core: change apprt action to enum value instead of a new one

This commit is contained in:
Mitchell Hashimoto
2025-12-11 16:09:08 -08:00
parent e93a4a911f
commit 65cf124e2c
6 changed files with 85 additions and 59 deletions

View File

@@ -5183,13 +5183,13 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.prompt_surface_title => return try self.rt_app.performAction(
.{ .surface = self },
.prompt_title,
{},
.surface,
),
.prompt_tab_title => return try self.rt_app.performAction(
.{ .surface = self },
.prompt_tab_title,
{},
.prompt_title,
.tab,
),
.clear_screen => {

View File

@@ -189,13 +189,9 @@ pub const Action = union(Key) {
set_title: SetTitle,
/// Set the title of the target to a prompted value. It is up to
/// the apprt to prompt.
prompt_title,
/// Set the title of the current tab/window to a prompted value. The title
/// set via this prompt overrides any title set by the terminal and persists
/// across focus changes within the tab. It is up to the apprt to prompt.
prompt_tab_title,
/// the apprt to prompt. The value specifies whether to prompt for the
/// surface title or the tab title.
prompt_title: PromptTitle,
/// The current working directory has changed for the target terminal.
pwd: Pwd,
@@ -352,7 +348,6 @@ pub const Action = union(Key) {
desktop_notification,
set_title,
prompt_title,
prompt_tab_title,
pwd,
mouse_shape,
mouse_visibility,
@@ -542,6 +537,12 @@ pub const MouseVisibility = enum(c_int) {
hidden,
};
/// Whether to prompt for the surface title or tab title.
pub const PromptTitle = enum(c_int) {
surface,
tab,
};
pub const MouseOverLink = struct {
url: [:0]const u8,

View File

@@ -693,7 +693,7 @@ pub const Application = extern struct {
.progress_report => return Action.progressReport(target, value),
.prompt_title => return Action.promptTitle(target),
.prompt_title => return Action.promptTitle(target, value),
.quit => self.quit(),
@@ -2250,12 +2250,18 @@ const Action = struct {
};
}
pub fn promptTitle(target: apprt.Target) bool {
switch (target) {
.app => return false,
.surface => |v| {
v.rt_surface.surface.promptTitle();
return true;
pub fn promptTitle(target: apprt.Target, value: apprt.action.PromptTitle) bool {
switch (value) {
.surface => switch (target) {
.app => return false,
.surface => |v| {
v.rt_surface.surface.promptTitle();
return true;
},
},
.tab => {
// GTK does not yet support tab title prompting
return false;
},
}
}