Commit 8aad24bb5c
Verified · cmc
Changed files (6)
Sources/OrgApp/CommandTitles.swift +1 −1 · view
| @@ -6,7 +6,6 @@ import Foundation | ||
| 6 | 6 | enum CommandTitles { |
| 7 | 7 | static let all: [String] = [ |
| 8 | 8 | String(localized: "Act at Point", comment: "Command title"), |
| 9 | String(localized: "Act at Point (C-c C-c)", comment: "Command title"), | |
| 10 | 9 | String(localized: "Agenda", comment: "Command title"), |
| 11 | 10 | String(localized: "Align Table", comment: "Command title"), |
| 12 | 11 | String(localized: "Align table.el Table", comment: "Command title"), |
| @@ -327,6 +326,7 @@ enum CommandTitles { | ||
| 327 | 326 | String(localized: "Unset Attachment Folder", comment: "Command title"), |
| 328 | 327 | String(localized: "Up to Parent Heading", comment: "Command title"), |
| 329 | 328 | String(localized: "Update Dynamic Block", comment: "Command title"), |
| 329 | String(localized: "Update at Point", comment: "Command title"), | |
| 330 | 330 | String(localized: "Use Selection for Find", comment: "Command title"), |
| 331 | 331 | String(localized: "Verbatim", comment: "Command title"), |
| 332 | 332 | String(localized: "Widen", comment: "Command title"), |
Sources/OrgCore/Commands/CtrlCCtrlC.swift +1 −1 · view
| @@ -10,7 +10,7 @@ import Foundation | ||
| 10 | 10 | public struct CtrlCCtrlC: OrgCommand { |
| 11 | 11 | public init() {} |
| 12 | 12 | 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" } | |
| 14 | 14 | public func applies(in context: EditContext) -> Bool { true } |
| 15 | 15 | |
| 16 | 16 | 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 { | ||
| 216 | 216 | let commands: AppCommands |
| 217 | 217 | let run: (String) -> Void |
| 218 | 218 | @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 | |
| 219 | 221 | @Environment(\.dismiss) private var dismiss |
| 220 | 222 | |
| 221 | 223 | private var matches: [EditorCommand] { |
| @@ -228,26 +230,35 @@ struct PaletteView: View { | ||
| 228 | 230 | |
| 229 | 231 | var body: some View { |
| 230 | 232 | let matches = matches |
| 233 | let current = min(selected, matches.count - 1) | |
| 231 | 234 | VStack(spacing: 0) { |
| 232 | 235 | TextField("Run command", text: $query) |
| 233 | 236 | .textFieldStyle(.plain) |
| 234 | 237 | .font(.title3) |
| 235 | 238 | .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 } | |
| 237 | 242 | 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 | } | |
| 247 | 255 | } |
| 256 | .contentShape(Rectangle()) | |
| 248 | 257 | } |
| 258 | .buttonStyle(.plain) | |
| 259 | .selectedRow(index == current) | |
| 249 | 260 | } |
| 250 | .buttonStyle(.plain) | |
| 261 | .onChange(of: current) { if current >= 0 { proxy.scrollTo(current) } } | |
| 251 | 262 | } |
| 252 | 263 | } |
| 253 | 264 | .frame(width: 520, height: 360) |
Sources/Orgstar/SearchViews.swift +24 −10 · view
| @@ -51,14 +51,7 @@ struct QuickOpenView: View { | ||
| 51 | 51 | .font(.title3) |
| 52 | 52 | .padding(12) |
| 53 | 53 | .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) | |
| 62 | 55 | .onChange(of: query) { selected = 0 } |
| 63 | 56 | Divider() |
| 64 | 57 | ScrollViewReader { proxy in |
| @@ -75,8 +68,7 @@ struct QuickOpenView: View { | ||
| 75 | 68 | .contentShape(Rectangle()) |
| 76 | 69 | } |
| 77 | 70 | .buttonStyle(.plain) |
| 78 | .listRowBackground(index == current ? Color.accentColor.opacity(0.25) : Color.clear) | |
| 79 | .accessibilityAddTraits(index == current ? .isSelected : []) | |
| 71 | .selectedRow(index == current) | |
| 80 | 72 | } |
| 81 | 73 | .onChange(of: current) { if current >= 0 { proxy.scrollTo(current) } } |
| 82 | 74 | } |
| @@ -85,3 +77,25 @@ struct QuickOpenView: View { | ||
| 85 | 77 | .onExitCommand { dismiss() } |
| 86 | 78 | } |
| 87 | 79 | } |
| 80 | ||
| 81 | extension 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 | ||
| 94 | 94 | - =M-x= in the Emacs and Doom presets (=execute-extended-command=), |
| 95 | 95 | - =SPC := in Doom normal state. |
| 96 | 96 | |
| 97 | Type 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. | |
| 97 | Type 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. | |
| 98 | 98 | |
| 99 | 99 | The 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. |
| 100 | 100 | |
| @@ -955,7 +955,7 @@ When a key appears in several rows, it runs the command whose condition holds at | ||
| 955 | 955 | | 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=). | |
| 956 | 956 | | Previous Table Field (=org.table.previous-field=) | =S-TAB= | =⇧⇥= | =S-TAB= (I) | In a table, moves to the previous field (=org-table-previous-field=). | |
| 957 | 957 | | 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. | | |
| 959 | 959 | | Move Table Row Up (=org.table.row-up=) | =M-<up>= | =⌃⌘↑= | =M-k= | In a table, moves the row up (=org-table-move-row-up=). | |
| 960 | 960 | | Move Table Row Down (=org.table.row-down=) | =M-<down>= | =⌃⌘↓= | =M-j= | In a table, moves the row down (=org-table-move-row-down=). | |
| 961 | 961 | | 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 | ||
| 993 | 993 | |
| 994 | 994 | | Command | Emacs | Mac | Doom | What it does | |
| 995 | 995 | |-+-+-+-+-| |
| 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. | | |
| 997 | 997 | | 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. | |
| 998 | 998 | | 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=). | |
| 999 | 999 | | 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 @@ | ||
| 2332 | 2332 | } |
| 2333 | 2333 | } |
| 2334 | 2334 | }, |
| 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 | }, | |
| 2370 | 2335 | "Actions": { |
| 2371 | 2336 | "localizations": { |
| 2372 | 2337 | "de": { |
| @@ -35207,6 +35172,41 @@ | ||
| 35207 | 35172 | } |
| 35208 | 35173 | } |
| 35209 | 35174 | }, |
| 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 | }, | |
| 35210 | 35210 | "Use Copy": { |
| 35211 | 35211 | "localizations": { |
| 35212 | 35212 | "de": { |