Commit 8aad24bb5c

8aad24bb5c3f9523d27242de48b6419675b16563

parent: 7f1797aa83

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 20:43 UTC

Mac palette: arrow-key selection, clearer names

↑/↓ and C-p/C-n move a highlighted row and Return runs it, with the selection handling Quick Open had. Act at Point (C-c C-c) is Update at Point.

Ref #222
Ref #138

Layout: unified · split

Changed files (6)
Sources/OrgApp/CommandTitles.swift +1 −1 · view
@@ -6,7 +6,6 @@ import Foundation
66enum CommandTitles {
77 static let all: [String] = [
88 String(localized: "Act at Point", comment: "Command title"),
9 String(localized: "Act at Point (C-c C-c)", comment: "Command title"),
109 String(localized: "Agenda", comment: "Command title"),
1110 String(localized: "Align Table", comment: "Command title"),
1211 String(localized: "Align table.el Table", comment: "Command title"),
@@ -327,6 +326,7 @@ enum CommandTitles {
327326 String(localized: "Unset Attachment Folder", comment: "Command title"),
328327 String(localized: "Up to Parent Heading", comment: "Command title"),
329328 String(localized: "Update Dynamic Block", comment: "Command title"),
329 String(localized: "Update at Point", comment: "Command title"),
330330 String(localized: "Use Selection for Find", comment: "Command title"),
331331 String(localized: "Verbatim", comment: "Command title"),
332332 String(localized: "Widen", comment: "Command title"),
Sources/OrgCore/Commands/CtrlCCtrlC.swift +1 −1 · view
@@ -10,7 +10,7 @@ import Foundation
1010public struct CtrlCCtrlC: OrgCommand {
1111 public init() {}
1212 public var id: String { "org.ctrl-c-ctrl-c" }
13 public var title: String { "Act at Point (C-c C-c)" }
13 public var title: String { "Update at Point" }
1414 public func applies(in context: EditContext) -> Bool { true }
1515
1616 static let nothing = CommandStep.failed("`C-c C-c' can do nothing useful here")
Sources/Orgstar/Keys.swift +22 −11 · view
@@ -216,6 +216,8 @@ struct PaletteView: View {
216216 let commands: AppCommands
217217 let run: (String) -> Void
218218 @State private var query = ""
219 /// The highlighted match, moved by ↑/↓ or C-p/C-n and run by Return.
220 @State private var selected = 0
219221 @Environment(\.dismiss) private var dismiss
220222
221223 private var matches: [EditorCommand] {
@@ -228,26 +230,35 @@ struct PaletteView: View {
228230
229231 var body: some View {
230232 let matches = matches
233 let current = min(selected, matches.count - 1)
231234 VStack(spacing: 0) {
232235 TextField("Run command", text: $query)
233236 .textFieldStyle(.plain)
234237 .font(.title3)
235238 .padding(12)
236 .onSubmit { if let first = matches.first { run(first.id) } }
239 .onSubmit { if current >= 0 { run(matches[current].id) } }
240 .movesSelection($selected, current: current, count: matches.count)
241 .onChange(of: query) { selected = 0 }
237242 Divider()
238 List(matches, id: \.id) { command in
239 Button {
240 run(command.id)
241 } label: {
242 HStack {
243 Text(command.localizedTitle)
244 Spacer()
245 if let keys = commands.keyLabel(for: command.id) {
246 Text(keys).font(.system(.caption, design: .monospaced)).foregroundStyle(.secondary)
243 ScrollViewReader { proxy in
244 List(matches.indices, id: \.self) { index in
245 let command = matches[index]
246 Button {
247 run(command.id)
248 } label: {
249 HStack {
250 Text(command.localizedTitle)
251 Spacer()
252 if let keys = commands.keyLabel(for: command.id) {
253 Text(keys).font(.system(.caption, design: .monospaced)).foregroundStyle(.secondary)
254 }
247255 }
256 .contentShape(Rectangle())
248257 }
258 .buttonStyle(.plain)
259 .selectedRow(index == current)
249260 }
250 .buttonStyle(.plain)
261 .onChange(of: current) { if current >= 0 { proxy.scrollTo(current) } }
251262 }
252263 }
253264 .frame(width: 520, height: 360)
Sources/Orgstar/SearchViews.swift +24 −10 · view
@@ -51,14 +51,7 @@ struct QuickOpenView: View {
5151 .font(.title3)
5252 .padding(12)
5353 .onSubmit { if current >= 0 { open(matches[current]) } }
54 .onKeyPress(phases: .down) { press in
55 let control = press.modifiers == .control
56 let step = if press.key == .downArrow || control && press.characters == "n" { 1 }
57 else if press.key == .upArrow || control && press.characters == "p" { -1 } else { 0 }
58 guard step != 0 else { return .ignored }
59 selected = max(0, min(current + step, matches.count - 1))
60 return .handled
61 }
54 .movesSelection($selected, current: current, count: matches.count)
6255 .onChange(of: query) { selected = 0 }
6356 Divider()
6457 ScrollViewReader { proxy in
@@ -75,8 +68,7 @@ struct QuickOpenView: View {
7568 .contentShape(Rectangle())
7669 }
7770 .buttonStyle(.plain)
78 .listRowBackground(index == current ? Color.accentColor.opacity(0.25) : Color.clear)
79 .accessibilityAddTraits(index == current ? .isSelected : [])
71 .selectedRow(index == current)
8072 }
8173 .onChange(of: current) { if current >= 0 { proxy.scrollTo(current) } }
8274 }
@@ -85,3 +77,25 @@ struct QuickOpenView: View {
8577 .onExitCommand { dismiss() }
8678 }
8779}
80
81extension View {
82 /// ↑/↓ and C-p/C-n move `selected` through `count` rows; `current` is the row shown as selected.
83 func movesSelection(_ selected: Binding<Int>, current: Int, count: Int) -> some View {
84 onKeyPress(phases: .down) { press in
85 let control = press.modifiers == .control
86 // Shift with an arrow is the date prompt's.
87 let plain = press.modifiers.intersection([.shift, .control, .option, .command]).isEmpty
88 let step = if press.key == .downArrow && plain || control && press.characters == "n" { 1 }
89 else if press.key == .upArrow && plain || control && press.characters == "p" { -1 } else { 0 }
90 guard step != 0, count > 0 else { return .ignored }
91 selected.wrappedValue = max(0, min(current + step, count - 1))
92 return .handled
93 }
94 }
95
96 /// The highlight of the row arrow keys select in a list.
97 func selectedRow(_ selected: Bool) -> some View {
98 listRowBackground(selected ? Color.accentColor.opacity(0.25) : Color.clear)
99 .accessibilityAddTraits(selected ? .isSelected : [])
100 }
101}
docs/manual/guide/03-keys.org +3 −3 · view
@@ -94,7 +94,7 @@ The palette lists every command by title with its keys in the current keymap. Op
9494- =M-x= in the Emacs and Doom presets (=execute-extended-command=),
9595- =SPC := in Doom normal state.
9696
97Type part of a title; matching is fuzzy and the best matches come first. =Return= runs the top match, a click runs any row, and =Esc= closes the palette. Each row shows up to two key sequences; in the Doom preset these are normal-state keys first, then insert-state keys.
97Type part of a title; matching is fuzzy and the best matches come first. =↑= and =↓= (or =C-p= and =C-n=) move the highlight, =Return= runs the highlighted command, a click runs any row, and =Esc= closes the palette. Quick Open (=⌘P=) works the same way. Each row shows up to two key sequences; in the Doom preset these are normal-state keys first, then insert-state keys.
9898
9999The palette leaves out text-system movement and editing commands (Forward Character, Kill Line, Set Mark and the like), which only make sense from keys. Every other command is in it, including the ones no preset binds, such as Show or Hide Backlinks, Import Table from File…, Recovery Versions… and Delete Property…. The Mac App Store version leaves out the Emacs exports and Attach File as Hard Link… and as Symbolic Link…; a key bound to Export to PDF with Emacs runs Export to PDF. Commands that cannot run at the caret show a message instead.
100100
@@ -955,7 +955,7 @@ When a key appears in several rows, it runs the command whose condition holds at
955955| Next Table Field (=org.table.next-field=) | =TAB= | =⇥= | =TAB= (I) | In a table, aligns it and moves to the next field, adding a row at the end (=org-table-next-field=). |
956956| Previous Table Field (=org.table.previous-field=) | =S-TAB= | =⇧⇥= | =S-TAB= (I) | In a table, moves to the previous field (=org-table-previous-field=). |
957957| Next Table Row (=org.table.next-row=) | =RET= | =↩= | =RET= (I) | In a table, moves to the same field in the next row, adding a row at the end (=org-table-next-row=). |
958| Align Table (=org.table.align=) | — | — | =SPC m b a= (N) | In a table, aligns it (=org-table-align=). =C-c C-c= in a table also aligns it; see Act at Point. |
958| Align Table (=org.table.align=) | — | — | =SPC m b a= (N) | In a table, aligns it (=org-table-align=). =C-c C-c= in a table also aligns it; see Update at Point. |
959959| Move Table Row Up (=org.table.row-up=) | =M-<up>= | =⌃⌘↑= | =M-k= | In a table, moves the row up (=org-table-move-row-up=). |
960960| Move Table Row Down (=org.table.row-down=) | =M-<down>= | =⌃⌘↓= | =M-j= | In a table, moves the row down (=org-table-move-row-down=). |
961961| Move Table Column Left (=org.table.column-left=) | =M-<left>= | =⌃⌘←= | =M-h=, =C-d= (I) | In a table, moves the column left (=org-table-move-column-left=). |
@@ -993,7 +993,7 @@ When a key appears in several rows, it runs the command whose condition holds at
993993
994994| Command | Emacs | Mac | Doom | What it does |
995995|-+-+-+-+-|
996| Act at Point (C-c C-c) (=org.ctrl-c-ctrl-c=) | =C-c C-c= | =⌃⌘X= | — | Does what fits the context: sets tags on a heading, toggles an item's checkbox, follows a footnote, offers the property menu in a property drawer, updates a clock line, statistics cookie or timestamp, runs a =#+CALL:= line, inline =call_= or inline =src_= block, and refreshes the setup on a =#+= keyword line (=org-ctrl-c-ctrl-c=). In a table it evaluates a formula typed in the field (starting with ~=~ or ~:=~), then recalculates the row when it is marked =#= and otherwise aligns the table; at the table's first character it recalculates the whole table. After a sparse tree, the first =C-c C-c= only clears the highlights. More specific bindings take =C-c C-c= and =⌃⌘X= in src blocks, =#+TBLFM= lines and dynamic blocks. |
996| Update at Point (=org.ctrl-c-ctrl-c=) | =C-c C-c= | =⌃⌘X= | — | Does what fits the context: sets tags on a heading, toggles an item's checkbox, follows a footnote, offers the property menu in a property drawer, updates a clock line, statistics cookie or timestamp, runs a =#+CALL:= line, inline =call_= or inline =src_= block, and refreshes the setup on a =#+= keyword line (=org-ctrl-c-ctrl-c=). In a table it evaluates a formula typed in the field (starting with ~=~ or ~:=~), then recalculates the row when it is marked =#= and otherwise aligns the table; at the table's first character it recalculates the whole table. After a sparse tree, the first =C-c C-c= only clears the highlights. More specific bindings take =C-c C-c= and =⌃⌘X= in src blocks, =#+TBLFM= lines and dynamic blocks. |
997997| Act at Point (=org.dwim=) | — | — | =RET= (N) | Doom's =+org/dwim-at-point=: follows a link, runs a src block, recalculates or aligns a table, toggles a checkbox, or switches a heading between TODO and done. |
998998| Run Source Block (=org.babel.execute=) | =C-c C-c= | =⌃⌘X= | — | In a src block, runs it and inserts the results (=org-babel-execute-src-block=). |
999999| Tangle File (=org.babel.tangle=) | =C-c C-v t=, =C-c C-v C-t= | =⌃⌘V= | — | Writes the file's src blocks to their tangle targets (=org-babel-tangle=). |
l10n/Localizable.xcstrings +35 −35 · view
@@ -2332,41 +2332,6 @@
23322332 }
23332333 }
23342334 },
2335 "Act at Point (C-c C-c)": {
2336 "comment": "Command title",
2337 "localizations": {
2338 "de": {
2339 "stringUnit": {
2340 "state": "translated",
2341 "value": "An der Einfügemarke ausführen (C-c C-c)"
2342 }
2343 },
2344 "es": {
2345 "stringUnit": {
2346 "state": "translated",
2347 "value": "Actuar en el punto (C-c C-c)"
2348 }
2349 },
2350 "fr": {
2351 "stringUnit": {
2352 "state": "translated",
2353 "value": "Agir au point (C-c C-c)"
2354 }
2355 },
2356 "ja": {
2357 "stringUnit": {
2358 "state": "translated",
2359 "value": "ポイントで実行(C-c C-c)"
2360 }
2361 },
2362 "pt-BR": {
2363 "stringUnit": {
2364 "state": "translated",
2365 "value": "Agir no Cursor (C-c C-c)"
2366 }
2367 }
2368 }
2369 },
23702335 "Actions": {
23712336 "localizations": {
23722337 "de": {
@@ -35207,6 +35172,41 @@
3520735172 }
3520835173 }
3520935174 },
35175 "Update at Point": {
35176 "comment": "Command title",
35177 "localizations": {
35178 "de": {
35179 "stringUnit": {
35180 "state": "translated",
35181 "value": "An der Einfügemarke aktualisieren"
35182 }
35183 },
35184 "es": {
35185 "stringUnit": {
35186 "state": "translated",
35187 "value": "Actualizar en el punto"
35188 }
35189 },
35190 "fr": {
35191 "stringUnit": {
35192 "state": "translated",
35193 "value": "Mettre à jour au point"
35194 }
35195 },
35196 "ja": {
35197 "stringUnit": {
35198 "state": "translated",
35199 "value": "ポイントで更新"
35200 }
35201 },
35202 "pt-BR": {
35203 "stringUnit": {
35204 "state": "translated",
35205 "value": "Atualizar no Cursor"
35206 }
35207 }
35208 }
35209 },
3521035210 "Use Copy": {
3521135211 "localizations": {
3521235212 "de": {
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form