core: performAction now returns a bool

This is to facilitate the `performable:` prefix on keybinds that are
implemented using app runtime actions.
This commit is contained in:
Jeffrey C. Ollie
2025-02-08 15:56:29 -06:00
committed by Mitchell Hashimoto
parent 66442cd469
commit 4ad749607a
5 changed files with 79 additions and 70 deletions

View File

@@ -569,7 +569,7 @@ pub fn init(
errdefer self.io.deinit();
// Report initial cell size on surface creation
try rt_app.performAction(
_ = try rt_app.performAction(
.{ .surface = self },
.cell_size,
.{ .width = size.cell.width, .height = size.cell.height },
@@ -581,7 +581,7 @@ pub fn init(
const min_window_width_cells: u32 = 10;
const min_window_height_cells: u32 = 4;
try rt_app.performAction(
_ = try rt_app.performAction(
.{ .surface = self },
.size_limit,
.{
@@ -645,7 +645,7 @@ pub fn init(
size.padding.top +
size.padding.bottom;
rt_app.performAction(
_ = rt_app.performAction(
.{ .surface = self },
.initial_size,
.{ .width = final_width, .height = final_height },
@@ -657,7 +657,7 @@ pub fn init(
}
if (config.title) |title| {
try rt_app.performAction(
_ = try rt_app.performAction(
.{ .surface = self },
.set_title,
.{ .title = title },
@@ -678,7 +678,7 @@ pub fn init(
break :xdg;
};
defer alloc.free(title);
try rt_app.performAction(
_ = try rt_app.performAction(
.{ .surface = self },
.set_title,
.{ .title = title },
@@ -831,7 +831,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
// We know that our title should end in 0.
const slice = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(v)), 0);
log.debug("changing title \"{s}\"", .{slice});
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.set_title,
.{ .title = slice },
@@ -867,7 +867,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
.color_change => |change| {
// Notify our apprt, but don't send a mode 2031 DSR report
// because VT sequences were used to change the color.
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.color_change,
.{
@@ -886,7 +886,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
.set_mouse_shape => |shape| {
log.debug("changing mouse shape: {}", .{shape});
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
shape,
@@ -918,7 +918,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
const str = try self.alloc.dupeZ(u8, w.slice());
defer self.alloc.free(str);
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.pwd,
.{ .pwd = str },
@@ -969,7 +969,7 @@ fn passwordInput(self: *Surface, v: bool) !void {
}
// Notify our apprt so it can do whatever it wants.
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.secure_input,
if (v) .on else .off,
@@ -1058,7 +1058,7 @@ fn mouseRefreshLinks(
self.renderer_state.mouse.point = pos_vp;
self.mouse.over_link = true;
self.renderer_state.terminal.screen.dirty.hyperlink_hover = true;
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
.pointer,
@@ -1071,7 +1071,7 @@ fn mouseRefreshLinks(
.trim = false,
});
defer self.alloc.free(str);
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_over_link,
.{ .url = str },
@@ -1085,7 +1085,7 @@ fn mouseRefreshLinks(
log.warn("failed to get URI for OSC8 hyperlink", .{});
break :link;
};
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_over_link,
.{ .url = uri },
@@ -1095,12 +1095,12 @@ fn mouseRefreshLinks(
try self.queueRender();
} else if (over_link) {
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
self.io.terminal.mouse_shape,
);
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_over_link,
.{ .url = "" },
@@ -1112,7 +1112,7 @@ fn mouseRefreshLinks(
/// Called when our renderer health state changes.
fn updateRendererHealth(self: *Surface, health: renderer.Health) void {
log.warn("renderer health status change status={}", .{health});
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.renderer_health,
health,
@@ -1124,7 +1124,7 @@ fn updateRendererHealth(self: *Surface, health: renderer.Health) void {
/// This should be called anytime `config_conditional_state` changes
/// so that the apprt can reload the configuration.
fn notifyConfigConditionalState(self: *Surface) void {
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.reload_config,
.{ .soft = true },
@@ -1204,14 +1204,14 @@ pub fn updateConfig(
// If we have a title set then we update our window to have the
// newly configured title.
if (config.title) |title| try self.rt_app.performAction(
if (config.title) |title| _ = try self.rt_app.performAction(
.{ .surface = self },
.set_title,
.{ .title = title },
);
// Notify the window
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.config_change,
.{ .config = config },
@@ -1478,7 +1478,7 @@ fn setCellSize(self: *Surface, size: renderer.CellSize) !void {
self.io.queueMessage(.{ .resize = self.size }, .unlocked);
// Notify the window
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.cell_size,
.{ .width = size.width, .height = size.height },
@@ -1774,12 +1774,12 @@ pub fn keyCallback(
};
} else if (self.io.terminal.flags.mouse_event != .none and !self.mouse.mods.shift) {
// If we have mouse reports on and we don't have shift pressed, we reset state
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
self.io.terminal.mouse_shape,
);
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_over_link,
.{ .url = "" },
@@ -1797,7 +1797,7 @@ pub fn keyCallback(
.mods = self.mouse.mods,
.over_link = self.mouse.over_link,
.hidden = self.mouse.hidden,
}).keyToMouseShape()) |shape| try self.rt_app.performAction(
}).keyToMouseShape()) |shape| _ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
shape,
@@ -1922,7 +1922,7 @@ fn maybeHandleBinding(
}
// Start or continue our key sequence
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.key_sequence,
.{ .trigger = entry.key_ptr.* },
@@ -2031,7 +2031,7 @@ fn endKeySequence(
mem: KeySequenceMemory,
) void {
// Notify apprt key sequence ended
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.key_sequence,
.end,
@@ -3367,12 +3367,12 @@ pub fn cursorPosCallback(
self.mouse.link_point = null;
if (self.mouse.over_link) {
self.mouse.over_link = false;
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_shape,
self.io.terminal.mouse_shape,
);
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.mouse_over_link,
.{ .url = "" },
@@ -3798,7 +3798,7 @@ fn scrollToBottom(self: *Surface) !void {
fn hideMouse(self: *Surface) void {
if (self.mouse.hidden) return;
self.mouse.hidden = true;
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.mouse_visibility,
.hidden,
@@ -3810,7 +3810,7 @@ fn hideMouse(self: *Surface) void {
fn showMouse(self: *Surface) void {
if (!self.mouse.hidden) return;
self.mouse.hidden = false;
self.rt_app.performAction(
_ = self.rt_app.performAction(
.{ .surface = self },
.mouse_visibility,
.visible,
@@ -4101,13 +4101,13 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
v,
),
.new_tab => try self.rt_app.performAction(
.new_tab => return try self.rt_app.performAction(
.{ .surface = self },
.new_tab,
{},
),
.close_tab => try self.rt_app.performAction(
.close_tab => return try self.rt_app.performAction(
.{ .surface = self },
.close_tab,
{},
@@ -4117,7 +4117,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.next_tab,
.last_tab,
.goto_tab,
=> |v, tag| try self.rt_app.performAction(
=> |v, tag| return try self.rt_app.performAction(
.{ .surface = self },
.goto_tab,
switch (tag) {
@@ -4129,13 +4129,13 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
),
.move_tab => |position| try self.rt_app.performAction(
.move_tab => |position| return try self.rt_app.performAction(
.{ .surface = self },
.move_tab,
.{ .amount = position },
),
.new_split => |direction| try self.rt_app.performAction(
.new_split => |direction| return try self.rt_app.performAction(
.{ .surface = self },
.new_split,
switch (direction) {
@@ -4150,7 +4150,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
),
.goto_split => |direction| try self.rt_app.performAction(
.goto_split => |direction| return try self.rt_app.performAction(
.{ .surface = self },
.goto_split,
switch (direction) {
@@ -4161,7 +4161,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
),
.resize_split => |value| try self.rt_app.performAction(
.resize_split => |value| return try self.rt_app.performAction(
.{ .surface = self },
.resize_split,
.{
@@ -4175,25 +4175,25 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
),
.equalize_splits => try self.rt_app.performAction(
.equalize_splits => return try self.rt_app.performAction(
.{ .surface = self },
.equalize_splits,
{},
),
.toggle_split_zoom => try self.rt_app.performAction(
.toggle_split_zoom => return try self.rt_app.performAction(
.{ .surface = self },
.toggle_split_zoom,
{},
),
.toggle_maximize => try self.rt_app.performAction(
.toggle_maximize => return try self.rt_app.performAction(
.{ .surface = self },
.toggle_maximize,
{},
),
.toggle_fullscreen => try self.rt_app.performAction(
.toggle_fullscreen => return try self.rt_app.performAction(
.{ .surface = self },
.toggle_fullscreen,
switch (self.config.macos_non_native_fullscreen) {
@@ -4203,19 +4203,19 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
},
),
.toggle_window_decorations => try self.rt_app.performAction(
.toggle_window_decorations => return try self.rt_app.performAction(
.{ .surface = self },
.toggle_window_decorations,
{},
),
.toggle_tab_overview => try self.rt_app.performAction(
.toggle_tab_overview => return try self.rt_app.performAction(
.{ .surface = self },
.toggle_tab_overview,
{},
),
.toggle_secure_input => try self.rt_app.performAction(
.toggle_secure_input => return try self.rt_app.performAction(
.{ .surface = self },
.secure_input,
.toggle,
@@ -4229,7 +4229,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
}
},
.inspector => |mode| try self.rt_app.performAction(
.inspector => |mode| return try self.rt_app.performAction(
.{ .surface = self },
.inspector,
switch (mode) {
@@ -4676,7 +4676,7 @@ fn showDesktopNotification(self: *Surface, title: [:0]const u8, body: [:0]const
self.app.last_notification_time = now;
self.app.last_notification_digest = new_digest;
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.desktop_notification,
.{
@@ -4696,7 +4696,7 @@ fn crashThreadState(self: *Surface) crash.sentry.ThreadState {
/// Tell the surface to present itself to the user. This may involve raising the
/// window and switching tabs.
fn presentSurface(self: *Surface) !void {
try self.rt_app.performAction(
_ = try self.rt_app.performAction(
.{ .surface = self },
.present_terminal,
{},