apprt: end_search
parent
b084889782
commit
b7e70ce534
|
|
@ -817,6 +817,7 @@ typedef enum {
|
|||
GHOSTTY_ACTION_SHOW_ON_SCREEN_KEYBOARD,
|
||||
GHOSTTY_ACTION_COMMAND_FINISHED,
|
||||
GHOSTTY_ACTION_START_SEARCH,
|
||||
GHOSTTY_ACTION_END_SEARCH,
|
||||
} ghostty_action_tag_e;
|
||||
|
||||
typedef union {
|
||||
|
|
|
|||
|
|
@ -609,6 +609,9 @@ extension Ghostty {
|
|||
case GHOSTTY_ACTION_START_SEARCH:
|
||||
startSearch(app, target: target, v: action.action.start_search)
|
||||
|
||||
case GHOSTTY_ACTION_END_SEARCH:
|
||||
endSearch(app, target: target)
|
||||
|
||||
case GHOSTTY_ACTION_TOGGLE_TAB_OVERVIEW:
|
||||
fallthrough
|
||||
case GHOSTTY_ACTION_TOGGLE_WINDOW_DECORATIONS:
|
||||
|
|
@ -1667,6 +1670,27 @@ extension Ghostty {
|
|||
}
|
||||
}
|
||||
|
||||
private static func endSearch(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s) {
|
||||
switch (target.tag) {
|
||||
case GHOSTTY_TARGET_APP:
|
||||
Ghostty.logger.warning("end_search does nothing with an app target")
|
||||
return
|
||||
|
||||
case GHOSTTY_TARGET_SURFACE:
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
surfaceView.searchState = nil
|
||||
}
|
||||
|
||||
default:
|
||||
assertionFailure()
|
||||
}
|
||||
}
|
||||
|
||||
private static func configReload(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s,
|
||||
|
|
|
|||
|
|
@ -4892,7 +4892,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||
const s: *Search = if (self.search) |*s| s else init: {
|
||||
// If we're stopping the search and we had no prior search,
|
||||
// then there is nothing to do.
|
||||
if (text.len == 0) break :search;
|
||||
if (text.len == 0) return false;
|
||||
|
||||
// We need to assign directly to self.search because we need
|
||||
// a stable pointer back to the thread state.
|
||||
|
|
@ -4922,6 +4922,13 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||
if (text.len == 0) {
|
||||
s.deinit();
|
||||
self.search = null;
|
||||
|
||||
// Notify apprt search has ended.
|
||||
_ = try self.rt_app.performAction(
|
||||
.{ .surface = self },
|
||||
.end_search,
|
||||
{},
|
||||
);
|
||||
break :search;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ pub const Action = union(Key) {
|
|||
/// Start the search overlay with an optional initial needle.
|
||||
start_search: StartSearch,
|
||||
|
||||
/// End the search overlay, clearing the search state and hiding it.
|
||||
end_search,
|
||||
|
||||
/// Sync with: ghostty_action_tag_e
|
||||
pub const Key = enum(c_int) {
|
||||
quit,
|
||||
|
|
@ -362,6 +365,7 @@ pub const Action = union(Key) {
|
|||
show_on_screen_keyboard,
|
||||
command_finished,
|
||||
start_search,
|
||||
end_search,
|
||||
};
|
||||
|
||||
/// Sync with: ghostty_action_u
|
||||
|
|
|
|||
|
|
@ -6410,6 +6410,12 @@ pub const Keybinds = struct {
|
|||
.start_search,
|
||||
.{ .performable = true },
|
||||
);
|
||||
try self.set.putFlags(
|
||||
alloc,
|
||||
.{ .key = .{ .physical = .escape } },
|
||||
.{ .search = "" },
|
||||
.{ .performable = true },
|
||||
);
|
||||
|
||||
// Inspector, matching Chromium
|
||||
try self.set.put(
|
||||
|
|
|
|||
|
|
@ -179,6 +179,12 @@ fn actionCommands(action: Action.Key) []const Command {
|
|||
.description = "Navigate to the previous search result, if any.",
|
||||
} },
|
||||
|
||||
.search => comptime &.{.{
|
||||
.action = .{ .search = "" },
|
||||
.title = "End Search",
|
||||
.description = "End a search if one is active.",
|
||||
}},
|
||||
|
||||
.increase_font_size => comptime &.{.{
|
||||
.action = .{ .increase_font_size = 1 },
|
||||
.title = "Increase Font Size",
|
||||
|
|
@ -620,7 +626,6 @@ fn actionCommands(action: Action.Key) []const Command {
|
|||
.csi,
|
||||
.esc,
|
||||
.cursor_key,
|
||||
.search,
|
||||
.set_font_size,
|
||||
.scroll_to_row,
|
||||
.scroll_page_fractional,
|
||||
|
|
|
|||
Loading…
Reference in New Issue