mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-27 11:06:31 +00:00
parameterize close_tab
- Add mode (`this`/`other`) parameter to `close_tab` keybind/apprt action. - Keybinds will default to `this` if not specified, eliminating backward compatibility issues (`keybind=x=close_tab` === `keybind=x=close_tab:this`). - Remove `close_other_tabs` keybind and apprt action.
This commit is contained in:
@@ -552,17 +552,17 @@ pub const Action = union(enum) {
|
||||
/// of the `confirm-close-surface` configuration setting.
|
||||
close_surface,
|
||||
|
||||
/// Close the current tab and all splits therein.
|
||||
/// Close the current tab and all splits therein _or_ close all tabs and
|
||||
/// splits thein of tabs _other_ than the current tab, depending on the
|
||||
/// mode.
|
||||
///
|
||||
/// If the mode is not specified, defaults to closing the current tab.
|
||||
///
|
||||
/// close-tab:other is only available on macOS.
|
||||
///
|
||||
/// This might trigger a close confirmation popup, depending on the value
|
||||
/// of the `confirm-close-surface` configuration setting.
|
||||
close_tab,
|
||||
|
||||
/// Close all tabs other than the currently focused one within the same
|
||||
/// window.
|
||||
///
|
||||
/// Only available on macOS currently.
|
||||
close_other_tabs,
|
||||
close_tab: CloseTabMode,
|
||||
|
||||
/// Close the current window and all tabs and splits therein.
|
||||
///
|
||||
@@ -864,6 +864,13 @@ pub const Action = union(enum) {
|
||||
hide,
|
||||
};
|
||||
|
||||
pub const CloseTabMode = enum {
|
||||
this,
|
||||
other,
|
||||
|
||||
pub const default: CloseTabMode = .this;
|
||||
};
|
||||
|
||||
fn parseEnum(comptime T: type, value: []const u8) !T {
|
||||
return std.meta.stringToEnum(T, value) orelse return Error.InvalidFormat;
|
||||
}
|
||||
@@ -1058,7 +1065,6 @@ pub const Action = union(enum) {
|
||||
.write_selection_file,
|
||||
.close_surface,
|
||||
.close_tab,
|
||||
.close_other_tabs,
|
||||
.close_window,
|
||||
.toggle_maximize,
|
||||
.toggle_fullscreen,
|
||||
|
||||
@@ -375,12 +375,6 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||
.description = "Show the on-screen keyboard if present.",
|
||||
}},
|
||||
|
||||
.close_other_tabs => comptime &.{.{
|
||||
.action = .close_other_tabs,
|
||||
.title = "Close Other Tabs",
|
||||
.description = "Close all tabs in this window except the current one.",
|
||||
}},
|
||||
|
||||
.open_config => comptime &.{.{
|
||||
.action = .open_config,
|
||||
.title = "Open Config",
|
||||
@@ -399,11 +393,27 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||
.description = "Close the current terminal.",
|
||||
}},
|
||||
|
||||
.close_tab => comptime &.{.{
|
||||
.action = .close_tab,
|
||||
.title = "Close Tab",
|
||||
.description = "Close the current tab.",
|
||||
}},
|
||||
.close_tab => comptime if (builtin.target.os.tag.isDarwin())
|
||||
&.{
|
||||
.{
|
||||
.action = .{ .close_tab = .this },
|
||||
.title = "Close Tab",
|
||||
.description = "Close the current tab.",
|
||||
},
|
||||
.{
|
||||
.action = .{ .close_tab = .other },
|
||||
.title = "Close Other Tabs",
|
||||
.description = "Close all tabs in this window except the current one.",
|
||||
},
|
||||
}
|
||||
else
|
||||
&.{
|
||||
.{
|
||||
.action = .{ .close_tab = .this },
|
||||
.title = "Close Tab",
|
||||
.description = "Close the current tab.",
|
||||
},
|
||||
},
|
||||
|
||||
.close_window => comptime &.{.{
|
||||
.action = .close_window,
|
||||
|
||||
Reference in New Issue
Block a user