diff --git a/src/Surface.zig b/src/Surface.zig index d23ae0ea7..4323291be 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -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| { diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 1b681e725..ce60ea0e0 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -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, diff --git a/src/input/command.zig b/src/input/command.zig index 11f65cea3..a3df0e858 100644 --- a/src/input/command.zig +++ b/src/input/command.zig @@ -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",