macos: handle search progress/total apprt actions

pull/9709/head
Mitchell Hashimoto 2025-11-25 20:44:19 -08:00
parent 2ee2d000f5
commit c20af77f98
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 52 additions and 0 deletions

View File

@ -612,6 +612,12 @@ extension Ghostty {
case GHOSTTY_ACTION_END_SEARCH:
endSearch(app, target: target)
case GHOSTTY_ACTION_SEARCH_TOTAL:
searchTotal(app, target: target, v: action.action.search_total)
case GHOSTTY_ACTION_SEARCH_SELECTED:
searchSelected(app, target: target, v: action.action.search_selected)
case GHOSTTY_ACTION_TOGGLE_TAB_OVERVIEW:
fallthrough
case GHOSTTY_ACTION_TOGGLE_WINDOW_DECORATIONS:
@ -1695,6 +1701,52 @@ extension Ghostty {
}
}
private static func searchTotal(
_ app: ghostty_app_t,
target: ghostty_target_s,
v: ghostty_action_search_total_s) {
switch (target.tag) {
case GHOSTTY_TARGET_APP:
Ghostty.logger.warning("search_total 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 }
let total: UInt? = v.total >= 0 ? UInt(v.total) : nil
DispatchQueue.main.async {
surfaceView.searchState?.total = total
}
default:
assertionFailure()
}
}
private static func searchSelected(
_ app: ghostty_app_t,
target: ghostty_target_s,
v: ghostty_action_search_selected_s) {
switch (target.tag) {
case GHOSTTY_TARGET_APP:
Ghostty.logger.warning("search_selected 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 }
let selected: UInt? = v.selected >= 0 ? UInt(v.selected) : nil
DispatchQueue.main.async {
surfaceView.searchState?.selected = selected
}
default:
assertionFailure()
}
}
private static func configReload(
_ app: ghostty_app_t,
target: ghostty_target_s,