Skip to content

Commit ae294d9

Browse files
committed
Initial commit. v1.0.0
0 parents  commit ae294d9

7 files changed

Lines changed: 142 additions & 0 deletions

File tree

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Normalize EOL for all files that Git considers text files.
2+
* text=auto eol=lf
3+
4+
# Only include the addons folder when downloading from the Asset Library.
5+
/** export-ignore
6+
/addons !export-ignore
7+
/addons/** !export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Godot 4+ specific ignores
2+
.godot/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Gustavo Jaruga Cruz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gdscript func finder shortcuts
2+
3+
Very simple plugin that adds shortcuts to scroll to the previous and next func definitions.
4+
Inspired by PICO-8 script editor where you use the 'page up/down' keys to move acress functions.
5+
6+
Shortcuts:
7+
- Page Up : Go to previous 'func'
8+
- Page Down : Go to next 'func'
9+
10+
## TODO maybes
11+
12+
Right now, it replaces the behavior of the 'page up' and 'page down' keys inside the script editor.
13+
I could add a proper shortcut configuration in the future instead.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[plugin]
2+
3+
name="Gdscript func finder shortcuts"
4+
description="Makes page up and page down inside the script editor scroll to 'func' definitions."
5+
author="Gustjc"
6+
version="1.0.0"
7+
script="plugin_func_finder.gd"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@tool
2+
extends EditorPlugin
3+
4+
var use_shift: bool = false ## Hold shift with page-up and page-down to scroll to funcs
5+
6+
## Editor setting path
7+
const SCRIPT_USE_SHIFT: StringName = &"plugin/gdscript_func_finder/use_shift"
8+
9+
10+
func _enter_tree() -> void:
11+
if ProjectSettings.has_setting(SCRIPT_USE_SHIFT):
12+
use_shift = ProjectSettings.get_setting(SCRIPT_USE_SHIFT, use_shift)
13+
else:
14+
ProjectSettings.set_setting(SCRIPT_USE_SHIFT, use_shift)
15+
ProjectSettings.set_initial_value(SCRIPT_USE_SHIFT, use_shift)
16+
ProjectSettings.set_as_basic(SCRIPT_USE_SHIFT, true)
17+
18+
ProjectSettings.settings_changed.connect(sync_settings)
19+
20+
21+
func _exit_tree() -> void:
22+
ProjectSettings.settings_changed.disconnect(sync_settings)
23+
24+
25+
func sync_settings() -> void:
26+
use_shift = ProjectSettings.get_setting(SCRIPT_USE_SHIFT, use_shift)
27+
28+
29+
func _input(event: InputEvent) -> void:
30+
if event is InputEventKey:
31+
# Page Up
32+
if event.keycode == KEY_PAGEUP and event.pressed and (!use_shift or event.shift_pressed):
33+
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
34+
if code_edit.has_focus():
35+
move_prev_function(code_edit)
36+
get_viewport().set_input_as_handled()
37+
38+
# Page down
39+
if event.keycode == KEY_PAGEDOWN and event.pressed and (!use_shift or event.shift_pressed):
40+
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
41+
if code_edit.has_focus():
42+
move_next_function(code_edit)
43+
get_viewport().set_input_as_handled()
44+
45+
46+
func move_prev_function(code_edit: CodeEdit) -> void:
47+
var caret_line = code_edit.get_caret_line()
48+
var text_lines = code_edit.text.split("\n")
49+
50+
# Search backward for the function definition
51+
for i in range(caret_line-1, -1, -1):
52+
var line = text_lines[i].strip_edges()
53+
if line.begins_with("func "):
54+
code_edit.set_caret_line(i)
55+
code_edit.set_caret_column(line.length())
56+
return
57+
58+
59+
func move_next_function(code_edit: CodeEdit) -> void:
60+
var caret_line = code_edit.get_caret_line()
61+
var text_lines = code_edit.text.split("\n")
62+
63+
# Search fowards for the function definition
64+
for i in range(caret_line+1, text_lines.size()):
65+
var line = text_lines[i].strip_edges()
66+
if line.begins_with("func "):
67+
code_edit.set_caret_line(i)
68+
code_edit.set_caret_column(line.length())
69+
return

project.godot

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=5
10+
11+
[application]
12+
13+
config/name="Gdscript func finder pageup/down shortcuts"
14+
config/features=PackedStringArray("4.3", "Forward Plus")
15+
run/max_fps=60
16+
17+
[dotnet]
18+
19+
project/assembly_name="Gdscript func finder pageup-down shortcuts"
20+
21+
[editor_plugins]
22+
23+
enabled=PackedStringArray("res://addons/gdscript_func_finder/plugin.cfg")

0 commit comments

Comments
 (0)