-
-
Notifications
You must be signed in to change notification settings - Fork 985
feat: add UI zoom scaling for all non-terminal UI elements #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
fb05987
e3aefbd
3c2b1a5
a7649b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1163,6 +1163,46 @@ struct CommandPaletteDebugSnapshot { | |
| static let empty = CommandPaletteDebugSnapshot(query: "", mode: "commands", results: []) | ||
| } | ||
|
|
||
| enum UIZoomShortcutAction: Equatable { | ||
| case zoomIn | ||
| case zoomOut | ||
| case reset | ||
| } | ||
|
|
||
| func uiZoomShortcutAction( | ||
| flags: NSEvent.ModifierFlags, | ||
| chars: String, | ||
| keyCode: UInt16, | ||
| literalChars: String? = nil | ||
| ) -> UIZoomShortcutAction? { | ||
| let normalizedFlags = flags | ||
| .intersection(.deviceIndependentFlagsMask) | ||
| .subtracting([.numericPad, .function]) | ||
| // Require exactly Cmd+Shift (no Control, no Option) | ||
| guard normalizedFlags.contains(.command), | ||
| normalizedFlags.contains(.shift), | ||
| normalizedFlags.isDisjoint(with: [.control, .option]) else { return nil } | ||
| let keys = browserZoomShortcutKeyCandidates( | ||
| chars: chars, | ||
| literalChars: literalChars, | ||
| keyCode: keyCode | ||
| ) | ||
|
|
||
| if keys.contains("=") || keys.contains("+") || keyCode == 24 || keyCode == 69 { // kVK_ANSI_Equal / kVK_ANSI_KeypadPlus | ||
| return .zoomIn | ||
| } | ||
|
|
||
| if keys.contains("-") || keys.contains("_") || keyCode == 27 || keyCode == 78 { // kVK_ANSI_Minus / kVK_ANSI_KeypadMinus | ||
| return .zoomOut | ||
| } | ||
|
|
||
| if keys.contains("0") || keyCode == 29 || keyCode == 82 { // kVK_ANSI_0 / kVK_ANSI_Keypad0 | ||
| return .reset | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func browserZoomShortcutAction( | ||
| flags: NSEvent.ModifierFlags, | ||
| chars: String, | ||
|
|
@@ -7480,6 +7520,27 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent | |
| } | ||
| } | ||
|
|
||
| // UI zoom: Cmd+Shift+=/Cmd+Shift+-/Cmd+Shift+0 | ||
| if let uiZoomAction = uiZoomShortcutAction( | ||
| flags: flags, | ||
| chars: chars, | ||
| keyCode: event.keyCode, | ||
| literalChars: event.characters | ||
| ) { | ||
| let current = UIZoomMetrics.effectiveScale() | ||
| let next: Double | ||
| switch uiZoomAction { | ||
| case .zoomIn: | ||
| next = UIZoomMetrics.clamped(current + UIZoomMetrics.step) | ||
| case .zoomOut: | ||
| next = UIZoomMetrics.clamped(current - UIZoomMetrics.step) | ||
| case .reset: | ||
| next = UIZoomMetrics.defaultScale | ||
| } | ||
| UserDefaults.standard.set(next, forKey: UIZoomMetrics.appStorageKey) | ||
| return true | ||
| } | ||
|
Comment on lines
+7523
to
+7545
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shortcut is unreachable while the command palette is open. Line 6999 returns early for almost every Command shortcut while the palette is visible, so this block never runs for 🤖 Prompt for AI AgentsAdd DEBUG tracing for the new UI zoom shortcut path. The adjacent browser zoom path logs match/dispatch in DEBUG, but this new key route does not. Please add As per coding guidelines, "All debug events (keys, mouse, focus, splits, tabs) must be logged to the unified debug event log in DEBUG builds using the 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DEBUG tracing addressed in 3c2b1a5 — added Regarding the command palette guard: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, something went wrong! Please try again later. 🐰 💔
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't fix. This is intentional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I’ll treat the “UI zoom is intentionally blocked while the command palette is open” behavior as by-design for cmux and won’t flag it again. Optional (no action required): consider dropping a brief inline comment near shouldConsumeShortcutWhileCommandPaletteVisible to document that UI zoom is deliberately consumed while the palette is visible, to preempt future refactors. ✏️ Learnings added
🧠 Learnings used |
||
|
|
||
| #if DEBUG | ||
| logBrowserZoomShortcutTrace(stage: "probe", event: event, flags: flags, chars: chars) | ||
| #endif | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.