diff --git a/src/Surface.zig b/src/Surface.zig index eb0c178ec..2b5e1cae8 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -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. diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 84eb3fe1c..00fed488f 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -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,