Add clear and sb_reset

Clearing the terminal removes all lines in the scrollback buffer except
for the most recent.

With sb_reset, the terminal will return the scrollback buffer to the
bottom when the user starts typing if they have previously scrolled up.
This commit is contained in:
Leroy Hopson 2021-07-13 06:27:20 +07:00
parent ebb527cb8b
commit e8c27f2796
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
5 changed files with 40 additions and 12 deletions

View file

@ -73,6 +73,13 @@ func write(data) -> void:
_native_terminal.update()
func clear() -> void:
var initial_size = _native_terminal.rect_size
_native_terminal.rect_size.y = _native_terminal.cell_size.y
_native_terminal.clear_sb()
_native_terminal.rect_size = initial_size
func copy_selection() -> String:
return _native_terminal.copy_selection()
@ -115,6 +122,10 @@ func _refresh():
func _gui_input(event):
_native_terminal._gui_input(event)
if event is InputEventKey:
_native_terminal.sb_reset() # Return to bottom of scrollback buffer if we scrolled up.
_handle_mouse_wheel(event)
_handle_selection(event)