Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ac9b99
Expose terminal Cmd+A falling through to viewport selection
austinywang May 12, 2026
e34136f
Route terminal Select All through command input semantics
austinywang May 12, 2026
3463bf2
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 12, 2026
716b8b5
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 12, 2026
d71fbb0
Fix terminal select-all cursor row targeting
austinywang May 12, 2026
0871c58
Fix synthetic select-all mouse release handling
austinywang May 12, 2026
51142bd
Fix Ghostty none modifier warnings
austinywang May 12, 2026
cc40826
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 12, 2026
416f5c8
fix: restore ghostty submodule pointer
austinywang May 12, 2026
08db99e
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 12, 2026
c3d7bb7
Use Ghostty cursor-line selection for terminal Cmd+A
austinywang May 12, 2026
f66bc1e
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 13, 2026
3a074fa
fix: pin GhosttyKit artifact for Ghostty bump
austinywang May 13, 2026
23e47cb
fix: update workspace test resume state argument
austinywang May 13, 2026
a1d9061
fix: keep terminal select all action private
austinywang May 13, 2026
280840a
fix: document select all action visibility
austinywang May 13, 2026
0e24fad
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 14, 2026
c16fa03
fix: avoid empty bash array expansion in ghostty scripts
austinywang May 14, 2026
99a591d
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 18, 2026
4ef5eb8
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 18, 2026
55e1462
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 18, 2026
b461417
Merge remote-tracking branch 'origin/main' into issue-3802-warp-style…
austinywang May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sources/App/ShortcutRoutingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ func shouldRouteTerminalFontZoomShortcutToGhostty(
literalChars: literalChars
) != nil
}

func shouldRouteTerminalSelectAllToNaturalTextEngine(_ event: NSEvent) -> Bool {
guard event.type == .keyDown else { return false }
let flags = event.modifierFlags
.intersection(.deviceIndependentFlagsMask)
.subtracting([.numericPad, .function, .capsLock])
guard flags == [.command] else { return false }
return event.charactersIgnoringModifiers?.lowercased() == "a"
}

