Commit 5ad20764b1
Verified · cmc
Changed files (8)
- Sources/Orgstar/AgendaView+Actions.swift +11 −19
- Sources/Orgstar/AgendaView+Toolbar.swift +7 −10
- Sources/Orgstar/AgendaView.swift +13 −67
- Sources/Orgstar/BoardView.swift +8 −6
- Sources/Orgstar/ColumnViewSheet.swift +12 −22
- Sources/Orgstar/Keys.swift +32 −9
- docs/manual/guide/02-the-editor.org +2
- docs/manual/guide/07-agenda.org +4 −4
Sources/Orgstar/AgendaView+Actions.swift +11 −19 · view
| @@ -153,8 +153,8 @@ extension AgendaView { | ||
| 153 | 153 | tick += 1 |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | /// Refiles the selected entry, or with `marked` the marked ones, to a target asked for in | |
| 157 | /// the main window, where the list of targets is searchable. | |
| 156 | /// Refiles the selected entry, or with `marked` the marked ones, to a target chosen from a | |
| 157 | /// searchable list. | |
| 158 | 158 | private func refile(marked bulk: Bool) { |
| 159 | 159 | let entries = bulk ? marked : selectedEntry.map { [$0] } ?? [] |
| 160 | 160 | guard !entries.isEmpty else { |
| @@ -162,8 +162,8 @@ extension AgendaView { | ||
| 162 | 162 | return |
| 163 | 163 | } |
| 164 | 164 | let targets = workspace.refileTargets(openPath: session.path, document: session.document) |
| 165 | commands.ask(Prompt(key: "refile", message: "Refile to:", choices: targets.map(\.label))) { answer in | |
| 166 | guard let answer, targets.contains(where: { $0.label == answer }) else { return } | |
| 165 | ask(Prompt(key: "refile", message: "Refile to:", choices: targets.map(\.label))) { answer in | |
| 166 | guard targets.contains(where: { $0.label == answer }) else { return } | |
| 167 | 167 | message = eachEntry(entries) { entry, offset in |
| 168 | 168 | // Targets in the entry's own file from its text now, as earlier moves shift them. |
| 169 | 169 | let document = session.openDocuments.first { $0.path == entry.path }?.document |
| @@ -176,7 +176,6 @@ extension AgendaView { | ||
| 176 | 176 | if bulk { marked = [] } |
| 177 | 177 | tick += 1 |
| 178 | 178 | } |
| 179 | openWindow(id: "main") | |
| 180 | 179 | } |
| 181 | 180 | |
| 182 | 181 | /// Runs `action` on each entry, finding it again first: later entries in a file first, so |
| @@ -213,25 +212,25 @@ extension AgendaView { | ||
| 213 | 212 | message = "No entries are marked" |
| 214 | 213 | return |
| 215 | 214 | } |
| 216 | textPrompt = TextPrompt(title: "Bulk action on \(marked.count): [$] archive [r] refile [t] TODO state [+] tag [-] untag [s] schedule [d] deadline") { answer in | |
| 215 | ask(Prompt(key: "action", message: "Bulk action on \(marked.count): [$] archive [r] refile [t] TODO state [+] tag [-] untag [s] schedule [d] deadline")) { answer in | |
| 217 | 216 | switch answer.trimmingCharacters(in: .whitespaces) { |
| 218 | 217 | case "$": bulk { session.archive(from: ($0.path, $1)) } |
| 219 | 218 | case "r": refile(marked: true) |
| 220 | 219 | case "t": |
| 221 | textPrompt = TextPrompt(title: "TODO state (empty for none):") { keyword in | |
| 220 | ask(Prompt(key: "todo", message: "TODO state (empty for none):")) { keyword in | |
| 222 | 221 | let word = keyword.trimmingCharacters(in: .whitespaces) |
| 223 | 222 | bulk { performAt($0, $1, SetTodo(keyword: word.isEmpty ? nil : word)) } |
| 224 | 223 | } |
| 225 | 224 | case "+", "-": |
| 226 | 225 | let on = answer.trimmingCharacters(in: .whitespaces) == "+" |
| 227 | textPrompt = TextPrompt(title: on ? "Tag to add:" : "Tag to remove:") { tag in | |
| 226 | ask(Prompt(key: "tag", message: on ? "Tag to add:" : "Tag to remove:")) { tag in | |
| 228 | 227 | let tag = tag.trimmingCharacters(in: .whitespaces) |
| 229 | 228 | guard !tag.isEmpty else { return } |
| 230 | 229 | bulk { performAt($0, $1, ToggleTag(tag: tag, on: on)) } |
| 231 | 230 | } |
| 232 | 231 | case "s", "d": |
| 233 | 232 | let deadline = answer.trimmingCharacters(in: .whitespaces) == "d" |
| 234 | textPrompt = TextPrompt(title: deadline ? "Deadline (+2d, fri, 2026-10-12):" : "Schedule (+2d, fri, 2026-10-12):") { date in | |
| 233 | ask(Prompt(key: "date", message: deadline ? "Deadline (+2d, fri, 2026-10-12):" : "Schedule (+2d, fri, 2026-10-12):")) { date in | |
| 235 | 234 | bulk { performAt($0, $1, SetPlanning(deadline: deadline), answers: ["date": date]) } |
| 236 | 235 | } |
| 237 | 236 | default: |
| @@ -270,8 +269,9 @@ extension AgendaView { | ||
| 270 | 269 | let step = session.perform(command, path: path, at: offset, expect: item.headingLine.map { (start, $0) }, answers: answers) |
| 271 | 270 | switch step { |
| 272 | 271 | case .prompt(let request): |
| 273 | promptText = request.initial | |
| 274 | prompt = PendingPrompt(prompt: request, command: command, atMarker: atMarker, answers: answers, itemID: id) | |
| 272 | ask(request) { answer in | |
| 273 | run(command, atMarker: atMarker, answers: answers.merging([request.key: answer]) { $1 }, itemID: id) | |
| 274 | } | |
| 275 | 275 | case .failed(let text): |
| 276 | 276 | message = text |
| 277 | 277 | tick += 1 |
| @@ -282,12 +282,4 @@ extension AgendaView { | ||
| 282 | 282 | tick += 1 |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | ||
| 286 | func answerPrompt() { | |
| 287 | guard let pending = prompt else { return } | |
| 288 | prompt = nil | |
| 289 | var answers = pending.answers | |
| 290 | answers[pending.prompt.key] = promptText | |
| 291 | run(pending.command, atMarker: pending.atMarker, answers: answers, itemID: pending.itemID) | |
| 292 | } | |
| 293 | 285 | } |
Sources/Orgstar/AgendaView+Toolbar.swift +7 −10 · view
| @@ -238,7 +238,7 @@ extension AgendaView { | ||
| 238 | 238 | /// that view. |
| 239 | 239 | func saveView() { |
| 240 | 240 | let mode = agenda.mode |
| 241 | textPrompt = TextPrompt(title: String(localized: "Name for this view:")) { name in | |
| 241 | ask(Prompt(key: "name", message: String(localized: "Name for this view:"))) { name in | |
| 242 | 242 | do { |
| 243 | 243 | try AgendaViewLoader.save(name: name, mode: mode) |
| 244 | 244 | loadViews() |
| @@ -298,23 +298,20 @@ extension AgendaView { | ||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | func askFilter(_ kind: Character) { |
| 301 | switch kind { | |
| 302 | case "/": filterText = filter.description | |
| 303 | default: filterText = "" | |
| 304 | } | |
| 305 | 301 | let title = switch kind { |
| 306 | 302 | case "/": "Filter [+cat-tag<0:10-/regexp/]:" |
| 307 | 303 | case "\\": "Tag filter (+tag-tag):" |
| 308 | 304 | case "=": "Regexp filter (-re to drop):" |
| 309 | 305 | default: "Effort filter (<0:30, >1:00, =1:00):" |
| 310 | 306 | } |
| 311 | filterPrompt = (title, kind) | |
| 307 | let tags = kind == "/" || kind == "\\" ? shown.tags.sorted() : [] | |
| 308 | ask(Prompt(key: "filter", message: title, initial: kind == "/" ? filter.description : "", choices: tags, requireMatch: false)) { text in | |
| 309 | applyFilter(kind, text) | |
| 310 | } | |
| 312 | 311 | } |
| 313 | 312 | |
| 314 | func applyFilter() { | |
| 315 | guard let kind = filterPrompt?.kind else { return } | |
| 316 | filterPrompt = nil | |
| 317 | let text = filterText.trimmingCharacters(in: .whitespaces) | |
| 313 | func applyFilter(_ kind: Character, _ answer: String) { | |
| 314 | let text = answer.trimmingCharacters(in: .whitespaces) | |
| 318 | 315 | var current = filter |
| 319 | 316 | switch kind { |
| 320 | 317 | case "/": |
Sources/Orgstar/AgendaView.swift +13 −67 · view
| @@ -44,25 +44,15 @@ struct AgendaView: View { | ||
| 44 | 44 | /// The view picker moved to the agenda for a followed timestamp, which sets its own days. |
| 45 | 45 | @State var keepRequestedDays = false |
| 46 | 46 | @State var message: String? |
| 47 | @State var prompt: PendingPrompt? | |
| 47 | /// A question for an agenda action, at the window's foot. | |
| 48 | @State var prompt: PromptRequest? | |
| 48 | 49 | /// An event being changed, or an entry being added to a calendar. |
| 49 | 50 | @State private var eventRequest: EventRequest? |
| 50 | @State var promptText = "" | |
| 51 | 51 | @State var prefix: String? |
| 52 | 52 | /// Entries marked for a bulk action. |
| 53 | 53 | @State var marked: [EntryRef] = [] |
| 54 | 54 | @State var logMode = false |
| 55 | 55 | @State var filter = AgendaFilter() |
| 56 | /// A filter question: its title and which filter it sets. | |
| 57 | @State var filterPrompt: (title: String, kind: Character)? | |
| 58 | @State var filterText = "" | |
| 59 | /// A one-line question for an agenda action, and what to do with the answer. | |
| 60 | struct TextPrompt { | |
| 61 | let title: String | |
| 62 | let apply: (String) -> Void | |
| 63 | } | |
| 64 | @State var textPrompt: TextPrompt? | |
| 65 | @State private var textAnswer = "" | |
| 66 | 56 | /// Day, week or month chosen with `v`; nil shows the span the settings or the view give. |
| 67 | 57 | @State var spanKind: AgendaSpan? |
| 68 | 58 | @State var showingDatePicker = false |
| @@ -126,15 +116,6 @@ struct AgendaView: View { | ||
| 126 | 116 | } |
| 127 | 117 | } |
| 128 | 118 | |
| 129 | struct PendingPrompt: Identifiable { | |
| 130 | let id = UUID() | |
| 131 | let prompt: Prompt | |
| 132 | let command: any OrgCommand | |
| 133 | let atMarker: Bool | |
| 134 | let answers: [String: String] | |
| 135 | let itemID: String | |
| 136 | } | |
| 137 | ||
| 138 | 119 | private struct RefreshKey: Hashable { |
| 139 | 120 | var mode: AgendaMode |
| 140 | 121 | var start: Int? |
| @@ -288,6 +269,14 @@ struct AgendaView: View { | ||
| 288 | 269 | |
| 289 | 270 | func line(_ id: String) -> Line? { lines(groups).first { $0.id == id } } |
| 290 | 271 | |
| 272 | /// Asks `prompt` at the window's foot; `apply` gets the answer unless it is cancelled. | |
| 273 | func ask(_ prompt: Prompt, apply: @escaping (String) -> Void) { | |
| 274 | self.prompt = PromptRequest(prompt: prompt) { answer in | |
| 275 | focused = true | |
| 276 | if let answer { apply(answer) } | |
| 277 | } | |
| 278 | } | |
| 279 | ||
| 291 | 280 | var body: some View { |
| 292 | 281 | let groups = self.groups |
| 293 | 282 | _ = tick |
| @@ -345,7 +334,9 @@ struct AgendaView: View { | ||
| 345 | 334 | .onAppear { focused = true } |
| 346 | 335 | .onKeyPress(phases: .down) { press in handle(press) } |
| 347 | 336 | .safeAreaInset(edge: .bottom, spacing: 0) { |
| 348 | if let message = message ?? (filter.isEmpty ? reminderStatus : "Filter: " + filter.description) { | |
| 337 | if prompt != nil { | |
| 338 | PromptBar(request: $prompt) | |
| 339 | } else if let message = message ?? (filter.isEmpty ? reminderStatus : "Filter: " + filter.description) { | |
| 349 | 340 | Text(message) |
| 350 | 341 | .font(.callout) |
| 351 | 342 | .frame(maxWidth: .infinity, alignment: .leading) |
| @@ -376,51 +367,6 @@ struct AgendaView: View { | ||
| 376 | 367 | } |
| 377 | 368 | } |
| 378 | 369 | } |
| 379 | .sheet(item: Binding(get: { prompt?.prompt.fast == nil ? nil : prompt }, set: { if $0 == nil { prompt = nil } })) { pending in | |
| 380 | if let fast = pending.prompt.fast { | |
| 381 | FastSelectionView(selection: fast, message: pending.prompt.message) { answer in | |
| 382 | prompt = nil | |
| 383 | guard let answer else { return } | |
| 384 | promptText = answer | |
| 385 | prompt = pending | |
| 386 | answerPrompt() | |
| 387 | } | |
| 388 | .frame(minWidth: 420) | |
| 389 | } | |
| 390 | } | |
| 391 | .alert(prompt?.prompt.message ?? "", isPresented: Binding(get: { prompt != nil && prompt?.prompt.fast == nil }, set: { if !$0 { prompt = nil } })) { | |
| 392 | TextField("", text: $promptText) | |
| 393 | Button("OK") { answerPrompt() } | |
| 394 | Button("Cancel", role: .cancel) { prompt = nil } | |
| 395 | } message: { | |
| 396 | if let choices = prompt?.prompt.choices, !choices.isEmpty { | |
| 397 | Text(choices.prefix(12).joined(separator: " ")) | |
| 398 | } | |
| 399 | } | |
| 400 | .alert(filterPrompt?.title ?? "", isPresented: Binding(get: { filterPrompt != nil }, set: { if !$0 { filterPrompt = nil } })) { | |
| 401 | TextField("", text: $filterText) | |
| 402 | Button("Filter") { applyFilter() } | |
| 403 | Button("Cancel", role: .cancel) { filterPrompt = nil } | |
| 404 | } message: { | |
| 405 | if filterPrompt?.kind == "/" || filterPrompt?.kind == "\\" { | |
| 406 | Text(shown.tags.sorted().prefix(20).joined(separator: " ")) | |
| 407 | } | |
| 408 | } | |
| 409 | .alert(textPrompt?.title ?? "", isPresented: Binding(get: { textPrompt != nil }, set: { if !$0 { textPrompt = nil } })) { | |
| 410 | TextField("", text: $textAnswer) | |
| 411 | Button("OK") { | |
| 412 | let pending = textPrompt | |
| 413 | let answer = textAnswer | |
| 414 | textPrompt = nil | |
| 415 | textAnswer = "" | |
| 416 | // A follow-up question opens after this alert closes. | |
| 417 | DispatchQueue.main.async { pending?.apply(answer) } | |
| 418 | } | |
| 419 | Button("Cancel", role: .cancel) { | |
| 420 | textPrompt = nil | |
| 421 | textAnswer = "" | |
| 422 | } | |
| 423 | } | |
| 424 | 370 | .navigationTitle(title) |
| 425 | 371 | .navigationSubtitle(([isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : ""] + [shownFolders ?? ""]).filter { !$0.isEmpty }.joined(separator: " · ")) |
| 426 | 372 | .onChange(of: viewName) { applyView() } |
Sources/Orgstar/BoardView.swift +8 −6 · view
| @@ -17,6 +17,8 @@ struct BoardView: View { | ||
| 17 | 17 | @State private var selection: Set<String> = [] |
| 18 | 18 | @State private var sortOrder = [KeyPathComparator(\BoardRow.todoOrder), KeyPathComparator(\BoardRow.title)] |
| 19 | 19 | @State private var message: String? |
| 20 | /// A question an edit asks (a state note, a property). | |
| 21 | @State private var prompt: PromptRequest? | |
| 20 | 22 | @State private var tick = 0 |
| 21 | 23 | /// Whether the first load has finished, so an empty board says so. |
| 22 | 24 | @State private var loaded = false |
| @@ -70,7 +72,9 @@ struct BoardView: View { | ||
| 70 | 72 | } |
| 71 | 73 | } |
| 72 | 74 | .safeAreaInset(edge: .bottom, spacing: 0) { |
| 73 | if let message { | |
| 75 | if prompt != nil { | |
| 76 | PromptBar(request: $prompt) | |
| 77 | } else if let message { | |
| 74 | 78 | Text(message).font(.callout).frame(maxWidth: .infinity, alignment: .leading).padding(.horizontal, 12).padding(.vertical, 6).background(.bar) |
| 75 | 79 | } |
| 76 | 80 | } |
| @@ -287,12 +291,11 @@ struct BoardView: View { | ||
| 287 | 291 | switch session.perform(command, path: entry.path, at: entry.headingOffset, expect: (entry.headingOffset, entry.headingLine), answers: answers) { |
| 288 | 292 | case .failed(let text): message = text |
| 289 | 293 | case .prompt(let prompt): |
| 290 | // A state note: asked in the main window's echo area. | |
| 291 | commands.ask(prompt) { answer in | |
| 294 | // A state note. | |
| 295 | self.prompt = PromptRequest(prompt: prompt) { answer in | |
| 292 | 296 | guard let answer else { return } |
| 293 | 297 | perform(command, on: entry, answers: answers.merging([prompt.key: answer]) { $1 }) |
| 294 | 298 | } |
| 295 | openWindow(id: "main") | |
| 296 | 299 | default: message = nil |
| 297 | 300 | } |
| 298 | 301 | tick += 1 |
| @@ -303,13 +306,12 @@ struct BoardView: View { | ||
| 303 | 306 | } |
| 304 | 307 | |
| 305 | 308 | private func askProperty(_ entry: BoardEntry) { |
| 306 | commands.ask(Prompt(key: "property", message: "Property (NAME value):")) { answer in | |
| 309 | prompt = PromptRequest(prompt: Prompt(key: "property", message: "Property (NAME value):")) { answer in | |
| 307 | 310 | guard let answer, let space = answer.firstIndex(of: " ") else { return } |
| 308 | 311 | let key = String(answer[..<space]) |
| 309 | 312 | let value = String(answer[answer.index(after: space)...]).trimmingCharacters(in: .whitespaces) |
| 310 | 313 | perform(SetProperty(key: key, value: value), on: entry) |
| 311 | 314 | } |
| 312 | openWindow(id: "main") | |
| 313 | 315 | } |
| 314 | 316 | |
| 315 | 317 | private func jump(_ entry: BoardEntry) { |
Sources/Orgstar/ColumnViewSheet.swift +12 −22 · view
| @@ -17,9 +17,8 @@ struct ColumnViewSheet: View { | ||
| 17 | 17 | @State private var editing: (row: Int, column: Int)? |
| 18 | 18 | @State private var draft = "" |
| 19 | 19 | @State private var message: String? |
| 20 | /// A question the edit asks (a state note), with the command to run again. | |
| 21 | @State private var pending: (prompt: Prompt, command: any OrgCommand, start: Int, answers: [String: String])? | |
| 22 | @State private var reply = "" | |
| 20 | /// A question the edit asks (a state note). | |
| 21 | @State private var prompt: PromptRequest? | |
| 23 | 22 | @FocusState private var focused: Bool |
| 24 | 23 | |
| 25 | 24 | var body: some View { |
| @@ -43,14 +42,7 @@ struct ColumnViewSheet: View { | ||
| 43 | 42 | .padding(10) |
| 44 | 43 | } |
| 45 | 44 | .defaultScrollAnchor(.topLeading) |
| 46 | if let pending { | |
| 47 | HStack { | |
| 48 | Text(pending.prompt.message) | |
| 49 | TextField("", text: $reply).onSubmit(answerPending) | |
| 50 | Button("OK", action: answerPending) | |
| 51 | } | |
| 52 | .padding(8) | |
| 53 | } | |
| 45 | PromptBar(request: $prompt) | |
| 54 | 46 | if let message { |
| 55 | 47 | Text(message).font(.callout).foregroundStyle(.secondary).padding(8) |
| 56 | 48 | } |
| @@ -120,7 +112,7 @@ struct ColumnViewSheet: View { | ||
| 120 | 112 | } |
| 121 | 113 | |
| 122 | 114 | private func key(_ press: KeyPress) -> KeyPress.Result { |
| 123 | guard editing == nil, pending == nil else { return .ignored } | |
| 115 | guard editing == nil, prompt == nil else { return .ignored } | |
| 124 | 116 | guard let current = selected else { |
| 125 | 117 | if [.downArrow, .upArrow, .leftArrow, .rightArrow].contains(press.key), !view.rows.isEmpty { |
| 126 | 118 | selected = (0, 0) |
| @@ -174,22 +166,20 @@ struct ColumnViewSheet: View { | ||
| 174 | 166 | refresh() |
| 175 | 167 | case .failed(let text): |
| 176 | 168 | message = text |
| 177 | case .prompt(let prompt): | |
| 178 | reply = prompt.initial ?? "" | |
| 179 | pending = (prompt, command, start, answers) | |
| 169 | case .prompt(let question): | |
| 170 | prompt = PromptRequest(prompt: question) { reply in | |
| 171 | focused = true | |
| 172 | guard let reply else { return } | |
| 173 | let answers = answers.merging([question.key: reply]) { $1 } | |
| 174 | handle(run(command, start, answers), command: command, start: start, answers: answers) | |
| 175 | } | |
| 176 | return | |
| 180 | 177 | default: |
| 181 | 178 | message = String(localized: "\(CommandTitle.localized(command.title)) can't run here", comment: "A command that doesn't apply in column view") |
| 182 | 179 | } |
| 183 | 180 | focused = true |
| 184 | 181 | } |
| 185 | 182 | |
| 186 | private func answerPending() { | |
| 187 | guard let pending else { return } | |
| 188 | self.pending = nil | |
| 189 | let answers = pending.answers.merging([pending.prompt.key: reply]) { $1 } | |
| 190 | handle(run(pending.command, pending.start, answers), command: pending.command, start: pending.start, answers: answers) | |
| 191 | } | |
| 192 | ||
| 193 | 183 | /// The view again, over the same entries, keeping the selected cell. |
| 194 | 184 | private func refresh() { |
| 195 | 185 | guard let document = document(), let new = try? ColumnView.refresh(view, text: document.text, tree: document.tree) else { return } |
Sources/Orgstar/Keys.swift +32 −9 · view
| @@ -33,7 +33,7 @@ struct EchoArea: View { | ||
| 33 | 33 | .padding(10) |
| 34 | 34 | } |
| 35 | 35 | if let request = commands.prompt { |
| 36 | PromptView(commands: commands, request: request) | |
| 36 | PromptView(request: request, reply: commands.answer) | |
| 37 | 37 | .id(request.id) |
| 38 | 38 | } else if let text = commands.pendingKeys.map({ $0 + "-" }) ?? commands.message { |
| 39 | 39 | Text(text) |
| @@ -114,10 +114,12 @@ struct StateTag: View { | ||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /// A question a command asks: fast selection, or a text field with its choices, filtered as |
| 117 | /// it is typed, and a calendar for dates. Any window with an echo area can show it. | |
| 117 | /// it is typed, and a calendar for dates. The echo area shows it, and `PromptBar` in windows | |
| 118 | /// without one. | |
| 118 | 119 | struct PromptView: View { |
| 119 | let commands: AppCommands | |
| 120 | 120 | let request: PromptRequest |
| 121 | /// Ends the prompt with an answer, or nil to cancel. | |
| 122 | let reply: (String?) -> Void | |
| 121 | 123 | @State private var answer = "" |
| 122 | 124 | @FocusState private var answerFocused: Bool |
| 123 | 125 | /// The highlighted choice, moved by ↑/↓ or C-p/C-n. |
| @@ -130,7 +132,7 @@ struct PromptView: View { | ||
| 130 | 132 | var body: some View { |
| 131 | 133 | if let fast = prompt.fast { |
| 132 | 134 | Divider() |
| 133 | FastSelectionView(selection: fast, message: prompt.message) { commands.answer($0) } | |
| 135 | FastSelectionView(selection: fast, message: prompt.message) { reply($0) } | |
| 134 | 136 | } else { |
| 135 | 137 | let matches = filteredChoices(prompt.choices) |
| 136 | 138 | let current = min(selected, matches.count - 1) |
| @@ -142,7 +144,7 @@ struct PromptView: View { | ||
| 142 | 144 | ForEach(matches.indices, id: \.self) { index in |
| 143 | 145 | let choice = matches[index] |
| 144 | 146 | Button { |
| 145 | if prompt.completionSeparator != nil { complete(choice) } else { commands.answer(choice) } | |
| 147 | if prompt.completionSeparator != nil { complete(choice) } else { reply(choice) } | |
| 146 | 148 | } label: { |
| 147 | 149 | Text(choice) |
| 148 | 150 | .frame(maxWidth: .infinity, alignment: .leading) |
| @@ -163,7 +165,7 @@ struct PromptView: View { | ||
| 163 | 165 | } |
| 164 | 166 | if let read = prompt.date { |
| 165 | 167 | Divider() |
| 166 | DatePickerView(answer: answer, read: read) { commands.answer($0) } | |
| 168 | DatePickerView(answer: answer, read: read) { reply($0) } | |
| 167 | 169 | } |
| 168 | 170 | Divider() |
| 169 | 171 | HStack(spacing: 6) { |
| @@ -177,9 +179,9 @@ struct PromptView: View { | ||
| 177 | 179 | .focused($answerFocused) |
| 178 | 180 | .onSubmit { |
| 179 | 181 | if current >= 0, moved || prompt.requireMatch { |
| 180 | commands.answer(matches[current]) | |
| 182 | reply(matches[current]) | |
| 181 | 183 | } else if prompt.choices.isEmpty || !prompt.requireMatch { |
| 182 | commands.answer(answer) | |
| 184 | reply(answer) | |
| 183 | 185 | } |
| 184 | 186 | } |
| 185 | 187 | .onKeyPress(.tab) { |
| @@ -194,7 +196,7 @@ struct PromptView: View { | ||
| 194 | 196 | answer = DatePickerView.shifted(answer, read, by: days) |
| 195 | 197 | return .handled |
| 196 | 198 | } |
| 197 | .onExitCommand { commands.answer(nil) } | |
| 199 | .onExitCommand { reply(nil) } | |
| 198 | 200 | .onChange(of: answer) { |
| 199 | 201 | selected = 0 |
| 200 | 202 | moved = false |
| @@ -241,6 +243,27 @@ struct PromptView: View { | ||
| 241 | 243 | } |
| 242 | 244 | } |
| 243 | 245 | |
| 246 | /// A window's own question at its foot, styled as the echo area, for windows without one. | |
| 247 | struct PromptBar: View { | |
| 248 | @Binding var request: PromptRequest? | |
| 249 | @Environment(\.orgTheme) private var theme | |
| 250 | @Environment(\.colorScheme) private var colorScheme | |
| 251 | ||
| 252 | var body: some View { | |
| 253 | if let current = request { | |
| 254 | VStack(alignment: .leading, spacing: 0) { | |
| 255 | PromptView(request: current) { text in | |
| 256 | request = nil | |
| 257 | current.reply(text) | |
| 258 | } | |
| 259 | .id(current.id) | |
| 260 | } | |
| 261 | .foregroundStyle(theme.color("modeline-foreground") ?? .primary) | |
| 262 | .background { if let bg = theme.color("modeline-background", in: colorScheme) { bg } else { Rectangle().fill(.bar) } } | |
| 263 | } | |
| 264 | } | |
| 265 | } | |
| 266 | ||
| 244 | 267 | /// Messages: the echo area's recent messages, newest last (`view-echo-area-messages`). |
| 245 | 268 | struct MessagesView: View { |
| 246 | 269 | let messages: [String] |
docs/manual/guide/02-the-editor.org +2 · view
| @@ -228,6 +228,8 @@ Date prompts also show a date picker, and =S-<left>=, =S-<right>=, =S-<up>= and | ||
| 228 | 228 | |
| 229 | 229 | When a prompt closes, the keyboard goes back to the editor. |
| 230 | 230 | |
| 231 | The Agenda and Board windows and the column view sheet ask their questions in the same prompt, at the bottom of the window or sheet. | |
| 232 | ||
| 231 | 233 | * Completion |
| 232 | 234 | |
| 233 | 235 | Complete at Point (=completion-at-point=) completes the word before the caret from what Org knows at that position. |
docs/manual/guide/07-agenda.org +4 −4 · view
| @@ -650,7 +650,7 @@ Right-click a line for Open, Cycle TODO State, Set Priority…, Set Tags…, Sch | ||
| 650 | 650 | |
| 651 | 651 | =t= follows =org-todo=: with fast-selection keys in your TODO keywords it asks for the state, otherwise it cycles (see [[file:05-todos-and-tags.org][TODOs and tags]]). Questions an action needs, such as a date for =C-c C-s= or a note on a state change, appear in the agenda window. Dates take the same input as in the editor (see [[file:06-dates-and-clocking.org][Dates, scheduling and clocking]]). =S-<right>= and =S-<left>= work only on deadline, scheduled and timestamp lines; they change the timestamp the line comes from. |
| 652 | 652 | |
| 653 | =C-c C-w= brings the main window forward and asks for the target there, where the target list is searchable. | |
| 653 | =C-c C-w= asks for the target at the bottom of the agenda window, where the target list is searchable. | |
| 654 | 654 | |
| 655 | 655 | =I= clocks in as Clock In does, so with no clock running it first asks about open clocks, in the main window's echo area. See [[file:06-dates-and-clocking.org][Dates, scheduling and clocking]]. |
| 656 | 656 | |
| @@ -665,7 +665,7 @@ Each action finds the entry again by its heading line before it changes anything | ||
| 665 | 665 | | =U= | Unmarks everything | =org-agenda-bulk-unmark-all= | |
| 666 | 666 | | =B= | Asks for an action on every marked entry | =org-agenda-bulk-action= | |
| 667 | 667 | |
| 668 | =B= offers =$= archive, =r= refile, =t= set a TODO state (typed; empty for none), =+= add a tag, =-= remove a tag, =s= schedule and =d= set a deadline. Type the letter and press OK. Entries that changed since they were marked are skipped and counted in the status line. An action that needs a further answer per entry, such as a state-change note, is not run in bulk; the status line tells you to run it on the entry. | |
| 668 | =B= offers =$= archive, =r= refile, =t= set a TODO state (typed; empty for none), =+= add a tag, =-= remove a tag, =s= schedule and =d= set a deadline. Type the letter and press =Return=. Entries that changed since they were marked are skipped and counted in the status line. An action that needs a further answer per entry, such as a state-change note, is not run in bulk; the status line tells you to run it on the entry. | |
| 669 | 669 | |
| 670 | 670 | On iOS, tap Select in the bar at the bottom, or Select in an entry's menu, then tap entries to mark them. The bar then shows how many are selected, Actions and Done. Actions offers the same actions: TODO State…, Add Tag…, Remove Tag…, Schedule…, Deadline…, Refile… and Archive…, which asks first. After an action, or Done, the selection ends. |
| 671 | 671 | |
| @@ -698,11 +698,11 @@ These three choices are remembered by the app; they are not in =config.toml=. | ||
| 698 | 698 | |
| 699 | 699 | ** Table |
| 700 | 700 | |
| 701 | Columns: TODO, priority, title, tags, scheduled, deadline, your property columns, and the file. Click a column header to sort (the property columns don't sort). The TODO column sorts by the keyword's order in your sequences. The context menu on a row offers Set TODO (a keyword or None), Set Property… (asked in the main window as =NAME value=) and Open. Double-click a row to open the entry. | |
| 701 | Columns: TODO, priority, title, tags, scheduled, deadline, your property columns, and the file. Click a column header to sort (the property columns don't sort). The TODO column sorts by the keyword's order in your sequences. The context menu on a row offers Set TODO (a keyword or None), Set Property… (asked at the bottom of the board as =NAME value=) and Open. Double-click a row to open the entry. | |
| 702 | 702 | |
| 703 | 703 | ** Kanban |
| 704 | 704 | |
| 705 | Each TODO keyword your files use gets a column, in sequence order, done keywords included. Column headings take the keyword colours of the agenda and editor (see [[file:13-configuration.org][Configuration]]). A card shows the priority and title, the category and tags, and the deadline or the scheduled date, in the theme's agenda colours: a past deadline in =agenda-overdue=, one due today or later in =agenda-due-soon=. Drag a card to another column to set that keyword; this is the same edit as changing the state in the editor, so logging and state-change notes apply (a note is asked for in the main window). Double-click a card to open its entry. With VoiceOver, each card has a Move to … action for each other column. | |
| 705 | Each TODO keyword your files use gets a column, in sequence order, done keywords included. Column headings take the keyword colours of the agenda and editor (see [[file:13-configuration.org][Configuration]]). A card shows the priority and title, the category and tags, and the deadline or the scheduled date, in the theme's agenda colours: a past deadline in =agenda-overdue=, one due today or later in =agenda-due-soon=. Drag a card to another column to set that keyword; this is the same edit as changing the state in the editor, so logging and state-change notes apply (a note is asked for at the bottom of the board). Double-click a card to open its entry. With VoiceOver, each card has a Move to … action for each other column. | |
| 706 | 706 | |
| 707 | 707 | From the keyboard, click a card or press an arrow key to select one. The arrow keys move between cards, =Return= opens the selected card's entry, and =⇧←= and =⇧→= move it to the column before or after, as dragging does. |
| 708 | 708 | |