Commit 5ad20764b1

5ad20764b1e8539fa66424a9dcc16abf95b34cf1

parent: 25119f4b2f

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-25 23:36 UTC

Mac: the echo area's prompt in the agenda, board and column view

PromptView takes a reply closure, and PromptBar shows it at the foot of a window without an echo area. The agenda's questions (command prompts, fast selection, filters, bulk actions, view names, refile) replace its alerts and sheet, the board asks for state notes and properties in its own window instead of the main window's, and column view's inline row is gone.

Ref #222

Layout: unified · split

Changed files (8)
Sources/Orgstar/AgendaView+Actions.swift +11 −19 · view
@@ -153,8 +153,8 @@ extension AgendaView {
153 tick += 1 153 tick += 1
154 } 154 }
155 155
156 /// Refiles the selected entry, or with `marked` the marked ones, to a target asked for in 156 /// Refiles the selected entry, or with `marked` the marked ones, to a target chosen from a
157 /// the main window, where the list of targets is searchable. 157 /// searchable list.
158 private func refile(marked bulk: Bool) { 158 private func refile(marked bulk: Bool) {
159 let entries = bulk ? marked : selectedEntry.map { [$0] } ?? [] 159 let entries = bulk ? marked : selectedEntry.map { [$0] } ?? []
160 guard !entries.isEmpty else { 160 guard !entries.isEmpty else {
@@ -162,8 +162,8 @@ extension AgendaView {
162 return 162 return
163 } 163 }
164 let targets = workspace.refileTargets(openPath: session.path, document: session.document) 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 165 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 } 166 guard targets.contains(where: { $0.label == answer }) else { return }
167 message = eachEntry(entries) { entry, offset in 167 message = eachEntry(entries) { entry, offset in
168 // Targets in the entry's own file from its text now, as earlier moves shift them. 168 // Targets in the entry's own file from its text now, as earlier moves shift them.
169 let document = session.openDocuments.first { $0.path == entry.path }?.document 169 let document = session.openDocuments.first { $0.path == entry.path }?.document
@@ -176,7 +176,6 @@ extension AgendaView {
176 if bulk { marked = [] } 176 if bulk { marked = [] }
177 tick += 1 177 tick += 1
178 } 178 }
179 openWindow(id: "main")
180 } 179 }
181 180
182 /// Runs `action` on each entry, finding it again first: later entries in a file first, so 181 /// Runs `action` on each entry, finding it again first: later entries in a file first, so
@@ -213,25 +212,25 @@ extension AgendaView {
213 message = "No entries are marked" 212 message = "No entries are marked"
214 return 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 switch answer.trimmingCharacters(in: .whitespaces) { 216 switch answer.trimmingCharacters(in: .whitespaces) {
218 case "$": bulk { session.archive(from: ($0.path, $1)) } 217 case "$": bulk { session.archive(from: ($0.path, $1)) }
219 case "r": refile(marked: true) 218 case "r": refile(marked: true)
220 case "t": 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 let word = keyword.trimmingCharacters(in: .whitespaces) 221 let word = keyword.trimmingCharacters(in: .whitespaces)
223 bulk { performAt($0, $1, SetTodo(keyword: word.isEmpty ? nil : word)) } 222 bulk { performAt($0, $1, SetTodo(keyword: word.isEmpty ? nil : word)) }
224 } 223 }
225 case "+", "-": 224 case "+", "-":
226 let on = answer.trimmingCharacters(in: .whitespaces) == "+" 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 let tag = tag.trimmingCharacters(in: .whitespaces) 227 let tag = tag.trimmingCharacters(in: .whitespaces)
229 guard !tag.isEmpty else { return } 228 guard !tag.isEmpty else { return }
230 bulk { performAt($0, $1, ToggleTag(tag: tag, on: on)) } 229 bulk { performAt($0, $1, ToggleTag(tag: tag, on: on)) }
231 } 230 }
232 case "s", "d": 231 case "s", "d":
233 let deadline = answer.trimmingCharacters(in: .whitespaces) == "d" 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 bulk { performAt($0, $1, SetPlanning(deadline: deadline), answers: ["date": date]) } 234 bulk { performAt($0, $1, SetPlanning(deadline: deadline), answers: ["date": date]) }
236 } 235 }
237 default: 236 default:
@@ -270,8 +269,9 @@ extension AgendaView {
270 let step = session.perform(command, path: path, at: offset, expect: item.headingLine.map { (start, $0) }, answers: answers) 269 let step = session.perform(command, path: path, at: offset, expect: item.headingLine.map { (start, $0) }, answers: answers)
271 switch step { 270 switch step {
272 case .prompt(let request): 271 case .prompt(let request):
273 promptText = request.initial 272 ask(request) { answer in
274 prompt = PendingPrompt(prompt: request, command: command, atMarker: atMarker, answers: answers, itemID: id) 273 run(command, atMarker: atMarker, answers: answers.merging([request.key: answer]) { $1 }, itemID: id)
274 }
275 case .failed(let text): 275 case .failed(let text):
276 message = text 276 message = text
277 tick += 1 277 tick += 1
@@ -282,12 +282,4 @@ extension AgendaView {
282 tick += 1 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 /// that view. 238 /// that view.
239 func saveView() { 239 func saveView() {
240 let mode = agenda.mode 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 do { 242 do {
243 try AgendaViewLoader.save(name: name, mode: mode) 243 try AgendaViewLoader.save(name: name, mode: mode)
244 loadViews() 244 loadViews()
@@ -298,23 +298,20 @@ extension AgendaView {
298 } 298 }
299 299
300 func askFilter(_ kind: Character) { 300 func askFilter(_ kind: Character) {
301 switch kind {
302 case "/": filterText = filter.description
303 default: filterText = ""
304 }
305 let title = switch kind { 301 let title = switch kind {
306 case "/": "Filter [+cat-tag<0:10-/regexp/]:" 302 case "/": "Filter [+cat-tag<0:10-/regexp/]:"
307 case "\\": "Tag filter (+tag-tag):" 303 case "\\": "Tag filter (+tag-tag):"
308 case "=": "Regexp filter (-re to drop):" 304 case "=": "Regexp filter (-re to drop):"
309 default: "Effort filter (<0:30, >1:00, =1:00):" 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() { 313 func applyFilter(_ kind: Character, _ answer: String) {
315 guard let kind = filterPrompt?.kind else { return } 314 let text = answer.trimmingCharacters(in: .whitespaces)
316 filterPrompt = nil
317 let text = filterText.trimmingCharacters(in: .whitespaces)
318 var current = filter 315 var current = filter
319 switch kind { 316 switch kind {
320 case "/": 317 case "/":
Sources/Orgstar/AgendaView.swift +13 −67 · view
@@ -44,25 +44,15 @@ struct AgendaView: View {
44 /// The view picker moved to the agenda for a followed timestamp, which sets its own days. 44 /// The view picker moved to the agenda for a followed timestamp, which sets its own days.
45 @State var keepRequestedDays = false 45 @State var keepRequestedDays = false
46 @State var message: String? 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 /// An event being changed, or an entry being added to a calendar. 49 /// An event being changed, or an entry being added to a calendar.
49 @State private var eventRequest: EventRequest? 50 @State private var eventRequest: EventRequest?
50 @State var promptText = ""
51 @State var prefix: String? 51 @State var prefix: String?
52 /// Entries marked for a bulk action. 52 /// Entries marked for a bulk action.
53 @State var marked: [EntryRef] = [] 53 @State var marked: [EntryRef] = []
54 @State var logMode = false 54 @State var logMode = false
55 @State var filter = AgendaFilter() 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 /// Day, week or month chosen with `v`; nil shows the span the settings or the view give. 56 /// Day, week or month chosen with `v`; nil shows the span the settings or the view give.
67 @State var spanKind: AgendaSpan? 57 @State var spanKind: AgendaSpan?
68 @State var showingDatePicker = false 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 private struct RefreshKey: Hashable { 119 private struct RefreshKey: Hashable {
139 var mode: AgendaMode 120 var mode: AgendaMode
140 var start: Int? 121 var start: Int?
@@ -288,6 +269,14 @@ struct AgendaView: View {
288 269
289 func line(_ id: String) -> Line? { lines(groups).first { $0.id == id } } 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 var body: some View { 280 var body: some View {
292 let groups = self.groups 281 let groups = self.groups
293 _ = tick 282 _ = tick
@@ -345,7 +334,9 @@ struct AgendaView: View {
345 .onAppear { focused = true } 334 .onAppear { focused = true }
346 .onKeyPress(phases: .down) { press in handle(press) } 335 .onKeyPress(phases: .down) { press in handle(press) }
347 .safeAreaInset(edge: .bottom, spacing: 0) { 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 Text(message) 340 Text(message)
350 .font(.callout) 341 .font(.callout)
351 .frame(maxWidth: .infinity, alignment: .leading) 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 .navigationTitle(title) 370 .navigationTitle(title)
425 .navigationSubtitle(([isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : ""] + [shownFolders ?? ""]).filter { !$0.isEmpty }.joined(separator: " · ")) 371 .navigationSubtitle(([isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : ""] + [shownFolders ?? ""]).filter { !$0.isEmpty }.joined(separator: " · "))
426 .onChange(of: viewName) { applyView() } 372 .onChange(of: viewName) { applyView() }
Sources/Orgstar/BoardView.swift +8 −6 · view
@@ -17,6 +17,8 @@ struct BoardView: View {
17 @State private var selection: Set<String> = [] 17 @State private var selection: Set<String> = []
18 @State private var sortOrder = [KeyPathComparator(\BoardRow.todoOrder), KeyPathComparator(\BoardRow.title)] 18 @State private var sortOrder = [KeyPathComparator(\BoardRow.todoOrder), KeyPathComparator(\BoardRow.title)]
19 @State private var message: String? 19 @State private var message: String?
20 /// A question an edit asks (a state note, a property).
21 @State private var prompt: PromptRequest?
20 @State private var tick = 0 22 @State private var tick = 0
21 /// Whether the first load has finished, so an empty board says so. 23 /// Whether the first load has finished, so an empty board says so.
22 @State private var loaded = false 24 @State private var loaded = false
@@ -70,7 +72,9 @@ struct BoardView: View {
70 } 72 }
71 } 73 }
72 .safeAreaInset(edge: .bottom, spacing: 0) { 74 .safeAreaInset(edge: .bottom, spacing: 0) {
73 if let message { 75 if prompt != nil {
76 PromptBar(request: $prompt)
77 } else if let message {
74 Text(message).font(.callout).frame(maxWidth: .infinity, alignment: .leading).padding(.horizontal, 12).padding(.vertical, 6).background(.bar) 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 switch session.perform(command, path: entry.path, at: entry.headingOffset, expect: (entry.headingOffset, entry.headingLine), answers: answers) { 291 switch session.perform(command, path: entry.path, at: entry.headingOffset, expect: (entry.headingOffset, entry.headingLine), answers: answers) {
288 case .failed(let text): message = text 292 case .failed(let text): message = text
289 case .prompt(let prompt): 293 case .prompt(let prompt):
290 // A state note: asked in the main window's echo area. 294 // A state note.
291 commands.ask(prompt) { answer in 295 self.prompt = PromptRequest(prompt: prompt) { answer in
292 guard let answer else { return } 296 guard let answer else { return }
293 perform(command, on: entry, answers: answers.merging([prompt.key: answer]) { $1 }) 297 perform(command, on: entry, answers: answers.merging([prompt.key: answer]) { $1 })
294 } 298 }
295 openWindow(id: "main")
296 default: message = nil 299 default: message = nil
297 } 300 }
298 tick += 1 301 tick += 1
@@ -303,13 +306,12 @@ struct BoardView: View {
303 } 306 }
304 307
305 private func askProperty(_ entry: BoardEntry) { 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 guard let answer, let space = answer.firstIndex(of: " ") else { return } 310 guard let answer, let space = answer.firstIndex(of: " ") else { return }
308 let key = String(answer[..<space]) 311 let key = String(answer[..<space])
309 let value = String(answer[answer.index(after: space)...]).trimmingCharacters(in: .whitespaces) 312 let value = String(answer[answer.index(after: space)...]).trimmingCharacters(in: .whitespaces)
310 perform(SetProperty(key: key, value: value), on: entry) 313 perform(SetProperty(key: key, value: value), on: entry)
311 } 314 }
312 openWindow(id: "main")
313 } 315 }
314 316
315 private func jump(_ entry: BoardEntry) { 317 private func jump(_ entry: BoardEntry) {
Sources/Orgstar/ColumnViewSheet.swift +12 −22 · view
@@ -17,9 +17,8 @@ struct ColumnViewSheet: View {
17 @State private var editing: (row: Int, column: Int)? 17 @State private var editing: (row: Int, column: Int)?
18 @State private var draft = "" 18 @State private var draft = ""
19 @State private var message: String? 19 @State private var message: String?
20 /// A question the edit asks (a state note), with the command to run again. 20 /// A question the edit asks (a state note).
21 @State private var pending: (prompt: Prompt, command: any OrgCommand, start: Int, answers: [String: String])? 21 @State private var prompt: PromptRequest?
22 @State private var reply = ""
23 @FocusState private var focused: Bool 22 @FocusState private var focused: Bool
24 23
25 var body: some View { 24 var body: some View {
@@ -43,14 +42,7 @@ struct ColumnViewSheet: View {
43 .padding(10) 42 .padding(10)
44 } 43 }
45 .defaultScrollAnchor(.topLeading) 44 .defaultScrollAnchor(.topLeading)
46 if let pending { 45 PromptBar(request: $prompt)
47 HStack {
48 Text(pending.prompt.message)
49 TextField("", text: $reply).onSubmit(answerPending)
50 Button("OK", action: answerPending)
51 }
52 .padding(8)
53 }
54 if let message { 46 if let message {
55 Text(message).font(.callout).foregroundStyle(.secondary).padding(8) 47 Text(message).font(.callout).foregroundStyle(.secondary).padding(8)
56 } 48 }
@@ -120,7 +112,7 @@ struct ColumnViewSheet: View {
120 } 112 }
121 113
122 private func key(_ press: KeyPress) -> KeyPress.Result { 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 guard let current = selected else { 116 guard let current = selected else {
125 if [.downArrow, .upArrow, .leftArrow, .rightArrow].contains(press.key), !view.rows.isEmpty { 117 if [.downArrow, .upArrow, .leftArrow, .rightArrow].contains(press.key), !view.rows.isEmpty {
126 selected = (0, 0) 118 selected = (0, 0)
@@ -174,22 +166,20 @@ struct ColumnViewSheet: View {
174 refresh() 166 refresh()
175 case .failed(let text): 167 case .failed(let text):
176 message = text 168 message = text
177 case .prompt(let prompt): 169 case .prompt(let question):
178 reply = prompt.initial ?? "" 170 prompt = PromptRequest(prompt: question) { reply in
179 pending = (prompt, command, start, answers) 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 default: 177 default:
181 message = String(localized: "\(CommandTitle.localized(command.title)) can't run here", comment: "A command that doesn't apply in column view") 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 focused = true 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 /// The view again, over the same entries, keeping the selected cell. 183 /// The view again, over the same entries, keeping the selected cell.
194 private func refresh() { 184 private func refresh() {
195 guard let document = document(), let new = try? ColumnView.refresh(view, text: document.text, tree: document.tree) else { return } 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 .padding(10) 33 .padding(10)
34 } 34 }
35 if let request = commands.prompt { 35 if let request = commands.prompt {
36 PromptView(commands: commands, request: request) 36 PromptView(request: request, reply: commands.answer)
37 .id(request.id) 37 .id(request.id)
38 } else if let text = commands.pendingKeys.map({ $0 + "-" }) ?? commands.message { 38 } else if let text = commands.pendingKeys.map({ $0 + "-" }) ?? commands.message {
39 Text(text) 39 Text(text)
@@ -114,10 +114,12 @@ struct StateTag: View {
114} 114}
115 115
116/// A question a command asks: fast selection, or a text field with its choices, filtered as 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.
118struct PromptView: View { 119struct PromptView: View {
119 let commands: AppCommands
120 let request: PromptRequest 120 let request: PromptRequest
121 /// Ends the prompt with an answer, or nil to cancel.
122 let reply: (String?) -> Void
121 @State private var answer = "" 123 @State private var answer = ""
122 @FocusState private var answerFocused: Bool 124 @FocusState private var answerFocused: Bool
123 /// The highlighted choice, moved by ↑/↓ or C-p/C-n. 125 /// The highlighted choice, moved by ↑/↓ or C-p/C-n.
@@ -130,7 +132,7 @@ struct PromptView: View {
130 var body: some View { 132 var body: some View {
131 if let fast = prompt.fast { 133 if let fast = prompt.fast {
132 Divider() 134 Divider()
133 FastSelectionView(selection: fast, message: prompt.message) { commands.answer($0) } 135 FastSelectionView(selection: fast, message: prompt.message) { reply($0) }
134 } else { 136 } else {
135 let matches = filteredChoices(prompt.choices) 137 let matches = filteredChoices(prompt.choices)
136 let current = min(selected, matches.count - 1) 138 let current = min(selected, matches.count - 1)
@@ -142,7 +144,7 @@ struct PromptView: View {
142 ForEach(matches.indices, id: \.self) { index in 144 ForEach(matches.indices, id: \.self) { index in
143 let choice = matches[index] 145 let choice = matches[index]
144 Button { 146 Button {
145 if prompt.completionSeparator != nil { complete(choice) } else { commands.answer(choice) } 147 if prompt.completionSeparator != nil { complete(choice) } else { reply(choice) }
146 } label: { 148 } label: {
147 Text(choice) 149 Text(choice)
148 .frame(maxWidth: .infinity, alignment: .leading) 150 .frame(maxWidth: .infinity, alignment: .leading)
@@ -163,7 +165,7 @@ struct PromptView: View {
163 } 165 }
164 if let read = prompt.date { 166 if let read = prompt.date {
165 Divider() 167 Divider()
166 DatePickerView(answer: answer, read: read) { commands.answer($0) } 168 DatePickerView(answer: answer, read: read) { reply($0) }
167 } 169 }
168 Divider() 170 Divider()
169 HStack(spacing: 6) { 171 HStack(spacing: 6) {
@@ -177,9 +179,9 @@ struct PromptView: View {
177 .focused($answerFocused) 179 .focused($answerFocused)
178 .onSubmit { 180 .onSubmit {
179 if current >= 0, moved || prompt.requireMatch { 181 if current >= 0, moved || prompt.requireMatch {
180 commands.answer(matches[current]) 182 reply(matches[current])
181 } else if prompt.choices.isEmpty || !prompt.requireMatch { 183 } else if prompt.choices.isEmpty || !prompt.requireMatch {
182 commands.answer(answer) 184 reply(answer)
183 } 185 }
184 } 186 }
185 .onKeyPress(.tab) { 187 .onKeyPress(.tab) {
@@ -194,7 +196,7 @@ struct PromptView: View {
194 answer = DatePickerView.shifted(answer, read, by: days) 196 answer = DatePickerView.shifted(answer, read, by: days)
195 return .handled 197 return .handled
196 } 198 }
197 .onExitCommand { commands.answer(nil) } 199 .onExitCommand { reply(nil) }
198 .onChange(of: answer) { 200 .onChange(of: answer) {
199 selected = 0 201 selected = 0
200 moved = false 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.
247struct 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/// Messages: the echo area's recent messages, newest last (`view-echo-area-messages`). 267/// Messages: the echo area's recent messages, newest last (`view-echo-area-messages`).
245struct MessagesView: View { 268struct MessagesView: View {
246 let messages: [String] 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
229When a prompt closes, the keyboard goes back to the editor. 229When a prompt closes, the keyboard goes back to the editor.
230 230
231The 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* Completion 233* Completion
232 234
233Complete at Point (=completion-at-point=) completes the word before the caret from what Org knows at that position. 235Complete 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=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. 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=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]]. 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| =U= | Unmarks everything | =org-agenda-bulk-unmark-all= | 665| =U= | Unmarks everything | =org-agenda-bulk-unmark-all= |
666| =B= | Asks for an action on every marked entry | =org-agenda-bulk-action= | 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
670On 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. 670On 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** Table 699** Table
700 700
701Columns: 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. 701Columns: 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** Kanban 703** Kanban
704 704
705Each 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. 705Each 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
707From 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. 707From 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
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