core: bindings for navigate_search

pull/9702/head
Mitchell Hashimoto 2025-11-25 10:48:31 -08:00
parent 880db9fdd0
commit ba7b816af0
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 33 additions and 0 deletions

View File

@ -4918,6 +4918,19 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.{ .change_needle = text },
.forever,
);
s.state.wakeup.notify() catch {};
},
.navigate_search => |nav| {
const s: *Search = if (self.search) |*s| s else return false;
_ = s.state.mailbox.push(
.{ .select = switch (nav) {
.next => .next,
.previous => .prev,
} },
.forever,
);
s.state.wakeup.notify() catch {};
},
.copy_to_clipboard => |format| {

View File

@ -336,6 +336,10 @@ pub const Action = union(enum) {
/// the search is canceled. If a previous search is active, it is replaced.
search: []const u8,
/// Navigate the search results. If there is no active search, this
/// is not performed.
navigate_search: NavigateSearch,
/// Clear the screen and all scrollback.
clear_screen,
@ -826,6 +830,11 @@ pub const Action = union(enum) {
}
};
pub const NavigateSearch = enum {
previous,
next,
};
pub const AdjustSelection = enum {
left,
right,
@ -1157,6 +1166,7 @@ pub const Action = union(enum) {
.text,
.cursor_key,
.search,
.navigate_search,
.reset,
.copy_to_clipboard,
.copy_url_to_clipboard,

View File

@ -163,6 +163,16 @@ fn actionCommands(action: Action.Key) []const Command {
.description = "Paste the contents of the selection clipboard.",
}},
.navigate_search => comptime &.{ .{
.action = .{ .navigate_search = .next },
.title = "Next Search Result",
.description = "Navigate to the next search result, if any.",
}, .{
.action = .{ .navigate_search = .previous },
.title = "Previous Search Result",
.description = "Navigate to the previous search result, if any.",
} },
.increase_font_size => comptime &.{.{
.action = .{ .increase_font_size = 1 },
.title = "Increase Font Size",