mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-04 02:44:50 +00:00
input: add direct set_surface_title and set_tab_title actions
Fixes #11316 This mirrors the `prompt` actions (hence why there is no window action here) and enables setting titles via keybind actions which importantly lets this work via command palettes, App Intents, AppleScript, etc.
This commit is contained in:
@@ -201,6 +201,9 @@ pub const Action = union(Key) {
|
||||
/// Set the title of the target to the requested value.
|
||||
set_title: SetTitle,
|
||||
|
||||
/// Set the tab title override for the target's tab.
|
||||
set_tab_title: SetTitle,
|
||||
|
||||
/// Set the title of the target to a prompted value. It is up to
|
||||
/// the apprt to prompt. The value specifies whether to prompt for the
|
||||
/// surface title or the tab title.
|
||||
@@ -375,6 +378,7 @@ pub const Action = union(Key) {
|
||||
render_inspector,
|
||||
desktop_notification,
|
||||
set_title,
|
||||
set_tab_title,
|
||||
prompt_title,
|
||||
pwd,
|
||||
mouse_shape,
|
||||
|
||||
@@ -740,6 +740,7 @@ pub const Application = extern struct {
|
||||
.scrollbar => Action.scrollbar(target, value),
|
||||
|
||||
.set_title => Action.setTitle(target, value),
|
||||
.set_tab_title => return Action.setTabTitle(target, value),
|
||||
|
||||
.show_child_exited => return Action.showChildExited(target, value),
|
||||
|
||||
@@ -2545,6 +2546,30 @@ const Action = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setTabTitle(
|
||||
target: apprt.Target,
|
||||
value: apprt.action.SetTitle,
|
||||
) bool {
|
||||
switch (target) {
|
||||
.app => {
|
||||
log.warn("set_tab_title to app is unexpected", .{});
|
||||
return false;
|
||||
},
|
||||
.surface => |core| {
|
||||
const surface = core.rt_surface.surface;
|
||||
const tab = ext.getAncestor(
|
||||
Tab,
|
||||
surface.as(gtk.Widget),
|
||||
) orelse {
|
||||
log.warn("surface is not in a tab, ignoring set_tab_title", .{});
|
||||
return false;
|
||||
};
|
||||
tab.setTitleOverride(if (value.title.len == 0) null else value.title);
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn showChildExited(
|
||||
target: apprt.Target,
|
||||
value: apprt.surface.Message.ChildExited,
|
||||
|
||||
Reference in New Issue
Block a user