initial commit

This commit is contained in:
Sabarigirish Manikandan
2024-12-28 19:29:54 +05:30
committed by Mitchell Hashimoto
parent 34a0b206f8
commit 68a8c05f19
5 changed files with 34 additions and 0 deletions

View File

@ -562,6 +562,7 @@ typedef enum {
GHOSTTY_ACTION_QUIT,
GHOSTTY_ACTION_NEW_WINDOW,
GHOSTTY_ACTION_NEW_TAB,
GHOSTTY_ACTION_CLOSE_TAB,
GHOSTTY_ACTION_NEW_SPLIT,
GHOSTTY_ACTION_CLOSE_ALL_WINDOWS,
GHOSTTY_ACTION_TOGGLE_FULLSCREEN,

View File

@ -4061,6 +4061,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
{},
),
.close_tab => try self.rt_app.performAction(
.{ .surface = self },
.close_tab,
{},
),
inline .previous_tab,
.next_tab,
.last_tab,

View File

@ -82,6 +82,9 @@ pub const Action = union(Key) {
/// the tab should be opened in a new window.
new_tab,
/// Closes the tab belonging to the currently focused split.
close_tab,
/// Create a new split. The value determines the location of the split
/// relative to the target.
new_split: SplitDirection,
@ -225,6 +228,7 @@ pub const Action = union(Key) {
quit,
new_window,
new_tab,
close_tab,
new_split,
close_all_windows,
toggle_fullscreen,

View File

@ -477,6 +477,7 @@ pub fn performAction(
.toggle_fullscreen => self.toggleFullscreen(target, value),
.new_tab => try self.newTab(target),
.close_tab => try self.closeTab(target),
.goto_tab => self.gotoTab(target, value),
.move_tab => self.moveTab(target, value),
.new_split => try self.newSplit(target, value),
@ -532,6 +533,23 @@ fn newTab(_: *App, target: apprt.Target) !void {
}
}
fn closeTab(_: *App, target: apprt.Target) !void {
switch (target) {
.app => {},
.surface => |v| {
const window = v.rt_surface.container.window() orelse {
log.info(
"close_tab invalid for container={s}",
.{@tagName(v.rt_surface.container)},
);
return;
};
// TODO: get tab from surface
try window.closeTab(v);
},
}
}
fn gotoTab(_: *App, target: apprt.Target, tab: apprt.action.GotoTab) void {
switch (target) {
.app => {},
@ -1743,6 +1761,7 @@ fn initMenu(self: *App) void {
c.g_menu_append_section(menu, null, @ptrCast(@alignCast(section)));
c.g_menu_append(section, "New Window", "win.new_window");
c.g_menu_append(section, "New Tab", "win.new_tab");
c.g_menu_append(section, "Close Tab", "win.close_tab");
c.g_menu_append(section, "Split Right", "win.split_right");
c.g_menu_append(section, "Split Down", "win.split_down");
c.g_menu_append(section, "Close Window", "win.close");

View File

@ -383,6 +383,9 @@ pub const Action = union(enum) {
/// This only works for macOS currently.
close_all_windows: void,
/// Closes the tab belonging to the currently focused split.
close_tab: void,
/// Toggle fullscreen mode of window.
toggle_fullscreen: void,
@ -750,6 +753,7 @@ pub const Action = union(enum) {
.resize_split,
.equalize_splits,
.inspector,
.close_tab,
=> .surface,
};
}