core: clear_screen binding doesn't consume on alt screen

The clear_screen binding does nothing on the alternate screen already,
but we were still marking the action as "performed" which caused the
binding to be consumed.

This meant that alt screen applications like neovim, tmux, etc. couldn't
see "cmd+k" (default binding for clear_screen on macOS) without the
Ghostty user unbinding it completely.

We already have other bindings that do not consume only when they do not
perform, such as `previous_tab` and `next_tab`. This extends the
framework we built for that to this action.
This commit is contained in:
Mitchell Hashimoto
2024-01-07 07:54:42 -08:00
parent 76f760c7eb
commit 383b7c5870

View File

@ -2788,6 +2788,17 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
.clear_screen => {
// This is a duplicate of some of the logic in termio.clearScreen
// but we need to do this here so we can know the answer before
// we send the message. If the currently active screen is on the
// alternate screen then clear screen does nothing so we want to
// return false so the keybind can be unconsumed.
{
self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock();
if (self.io.terminal.active_screen == .alternate) return false;
}
_ = self.io_thread.mailbox.push(.{
.clear_screen = .{ .history = true },
}, .{ .forever = {} });