From aa2b93248e9d854bdecd94c17a65272e42d5c0cd Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Tue, 13 Feb 2024 11:27:07 +1300 Subject: [PATCH] Perform GDScript format checks using pre-commit --- .github/workflows/main.yml | 13 +++---------- .pre-commit-config.yaml | 5 +++++ addons/godot_xterm/terminal.gd | 23 +++++++++++++---------- requirements.txt | 1 - 4 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8667e8..2d0c120 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -320,16 +320,9 @@ jobs: exit 1 fi - check-code-format: - name: "Check Code Format" + check-pre-commit: + name: "Check Pre-Commit" runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.9 - cache: "pip" - - name: Install python dependencies - run: pip install -r requirements.txt - - name: GDScript format check - run: gdformat -c . + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fec2f45..bd19593 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,8 @@ repos: rev: v3.1.0 hooks: - id: prettier + - repo: https://github.com/Scony/godot-gdscript-toolkit + rev: 4.2.2 + hooks: + - id: gdformat + exclude: "^addons/gut/" diff --git a/addons/godot_xterm/terminal.gd b/addons/godot_xterm/terminal.gd index e896274..208b411 100644 --- a/addons/godot_xterm/terminal.gd +++ b/addons/godot_xterm/terminal.gd @@ -24,9 +24,9 @@ enum SelectionMode { POINTER, } -@export var update_mode: UpdateMode = UpdateMode.AUTO : +@export var update_mode: UpdateMode = UpdateMode.AUTO: get: - return update_mode # TODOConverter40 Non existent get function + return update_mode # TODOConverter40 Non existent get function set(p_update_mode): set_update_mode(p_update_mode) @@ -113,9 +113,9 @@ func _ready(): _update_theme() _native_terminal.update_mode = update_mode - _native_terminal.connect("data_sent",Callable(self,"_on_data_sent")) - _native_terminal.connect("key_pressed",Callable(self,"_on_key_pressed")) - _native_terminal.connect("size_changed",Callable(self,"_on_size_changed")) + _native_terminal.connect("data_sent", Callable(self, "_on_data_sent")) + _native_terminal.connect("key_pressed", Callable(self, "_on_key_pressed")) + _native_terminal.connect("size_changed", Callable(self, "_on_size_changed")) _viewport.size = size _viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS @@ -123,12 +123,12 @@ func _ready(): _screen.set_anchors_preset(PRESET_VCENTER_WIDE) _screen.texture = _viewport.get_texture() - _native_terminal.connect("bell",Callable(self,"_on_bell")) + _native_terminal.connect("bell", Callable(self, "_on_bell")) _bell_timer.one_shot = true add_child(_bell_timer) _selection_timer.wait_time = 0.05 - _selection_timer.connect("timeout",Callable(self,"_on_selection_held")) + _selection_timer.connect("timeout", Callable(self, "_on_selection_held")) add_child(_viewport) add_child(_screen) @@ -140,7 +140,7 @@ func _ready(): # we make all the draw_* calls caused by writing. We need to use signals # here rather than yield otherwise we will sometimes get a "Resumed # function after yield but class instance is gone" error. - RenderingServer.connect("frame_pre_draw",Callable(self,"_flush")) + RenderingServer.connect("frame_pre_draw", Callable(self, "_flush")) func _update_theme(): @@ -176,7 +176,7 @@ func _refresh(): func _gui_input(event): - _native_terminal.__gui_input(event) # FIXME: use _gui_input rather than __gui_input. + _native_terminal.__gui_input(event) # FIXME: use _gui_input rather than __gui_input. if event is InputEventKey and event.pressed: # Return to bottom of scrollback buffer if we scrolled up. Ignore modifier @@ -243,7 +243,10 @@ func _handle_selection(event: InputEventMouse): func _on_selection_held() -> void: - if not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or _selecting_mode == SelectionMode.NONE: + if ( + not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) + or _selecting_mode == SelectionMode.NONE + ): if copy_on_selection: var selection = _native_terminal.copy_selection() # TODO:godot4 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 562d971..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -gdtoolkit==4.2.2