@discardableResult
func startOrFocusTerminalSearch(
_ terminalSurface: TerminalSurface,
Expand Down
8 changes: 8 additions & 0 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14379,6 +14379,14 @@ private extension NSWindow {
ghosttyView.keyDown(with: event)
#if DEBUG
cmuxDebugLog("zoom.shortcut stage=window.ghosttyKeyDownDirect event=\(Self.keyDescription(event)) handled=1")
#endif
return true
}

if shouldRouteTerminalSelectAllToNaturalTextEngine(event) {
ghosttyView.selectAll(nil)
#if DEBUG
cmuxDebugLog(" → terminal natural text select-all")
#endif
return true
}
Expand Down
106 changes: 106 additions & 0 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,33 @@ func terminalKeyboardCopyModeInitialViewportRow(
return max(0, min(clampedRows - 1, estimatedRow))
}

func terminalCursorCellClickPoint(
imePointX: Double,
imePointY: Double,
imeCellWidth: Double,
imeCellHeight: Double,
fallbackCellSize: CGSize,
boundsSize: CGSize
) -> CGPoint {
let cellWidth = max(imeCellWidth, Double(fallbackCellSize.width), 1)
let cellHeight = max(imeCellHeight, Double(fallbackCellSize.height), 1)
return CGPoint(
x: terminalClampSurfaceClickCoordinate(
imePointX + cellWidth * 0.5,
upperBound: Double(boundsSize.width)
),
y: terminalClampSurfaceClickCoordinate(
imePointY - cellHeight * 0.5,
upperBound: Double(boundsSize.height)
)
)
}

func terminalClampSurfaceClickCoordinate(_ value: Double, upperBound: Double) -> Double {
guard upperBound > 0 else { return 0 }
return min(max(value, 0), max(upperBound - 1, 0))
}

private func terminalKeyboardCopyModeNormalizedModifiers(
_ modifierFlags: NSEvent.ModifierFlags
) -> NSEvent.ModifierFlags {
Expand Down Expand Up @@ -7011,6 +7038,85 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {

// MARK: - Input Handling

@IBAction override func selectAll(_ sender: Any?) {
_ = selectCommandLineAtCursorOrAll()
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

@discardableResult
private func selectCommandLineAtCursorOrAll() -> Bool {
guard let surface = ensureSurfaceReadyForInput() else {
requestInputRecoveryAfterSurfaceMiss(reason: "selectAll.missingSurface")
return false
}

if selectCommandLineAtCursor(surface: surface) {
invalidateTextInputCoordinates(selectionChanged: true)
return true
}

let selected = performBindingAction("select_all")
if selected {
invalidateTextInputCoordinates(selectionChanged: true)
}
return selected
}

private func selectCommandLineAtCursor(surface: ghostty_surface_t) -> Bool {
// Ghostty reports active xterm mouse reporting as captured; do not send
// synthetic selection clicks while a TUI owns mouse events.
guard !ghostty_surface_mouse_captured(surface) else { return false }
guard bounds.width > 0, bounds.height > 0 else { return false }

var x: Double = 0
var y: Double = 0
var width: Double = cellSize.width
var height: Double = cellSize.height
ghostty_surface_ime_point(surface, &x, &y, &width, &height)

let clickPoint = terminalCursorCellClickPoint(
imePointX: x,
imePointY: y,
imeCellWidth: width,
imeCellHeight: height,
fallbackCellSize: cellSize,
boundsSize: bounds.size
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
let clickX = Double(clickPoint.x)
let clickY = Double(clickPoint.y)
let resetX = clickX > max(cellSize.width * 2, 2) ? 0 : max(bounds.width - 1, 0)
let resetY = clickY > max(cellSize.height * 2, 2) ? 0 : max(bounds.height - 1, 0)

let mods = ghostty_input_mods_e(rawValue: GHOSTTY_MODS_NONE.rawValue) ?? GHOSTTY_MODS_NONE
_ = ghostty_surface_clear_selection_compat(surface)

// Force Ghostty's multi-click state to restart before issuing the triple
// click that reaches Screen.selectLine and its OSC 133 input boundaries.
guard sendSurfaceLeftClick(surface: surface, x: resetX, y: resetY, mods: mods) else {
return false
}

for _ in 0 ..< 3 {
guard sendSurfaceLeftClick(surface: surface, x: clickX, y: clickY, mods: mods) else {
return false
}
}
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved

return ghostty_surface_has_selection(surface)
}

private func sendSurfaceLeftClick(
surface: ghostty_surface_t,
x: Double,
y: Double,
mods: ghostty_input_mods_e
) -> Bool {
ghostty_surface_mouse_pos(surface, x, y, mods)
guard ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_PRESS, GHOSTTY_MOUSE_LEFT, mods) else {
return false
}
return ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_RELEASE, GHOSTTY_MOUSE_LEFT, mods)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

@IBAction func copy(_ sender: Any?) {
_ = performBindingAction("copy_to_clipboard")
}
Expand Down
50 changes: 50 additions & 0 deletions cmuxTests/AppDelegateShortcutRoutingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ private final class GhosttyCommandEquivalentProbeView: GhosttyNSView {
var afterMenuMissCallCount = 0
var keyDownCallCount = 0
var lastKeyDownCharactersIgnoringModifiers: String?
var selectAllCallCount = 0
var pasteCallCount = 0
var pasteAsPlainTextCallCount = 0
var performAfterMenuMissResult = true
Expand All @@ -34,6 +35,10 @@ private final class GhosttyCommandEquivalentProbeView: GhosttyNSView {
lastKeyDownCharactersIgnoringModifiers = event.charactersIgnoringModifiers
}

override func selectAll(_ sender: Any?) {
selectAllCallCount += 1
}

override func paste(_ sender: Any?) {
pasteCallCount += 1
}
Expand Down Expand Up @@ -5281,6 +5286,51 @@ final class AppDelegateShortcutRoutingTests: XCTestCase {
)
}

func testWindowPerformKeyEquivalentRoutesTerminalCmdAToResponderSelectAll() {
let previousMainMenu = NSApp.mainMenu
let probeWindow = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 320, height: 240),
styleMask: [.titled, .closable],
backing: .buffered,
defer: false
)
let contentView = NSView(frame: probeWindow.contentRect(forFrameRect: probeWindow.frame))
let probeView = GhosttyCommandEquivalentProbeView(frame: NSRect(x: 0, y: 0, width: 200, height: 120))

defer {
NSApp.mainMenu = previousMainMenu
probeWindow.orderOut(nil)
}

let emptyMenu = NSMenu(title: "Test")
emptyMenu.addItem(withTitle: "Placeholder", action: nil, keyEquivalent: "")
NSApp.mainMenu = emptyMenu

probeWindow.contentView = contentView
contentView.addSubview(probeView)
probeWindow.makeKeyAndOrderFront(nil)
probeWindow.displayIfNeeded()
XCTAssertTrue(probeWindow.makeFirstResponder(probeView), "Expected probe Ghostty view to own first responder")

guard let event = makeKeyDownEvent(
key: "a",
modifiers: [.command],
keyCode: 0,
windowNumber: probeWindow.windowNumber
) else {
XCTFail("Failed to construct Cmd+A event")
return
}

XCTAssertTrue(
probeWindow.performKeyEquivalent(with: event),
"Cmd+A in a terminal should use the terminal responder's natural text selection path"
)
XCTAssertEqual(probeView.selectAllCallCount, 1, "Terminal Cmd+A should invoke selectAll on the Ghostty responder")
XCTAssertEqual(probeView.afterMenuMissCallCount, 0, "Terminal Cmd+A must not fall through to Ghostty's viewport-wide select_all binding")
XCTAssertEqual(probeView.keyDownCallCount, 0, "Terminal Cmd+A must not be sent as a raw terminal key event")
}

func testWindowPerformKeyEquivalentForwardsClearedCmdDPastStaleMenuShortcut() {
let previousMainMenu = NSApp.mainMenu
let probeWindow = NSWindow(
Expand Down
32 changes: 32 additions & 0 deletions cmuxTests/TerminalAndGhosttyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,38 @@ final class TerminalKeyboardCopyModeViewportRowTests: XCTestCase {
23
)
}

func testCursorCellClickPointUsesCursorRowCenterFromImeBaseline() {
let point = terminalCursorCellClickPoint(
imePointX: 48,
imePointY: 240,
imeCellWidth: 12,
imeCellHeight: 24,
fallbackCellSize: CGSize(width: 12, height: 24),
boundsSize: CGSize(width: 960, height: 576)
)

XCTAssertEqual(point.x, 54)
XCTAssertEqual(
point.y,
228,
"IME Y is already one cell below the cursor row, so the click should subtract half a cell"
)
}

func testCursorCellClickPointClampsToSurfaceBounds() {
XCTAssertEqual(
terminalCursorCellClickPoint(
imePointX: 995,
imePointY: 5,
imeCellWidth: 20,
imeCellHeight: 20,
fallbackCellSize: CGSize(width: 20, height: 20),
boundsSize: CGSize(width: 100, height: 80)
),
CGPoint(x: 99, y: 0)
)
}
}


Expand Down
Loading