-
Notifications
You must be signed in to change notification settings - Fork 1.5k
macOS: Jump palette #9970
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?
macOS: Jump palette #9970
Changes from all commits
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 |
|---|---|---|
|
|
@@ -9,6 +9,9 @@ struct TerminalCommandPaletteView: View { | |
| /// result in the view disappearing. | ||
| @Binding var isPresented: Bool | ||
|
|
||
| /// Set this to true for the jump palette mode (only focus action). | ||
|
Contributor
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'd just change this to an enum of |
||
| @Binding var isJumpPalette: Bool | ||
|
|
||
| /// The configuration so we can lookup keyboard shortcuts. | ||
| @ObservedObject var ghosttyConfig: Ghostty.Config | ||
|
|
||
|
|
@@ -30,6 +33,7 @@ struct TerminalCommandPaletteView: View { | |
|
|
||
| CommandPaletteView( | ||
| isPresented: $isPresented, | ||
| isJumpPalette: $isJumpPalette, | ||
| backgroundColor: ghosttyConfig.backgroundColor, | ||
| options: commandOptions | ||
| ) | ||
|
|
@@ -58,13 +62,18 @@ struct TerminalCommandPaletteView: View { | |
| /// All commands available in the command palette, combining update and terminal options. | ||
| private var commandOptions: [CommandOption] { | ||
| var options: [CommandOption] = [] | ||
| // Updates always appear first | ||
| options.append(contentsOf: updateOptions) | ||
|
|
||
|
|
||
| if !isJumpPalette { | ||
| // Updates always appear first | ||
| options.append(contentsOf: updateOptions) | ||
| } | ||
|
Contributor
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. Change this to a |
||
|
|
||
| let restOptions = isJumpPalette ? jumpOptions : jumpOptions + terminalOptions; | ||
|
|
||
| // Sort the rest. We replace ":" with a character that sorts before space | ||
| // so that "Foo:" sorts before "Foo Bar:". Use sortKey as a tie-breaker | ||
| // for stable ordering when titles are equal. | ||
| options.append(contentsOf: (jumpOptions + terminalOptions).sorted { a, b in | ||
| options.append(contentsOf: restOptions.sorted { a, b in | ||
| let aNormalized = a.title.replacingOccurrences(of: ":", with: "\t") | ||
| let bNormalized = b.title.replacingOccurrences(of: ":", with: "\t") | ||
| let comparison = aNormalized.localizedCaseInsensitiveCompare(bNormalized) | ||
|
|
@@ -154,7 +163,7 @@ struct TerminalCommandPaletteView: View { | |
| } | ||
|
|
||
| return CommandOption( | ||
| title: "Focus: \(displayTitle)", | ||
| title: isJumpPalette ? displayTitle : "Focus: \(displayTitle)", | ||
|
Contributor
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. Remove this completely and change it so that in command palette mode we run a |
||
| subtitle: subtitle, | ||
| leadingIcon: "rectangle.on.rectangle", | ||
| leadingColor: displayColor?.displayColor.map { Color($0) }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,10 @@ protocol TerminalViewModel: ObservableObject { | |
|
|
||
| /// The command palette state. | ||
| var commandPaletteIsShowing: Bool { get set } | ||
|
|
||
| /// The command palette is reused for the focus palette, this indicates what | ||
| /// mode it should be in, true for the focus palette. | ||
| var commandPaletteIsJumpPalette: Bool { get set } | ||
|
Contributor
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. Replace |
||
|
|
||
| /// The update overlay should be visible. | ||
| var updateOverlayIsVisible: Bool { get } | ||
| } | ||
|
|
@@ -110,6 +113,7 @@ struct TerminalView<ViewModel: TerminalViewModel>: View { | |
| TerminalCommandPaletteView( | ||
| surfaceView: surfaceView, | ||
| isPresented: $viewModel.commandPaletteIsShowing, | ||
| isJumpPalette: $viewModel.commandPaletteIsJumpPalette, | ||
| ghosttyConfig: ghostty.config, | ||
| updateViewModel: (NSApp.delegate as? AppDelegate)?.updateViewModel) { action in | ||
| self.delegate?.performAction(action, on: surfaceView) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, doesn't have to be a binding, and just make it
placeholder: Stringand let downstream callers set it.