core: add "reset" keybinding to reset the terminal

Fixes #1425
This commit is contained in:
Mitchell Hashimoto
2024-02-01 08:38:34 -08:00
parent 61b964b958
commit eafc9559d7
2 changed files with 15 additions and 0 deletions

View File

@ -2920,6 +2920,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
try self.io_thread.wakeup.notify();
},
.reset => {
self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock();
self.renderer_state.terminal.fullReset(self.alloc);
},
.copy_to_clipboard => {
// We can read from the renderer state without holding
// the lock because only we will write to this field.

View File

@ -143,6 +143,15 @@ pub const Action = union(enum) {
/// (`application`) or disabled (`normal`).
cursor_key: CursorKey,
/// Reset the terminal. This can fix a lot of issues when a running
/// program puts the terminal into a broken state. This is equivalent to
/// when you type "reset" and press enter.
///
/// If you do this while in a TUI program such as vim, this may break
/// the program. If you do this while in a shell, you may have to press
/// enter after to get a new prompt.
reset: void,
/// Copy and paste.
copy_to_clipboard: void,
paste_from_clipboard: void,