Prevent scrollback buffer reset when using copy shortcut

Prevents scrollback buffer reset (i.e. scrolling to the bottom of
terminal output) when pressing modifier keys in isolation or when
copying text using the shortcut Ctrl+Shift+C.
This commit is contained in:
Leroy Hopson 2022-06-27 00:41:24 +07:00
parent cf613708c4
commit b76f8d0939
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 10 additions and 2 deletions

View file

@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Shortcuts starting with Ctrl + Shift. This includes the remaining default terminal - Shortcuts starting with Ctrl + Shift. This includes the remaining default terminal
panel shortcuts such as 'Copy' (Ctrl+Shift+C) and 'New Terminal' (Ctrl+Shift+T). panel shortcuts such as 'Copy' (Ctrl+Shift+C) and 'New Terminal' (Ctrl+Shift+T).
- Target Godot version from 3.3.2-stable -> 3.4.4-stable. - Target Godot version from 3.3.2-stable -> 3.4.4-stable.
- Prevent scrollback buffer reset (i.e. scrolling to the bottom of terminal output) when
pressing modifier keys in isolation or when copying text using the shortcut Ctrl+Shift+C.
### Removed ### Removed
- Removed custom TerminalSettings Resource type. - Removed custom TerminalSettings Resource type.

View file

@ -175,8 +175,14 @@ func _refresh():
func _gui_input(event): func _gui_input(event):
_native_terminal._gui_input(event) _native_terminal._gui_input(event)
if event is InputEventKey: if event is InputEventKey and event.pressed:
_native_terminal.sb_reset() # Return to bottom of scrollback buffer if we scrolled up. # Return to bottom of scrollback buffer if we scrolled up. Ignore modifier
# keys pressed in isolation or if Ctrl+Shift modifier keys are pressed.
if (
not event.scancode in [KEY_ALT, KEY_SHIFT, KEY_CONTROL, KEY_META, KEY_MASK_CMD]
and not (event.control and event.shift)
):
_native_terminal.sb_reset()
_handle_mouse_wheel(event) _handle_mouse_wheel(event)
_handle_selection(event) _handle_selection(event)