mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-05 03:14:14 +00:00
macOS: add Cmd+J "Jump to Selection" menu item and default binding
This matches other built-in macOS apps like Terminal, Notes, Safari. We already had the binding, just needed to create the menu. https://ampcode.com/threads/T-019b956a-f4e6-71b4-87fa-4162258d33ff
This commit is contained in:
@@ -47,6 +47,7 @@ class AppDelegate: NSObject,
|
||||
@IBOutlet private var menuFindParent: NSMenuItem?
|
||||
@IBOutlet private var menuFind: NSMenuItem?
|
||||
@IBOutlet private var menuSelectionForFind: NSMenuItem?
|
||||
@IBOutlet private var menuScrollToSelection: NSMenuItem?
|
||||
@IBOutlet private var menuFindNext: NSMenuItem?
|
||||
@IBOutlet private var menuFindPrevious: NSMenuItem?
|
||||
@IBOutlet private var menuHideFindBar: NSMenuItem?
|
||||
@@ -617,6 +618,7 @@ class AppDelegate: NSObject,
|
||||
syncMenuShortcut(config, action: "select_all", menuItem: self.menuSelectAll)
|
||||
syncMenuShortcut(config, action: "start_search", menuItem: self.menuFind)
|
||||
syncMenuShortcut(config, action: "search_selection", menuItem: self.menuSelectionForFind)
|
||||
syncMenuShortcut(config, action: "scroll_to_selection", menuItem: self.menuScrollToSelection)
|
||||
syncMenuShortcut(config, action: "search:next", menuItem: self.menuFindNext)
|
||||
syncMenuShortcut(config, action: "search:previous", menuItem: self.menuFindPrevious)
|
||||
|
||||
|
||||
@@ -289,6 +289,12 @@
|
||||
<action selector="selectionForFind:" target="-1" id="rhL-7g-XQQ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Jump to Selection" id="1rN-4k-Dz3">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="scrollToSelection:" target="-1" id="5gS-8h-Xm2"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
|
||||
@@ -1388,6 +1388,10 @@ class BaseTerminalController: NSWindowController,
|
||||
focusedSurface?.selectionForFind(sender)
|
||||
}
|
||||
|
||||
@IBAction func scrollToSelection(_ sender: Any) {
|
||||
focusedSurface?.scrollToSelection(sender)
|
||||
}
|
||||
|
||||
@IBAction func findNext(_ sender: Any) {
|
||||
focusedSurface?.findNext(sender)
|
||||
}
|
||||
|
||||
@@ -1527,6 +1527,14 @@ extension Ghostty {
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func scrollToSelection(_ sender: Any?) {
|
||||
guard let surface = self.surface else { return }
|
||||
let action = "scroll_to_selection"
|
||||
if (!ghostty_surface_binding_action(surface, action, UInt(action.lengthOfBytes(using: .utf8)))) {
|
||||
AppDelegate.logger.warning("action failed action=\(action)")
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func findNext(_ sender: Any?) {
|
||||
guard let surface = self.surface else { return }
|
||||
let action = "search:next"
|
||||
|
||||
@@ -6446,6 +6446,12 @@ pub const Keybinds = struct {
|
||||
.{ .key = .{ .physical = .page_down }, .mods = .{ .super = true } },
|
||||
.{ .scroll_page_down = {} },
|
||||
);
|
||||
try self.set.putFlags(
|
||||
alloc,
|
||||
.{ .key = .{ .unicode = 'j' }, .mods = .{ .super = true } },
|
||||
.{ .scroll_to_selection = {} },
|
||||
.{ .performable = true },
|
||||
);
|
||||
|
||||
// Semantic prompts
|
||||
try self.set.put(
|
||||
|
||||
Reference in New Issue
Block a user