iOS: suggestion row above the keyboard; editor file name !484

merged merged by cmc on 2026-11-26 06:03 UTC · krz/orgstar:m4-suggestions into main

10 files changed, +314 −20

Layout: unified · split

Changed files (10)
Sources/OrgApp/CommandTitles.swift +1 · view
@@ -90,6 +90,7 @@ enum CommandTitles {
90 String(localized: "Expand Table Columns", comment: "Command title"), 90 String(localized: "Expand Table Columns", comment: "Command title"),
91 String(localized: "Expand Word", comment: "Command title"), 91 String(localized: "Expand Word", comment: "Command title"),
92 String(localized: "Export Agenda Files to iCalendar", comment: "Command title"), 92 String(localized: "Export Agenda Files to iCalendar", comment: "Command title"),
93 String(localized: "Export Subtree…", comment: "Command title"),
93 String(localized: "Export Table as TSV…", comment: "Command title"), 94 String(localized: "Export Table as TSV…", comment: "Command title"),
94 String(localized: "Export Table to File…", comment: "Command title"), 95 String(localized: "Export Table to File…", comment: "Command title"),
95 String(localized: "Export to HTML", comment: "Command title"), 96 String(localized: "Export to HTML", comment: "Command title"),
Sources/OrgApp/SuggestionRow.swift added +40 · view
@@ -0,0 +1,40 @@
1import Foundation
2import OrgCore
3
4/// The iOS suggestion row: completion candidates in the key bar's place, tapped as the
5/// system's QuickType bar is. It shows the candidates the completion list would; the list
6/// stays for a hardware keyboard, whose keys move through it.
7public enum SuggestionRow {
8 /// A candidate as the row shows it: what is inserted, and what the list adds after it
9 /// (a snippet's name, a template's block, a heading's file).
10 public struct Item: Equatable, Sendable {
11 public let candidate: String
12 public let detail: String?
13 public let snippet: Bool
14 }
15
16 /// The most candidates the row holds; it scrolls through them.
17 public static let limit = 30
18
19 /// Candidates show in the row rather than the floating list: while the on-screen keyboard
20 /// is used, so not with a hardware keyboard.
21 public static func usesRow(hardwareKeyboard: Bool) -> Bool {
22 !hardwareKeyboard
23 }
24
25 /// The row takes the key bar's place: there are candidates, and the row wasn't put away
26 /// for this completion.
27 public static func shows(_ completion: Completion?, dismissed: Bool) -> Bool {
28 guard let completion, !dismissed else { return false }
29 return !completion.candidates.isEmpty
30 }
31
32 /// The candidates in the list's order, up to `limit`.
33 public static func items(_ completion: Completion, limit: Int = limit) -> [Item] {
34 completion.candidates.prefix(limit).map { candidate in
35 let label = completion.label(candidate)
36 let detail = label.hasPrefix(candidate) ? label.dropFirst(candidate.count).trimmingCharacters(in: .whitespaces) : ""
37 return Item(candidate: candidate, detail: detail.isEmpty ? nil : detail, snippet: completion.kind == .snippet)
38 }
39 }
40}
Sources/OrgstarMobile/EditorScreen.swift +19 −4 · view
@@ -83,7 +83,7 @@ struct EditorScreen: View {
83 } 83 }
84 84
85 enum Sheet: Identifiable { 85 enum Sheet: Identifiable {
86 case palette, conflict, syncCopies, recovery 86 case palette, conflict, syncCopies, recovery, export
87 /// `app.refile`, `app.refile.copy` or `app.refile.goto`. 87 /// `app.refile`, `app.refile.copy` or `app.refile.goto`.
88 case refile(String) 88 case refile(String)
89 case block(BlockEdit) 89 case block(BlockEdit)
@@ -102,6 +102,7 @@ struct EditorScreen: View {
102 case .conflict: "conflict" 102 case .conflict: "conflict"
103 case .syncCopies: "syncCopies" 103 case .syncCopies: "syncCopies"
104 case .recovery: "recovery" 104 case .recovery: "recovery"
105 case .export: "export"
105 case .block(let edit): "block \(edit.range)" 106 case .block(let edit): "block \(edit.range)"
106 case .columns: "columns" 107 case .columns: "columns"
107 case .plot: "plot" 108 case .plot: "plot"
@@ -115,6 +116,9 @@ struct EditorScreen: View {
115 116
116 private var pane: EditorPane? { givenPane ?? holder.pane } 117 private var pane: EditorPane? { givenPane ?? holder.pane }
117 118
119 /// Export Subtree…, which shows the export formats for the subtree at the caret.
120 static let exportSubtreeCommand = "app.export-subtree-dialog"
121
118 /// The pane commands, as the Mac's View menu has them. 122 /// The pane commands, as the Mac's View menu has them.
119 static let paneCommands = ["app.split-right", "app.split-below", "app.pane-next", "app.pane-close", "app.pane-only"] 123 static let paneCommands = ["app.split-right", "app.split-below", "app.pane-next", "app.pane-close", "app.pane-only"]
120 124
@@ -138,7 +142,8 @@ struct EditorScreen: View {
138 if syncCopies > 0 { 142 if syncCopies > 0 {
139 Button("Resolve Sync Conflicts…", systemImage: "doc.on.doc") { sheet = .syncCopies } 143 Button("Resolve Sync Conflicts…", systemImage: "doc.on.doc") { sheet = .syncCopies }
140 } 144 }
141 if recoveries > 0 { 145 // On iPhone, in Commands, so the file name has room at the largest text sizes.
146 if recoveries > 0, sizeClass == .regular {
142 Button("Recovery Versions…", systemImage: "clock.arrow.circlepath") { sheet = .recovery } 147 Button("Recovery Versions…", systemImage: "clock.arrow.circlepath") { sheet = .recovery }
143 } 148 }
144 Button("Find", systemImage: "magnifyingglass") { 149 Button("Find", systemImage: "magnifyingglass") {
@@ -152,7 +157,8 @@ struct EditorScreen: View {
152 } primaryAction: { 157 } primaryAction: {
153 editor?.run("edit.undo") 158 editor?.run("edit.undo")
154 } 159 }
155 if let tree = session.document(of: path)?.tree { 160 // On iPhone, Export is in Commands, so the file name has room.
161 if sizeClass == .regular, let tree = session.document(of: path)?.tree {
156 ExportMenu(path: path, tree: tree, report: { message = $0 }, exportSubtree: exportSubtree) 162 ExportMenu(path: path, tree: tree, report: { message = $0 }, exportSubtree: exportSubtree)
157 } 163 }
158 Button("Commands", systemImage: "command") { sheet = .palette } 164 Button("Commands", systemImage: "command") { sheet = .palette }
@@ -220,6 +226,8 @@ struct EditorScreen: View {
220 PlotScreen(plot: plot) 226 PlotScreen(plot: plot)
221 case .crypt(let request): 227 case .crypt(let request):
222 CryptScreen(request: request, session: session, editor: editor) { message = $0 } 228 CryptScreen(request: request, session: session, editor: editor) { message = $0 }
229 case .export:
230 if let tree = session.document(of: path)?.tree { ExportScreen(path: path, tree: tree) { message = $0 } }
223 case .exportSubtree(let caret): 231 case .exportSubtree(let caret):
224 if let tree = session.document(of: path)?.tree { SubtreeExportScreen(path: path, tree: tree, caret: caret) } 232 if let tree = session.document(of: path)?.tree { SubtreeExportScreen(path: path, tree: tree, caret: caret) }
225 case .backlinks: 233 case .backlinks:
@@ -449,6 +457,10 @@ struct EditorScreen: View {
449 if let caret = self.editor?.editContext().caret { message = session.archive(from: (path, caret)) } 457 if let caret = self.editor?.editContext().caret { message = session.archive(from: (path, caret)) }
450 } else if id == "app.copy-rich-text" { 458 } else if id == "app.copy-rich-text" {
451 if let text = session.document(of: path)?.text { message = ExportItems.copy(path: path, text: text, theme: model.theme) } 459 if let text = session.document(of: path)?.text { message = ExportItems.copy(path: path, text: text, theme: model.theme) }
460 } else if id == "app.export-dialog" {
461 sheet = .export
462 } else if id == EditorScreen.exportSubtreeCommand {
463 exportSubtree()
452 } else if id == "app.export.html-open" { 464 } else if id == "app.export.html-open" {
453 exportHTMLAndOpen() 465 exportHTMLAndOpen()
454 } else if id == "app.export-body-only" { 466 } else if id == "app.export-body-only" {
@@ -1020,7 +1032,8 @@ struct CommandPalette: View {
1020 ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"), 1032 ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"),
1021 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), 1033 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"),
1022 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"), 1034 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"),
1023 ("app.archive", "Archive Subtree"), ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"), 1035 ("app.archive", "Archive Subtree"), ("app.export-dialog", "Export…"), ("app.export-subtree-dialog", "Export Subtree…"),
1036 ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"),
1024 ("app.export-body-only", "Turn Body-Only Export On or Off"), 1037 ("app.export-body-only", "Turn Body-Only Export On or Off"),
1025 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"), 1038 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"),
1026 ("app.publish", "Publish Project…"), ("app.publish.all", "Publish All Projects"), ("app.publish.current-file", "Publish Current File"), 1039 ("app.publish", "Publish Project…"), ("app.publish.all", "Publish All Projects"), ("app.publish.current-file", "Publish Current File"),
@@ -1112,6 +1125,8 @@ struct CommandPalette: View {
1112 switch id { 1125 switch id {
1113 case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions") 1126 case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions")
1114 case "app.sync-conflicts": return syncCopies > 0 ? nil : String(localized: "No sync conflict copies", comment: "Why Resolve Sync Conflicts… is greyed in the Commands list") 1127 case "app.sync-conflicts": return syncCopies > 0 ? nil : String(localized: "No sync conflict copies", comment: "Why Resolve Sync Conflicts… is greyed in the Commands list")
1128 case EditorScreen.exportSubtreeCommand:
1129 return ExportScope.subtree(context.text, at: context.caret) != nil ? nil : String(localized: "Not in a subtree", comment: "Why Export Subtree… is greyed in the Commands list")
1115 default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context) 1130 default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context)
1116 } 1131 }
1117 } 1132 }
Sources/OrgstarMobile/KeyBar.swift +93 −7 · view
@@ -7,7 +7,8 @@ import UIKit
7/// Org's keys for a touch keyboard: each button does what its key does at the caret, as the 7/// Org's keys for a touch keyboard: each button does what its key does at the caret, as the
8/// Emacs keymap binds it (M-→ demotes a heading, indents an item, moves a table column), or 8/// Emacs keymap binds it (M-→ demotes a heading, indents an item, moves a table column), or
9/// runs a command. The buttons are `[key-bar]` in config.toml, or the default; they share the 9/// runs a command. The buttons are `[key-bar]` in config.toml, or the default; they share the
10/// width without scrolling, and those that don't fit go under More. 10/// width without scrolling, and those that don't fit go under More. While completion has
11/// candidates at the caret, they show in the bar's place.
11struct KeyBar: View { 12struct KeyBar: View {
12 let editor: MobileEditor 13 let editor: MobileEditor
13 let palette: () -> Void 14 let palette: () -> Void
@@ -109,6 +110,22 @@ struct KeyBar: View {
109 @ScaledMetric(relativeTo: .body) private var size = KeyBar.target 110 @ScaledMetric(relativeTo: .body) private var size = KeyBar.target
110 111
111 var body: some View { 112 var body: some View {
113 Group {
114 if SuggestionRow.shows(editor.suggestions.completion, dismissed: editor.suggestions.dismissed), let completion = editor.suggestions.completion {
115 suggestionRow(completion)
116 } else {
117 keys
118 }
119 }
120 .labelStyle(.iconOnly)
121 .padding(.horizontal, 6)
122 .padding(.vertical, Self.padding)
123 .frame(maxWidth: .infinity)
124 .onGeometryChange(for: CGFloat.self) { $0.size.width } action: { width = $0 }
125 .background(.bar)
126 }
127
128 private var keys: some View {
112 let layout = sizeClass == .regular ? KeyBarLayout.Width.ipad : .iphone 129 let layout = sizeClass == .regular ? KeyBarLayout.Width.ipad : .iphone
113 var ids = ((layout == .ipad ? ipad : iphone).map(KeyBarLayout.ids) ?? layout.defaultIDs).filter { Self.item($0) != nil } 130 var ids = ((layout == .ipad ? ipad : iphone).map(KeyBarLayout.ids) ?? layout.defaultIDs).filter { Self.item($0) != nil }
114 if editor.fields.active { ids = KeyBarLayout.withSnippetFields(ids) } 131 if editor.fields.active { ids = KeyBarLayout.withSnippetFields(ids) }
@@ -120,12 +137,52 @@ struct KeyBar: View {
120 } 137 }
121 if !more.isEmpty { moreButton(more) } 138 if !more.isEmpty { moreButton(more) }
122 } 139 }
123 .labelStyle(.iconOnly) 140 }
124 .padding(.horizontal, 6) 141
125 .padding(.vertical, Self.padding) 142 /// The candidates at the caret in the bar's place, scrolling on their own, and at the end
126 .frame(maxWidth: .infinity) 143 /// the button that puts them away and brings the keys back.
127 .onGeometryChange(for: CGFloat.self) { $0.size.width } action: { width = $0 } 144 private func suggestionRow(_ completion: Completion) -> some View {
128 .background(.bar) 145 HStack(spacing: 4) {
146 ScrollView(.horizontal, showsIndicators: false) {
147 HStack(spacing: 4) {
148 ForEach(SuggestionRow.items(completion), id: \.candidate) { item in
149 Button {
150 editor.chooseSuggestion(item.candidate)
151 } label: {
152 suggestionLabel(item)
153 }
154 .buttonStyle(SuggestionStyle(size: size))
155 .accessibilityLabel([item.candidate, item.detail, item.snippet ? String(localized: "snippet", comment: "Marks a snippet in the completion list") : nil]
156 .compactMap { $0 }.joined(separator: ", "))
157 }
158 }
159 .padding(.horizontal, 2)
160 }
161 // Back at the start for each new completion.
162 .id(completion.range.lowerBound)
163 Button {
164 editor.suggestions.dismissed = true
165 } label: {
166 Label(String(localized: "Hide Suggestions"), systemImage: "xmark")
167 }
168 .buttonStyle(KeyStyle(size: size, slots: 1))
169 .frame(width: KeyBar.widest)
170 .accessibilityLabel(String(localized: "Hide Suggestions"))
171 }
172 .dynamicTypeSize(...Self.largestSymbolSize)
173 .accessibilityIdentifier("suggestions")
174 }
175
176 private func suggestionLabel(_ item: SuggestionRow.Item) -> some View {
177 CappedWidth(width: 240) {
178 HStack(spacing: 4) {
179 if item.snippet { Image(systemName: "text.badge.plus").foregroundStyle(.tint) }
180 Text(item.candidate).foregroundStyle(.primary)
181 if let detail = item.detail { Text(detail).foregroundStyle(.secondary) }
182 }
183 .font(.body)
184 .lineLimit(1)
185 }
129 } 186 }
130 187
131 @ViewBuilder 188 @ViewBuilder
@@ -266,6 +323,35 @@ private struct KeyShape: ViewModifier {
266 } 323 }
267} 324}
268 325
326/// As wide as its content wants up to `width`, where a long suggestion is cut short.
327private struct CappedWidth: Layout {
328 let width: CGFloat
329
330 func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
331 guard let view = subviews.first else { return .zero }
332 let ideal = view.sizeThatFits(.unspecified)
333 return view.sizeThatFits(ProposedViewSize(width: min(ideal.width, width), height: proposal.height))
334 }
335
336 func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
337 subviews.first?.place(at: bounds.origin, proposal: ProposedViewSize(bounds.size))
338 }
339}
340
341/// A suggestion: its text on a tile as tall as the keys, as wide as the text needs.
342private struct SuggestionStyle: ButtonStyle {
343 let size: CGFloat
344
345 func makeBody(configuration: Configuration) -> some View {
346 configuration.label
347 .padding(.horizontal, 12)
348 .frame(minHeight: size)
349 .background(.fill.tertiary, in: .rect(cornerRadius: 10))
350 .opacity(configuration.isPressed ? 0.5 : 1)
351 .contentShape(.rect)
352 }
353}
354
269private struct KeyStyle: ButtonStyle { 355private struct KeyStyle: ButtonStyle {
270 let size: CGFloat 356 let size: CGFloat
271 let slots: Int 357 let slots: Int
Sources/OrgstarMobile/MobileEditor+Completion.swift +15 −1 · view
@@ -1,5 +1,6 @@
1#if os(iOS) 1#if os(iOS)
2import OrgApp 2import OrgApp
3import GameController
3import OrgCore 4import OrgCore
4import UIKit 5import UIKit
5 6
@@ -100,6 +101,7 @@ extension MobileEditor {
100 101
101 func openCompletion(_ completion: Completion, select: Int? = nil) { 102 func openCompletion(_ completion: Completion, select: Int? = nil) {
102 completionFetched = nil 103 completionFetched = nil
104 suggestions.dismissed = false
103 if !completion.candidates.isEmpty { showCompletion(completion, select: select) } 105 if !completion.candidates.isEmpty { showCompletion(completion, select: select) }
104 guard let query = completion.query, let source = completionSource else { 106 guard let query = completion.query, let source = completionSource else {
105 if completion.candidates.isEmpty { closeCompletion() } 107 if completion.candidates.isEmpty { closeCompletion() }
@@ -140,7 +142,10 @@ extension MobileEditor {
140 completionList = view 142 completionList = view
141 textView.addSubview(view) 143 textView.addSubview(view)
142 } 144 }
143 guard let position = textView.position(from: textView.beginningOfDocument, offset: completion.range.lowerBound) else { return } 145 let row = SuggestionRow.usesRow(hardwareKeyboard: GCKeyboard.coalesced != nil)
146 view.isHidden = row
147 suggestions.completion = row ? view.completion : nil
148 guard !row, let position = textView.position(from: textView.beginningOfDocument, offset: completion.range.lowerBound) else { return }
144 let caret = textView.caretRect(for: position) 149 let caret = textView.caretRect(for: position)
145 let insets = textView.adjustedContentInset 150 let insets = textView.adjustedContentInset
146 let visible = CGRect(x: textView.contentOffset.x, y: textView.contentOffset.y + insets.top, 151 let visible = CGRect(x: textView.contentOffset.x, y: textView.contentOffset.y + insets.top,
@@ -154,6 +159,15 @@ extension MobileEditor {
154 completionTask?.cancel() 159 completionTask?.cancel()
155 completionList?.removeFromSuperview() 160 completionList?.removeFromSuperview()
156 completionList = nil 161 completionList = nil
162 suggestions.completion = nil
163 suggestions.dismissed = false
164 }
165
166 /// A candidate tapped in the suggestion row, inserted as one chosen from the list.
167 func chooseSuggestion(_ candidate: String) {
168 guard let completion = completionList?.completion else { return }
169 closeCompletion()
170 insertCompletion(completion, candidate)
157 } 171 }
158 172
159 /// After typing: the open list follows the text; otherwise, as the settings say, a list 173 /// After typing: the open list follows the text; otherwise, as the settings say, a list
Sources/OrgstarMobile/MobileEditor.swift +10 −1 · view
@@ -130,6 +130,8 @@ final class MobileEditor: NSObject, DocumentBuffer {
130 var completionTimer: Timer? 130 var completionTimer: Timer?
131 var completionFetched: CompletionFlow.Fetched? 131 var completionFetched: CompletionFlow.Fetched?
132 var completionTask: Task<Void, Never>? 132 var completionTask: Task<Void, Never>?
133 /// The candidates the key bar shows in its place while the on-screen keyboard is used.
134 let suggestions = Suggestions()
133 /// `dabbrev-expand` being repeated, and the revision its last expansion left. 135 /// `dabbrev-expand` being repeated, and the revision its last expansion left.
134 var dabbrev: DabbrevExpansion? 136 var dabbrev: DabbrevExpansion?
135 var dabbrevRevision: Int? 137 var dabbrevRevision: Int?
@@ -506,7 +508,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
506 case "app.word-count", "app.recovery", "app.sync-conflicts", "app.attach.photo", "app.attach.camera", "app.attach.scan": return onAppCommand != nil 508 case "app.word-count", "app.recovery", "app.sync-conflicts", "app.attach.photo", "app.attach.camera", "app.attach.scan": return onAppCommand != nil
507 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true 509 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true
508 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil 510 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
509 case "app.copy-rich-text", "app.export.html-open", "app.export-body-only", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil 511 case "app.export-dialog", "app.export-subtree-dialog", "app.copy-rich-text", "app.export.html-open", "app.export-body-only", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil
510 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil 512 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil
511 case _ where Self.linkCommands.contains(id): return onAppCommand != nil 513 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
512 case "org.link.open": return OpenLinkAtPoint().applies(in: context) 514 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
@@ -849,6 +851,13 @@ extension MobileEditor: NSTextLayoutManagerDelegate {
849 } 851 }
850} 852}
851 853
854/// The completion the suggestion row shows, and whether it was put away for it.
855@Observable
856final class Suggestions {
857 var completion: Completion?
858 var dismissed = false
859}
860
852/// Whether a snippet's fields are being filled in. 861/// Whether a snippet's fields are being filled in.
853@Observable 862@Observable
854final class SnippetFields { 863final class SnippetFields {
Tests/OrgAppTests/EditorCommandListTests.swift added +24 · view
@@ -0,0 +1,24 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5/// The iOS editor's Commands list, read from its source as CommandTitleTests does: the target
6/// isn't built by `swift test`.
7struct EditorCommandListTests {
8 static let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
9
10 static func viewCommands() throws -> [(id: String, title: String)] {
11 let source = try String(contentsOf: root.appendingPathComponent("Sources/OrgstarMobile/EditorScreen.swift"), encoding: .utf8)
12 return source.matches(of: /\("((?:app|org|edit|editor|view)\.[^"]+)", "([^"\\]+)"\)/).map { (String($0.1), String($0.2)) }
13 }
14
15 /// #236: Export is in Commands, under Export, since the iPhone toolbar has no room for it.
16 @Test func exportIsInTheEditorsCommands() throws {
17 let commands = try Self.viewCommands()
18 #expect(commands.contains { $0 == ("app.export-dialog", "Export…") })
19 #expect(commands.contains { $0 == ("app.export-subtree-dialog", "Export Subtree…") })
20 let export = try #require(CommandGroups.commandList.firstIndex { $0.prefixes.contains("app.export") })
21 #expect(CommandGroups.group(of: "app.export-dialog", in: CommandGroups.commandList) == export)
22 #expect(CommandGroups.group(of: "app.export-subtree-dialog", in: CommandGroups.commandList) == export)
23 }
24}
Tests/OrgAppTests/SuggestionRowTests.swift added +62 · view
@@ -0,0 +1,62 @@
1import Foundation
2import Testing
3import OrgCore
4@testable import OrgApp
5
6/// The iOS suggestion row (#145).
7struct SuggestionRowTests {
8 func context(_ text: String, options: EditingOptions = .org) -> EditContext {
9 let caret = text.utf16.count
10 return EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], options: options)
11 }
12
13 @Test func rowOnlyWithTheOnScreenKeyboard() {
14 #expect(SuggestionRow.usesRow(hardwareKeyboard: false))
15 #expect(!SuggestionRow.usesRow(hardwareKeyboard: true))
16 }
17
18 @Test func showsWhileThereAreCandidates() {
19 let completion = OrgCompletion.at(context("#+TIT"))
20 #expect(SuggestionRow.shows(completion, dismissed: false))
21 #expect(!SuggestionRow.shows(completion, dismissed: true))
22 #expect(!SuggestionRow.shows(nil, dismissed: false))
23 // Nothing matches: the key bar stays.
24 #expect(!SuggestionRow.shows(OrgCompletion.at(context("#+XYZQ")), dismissed: false))
25 }
26
27 @Test func showsWhenTheListWouldOpenByItself() {
28 let options = CompletionOptions(auto: true, prefix: 3)
29 for text in ["#+TI", "#+TIT"] {
30 let completion = OrgCompletion.at(context(text))
31 let opened = CompletionAuto.opens(completion, options) ? completion : nil
32 #expect(SuggestionRow.shows(opened, dismissed: false) == (text == "#+TIT"))
33 }
34 }
35
36 @Test func itemsFollowTheListsOrder() throws {
37 let completion = try #require(OrgCompletion.at(context("#+TIT")))
38 let items = SuggestionRow.items(completion)
39 #expect(items.map(\.candidate) == completion.candidates)
40 #expect(items.allSatisfy { !$0.snippet && $0.detail == nil })
41 #expect(SuggestionRow.items(completion, limit: 1).count == min(1, completion.candidates.count))
42 }
43
44 @Test func snippetsWithTheirNames() throws {
45 var options = EditingOptions.org
46 options.snippets = [Snippet(trigger: "meeting", name: "Meeting notes", body: "x"), Snippet(trigger: "mail", body: "y")]
47 let completion = try #require(OrgCompletion.at(context("m", options: options)))
48 #expect(completion.kind == .snippet)
49 let items = SuggestionRow.items(completion)
50 #expect(Set(items.map(\.candidate)) == ["meeting", "mail"])
51 #expect(items.allSatisfy { $0.snippet })
52 #expect(items.first { $0.candidate == "meeting" }?.detail == "Meeting notes")
53 #expect(items.first { $0.candidate == "mail" }?.detail == nil)
54 }
55
56 @Test func templatesWithTheirBlocks() throws {
57 let completion = try #require(OrgCompletion.at(context("<s")))
58 #expect(completion.kind == .template)
59 let item = try #require(SuggestionRow.items(completion).first { $0.candidate == "<s" })
60 #expect(item.detail == "src")
61 }
62}
docs/manual/guide/14-ios.org +15 −7 · view
@@ -57,11 +57,13 @@ The toolbar has:
57- Conflict :: shown while the file and your edits conflict; opens the conflict sheet. 57- Conflict :: shown while the file and your edits conflict; opens the conflict sheet.
58- Find :: the system find bar. The result shown is selected, and opened when it is in folded text. 58- Find :: the system find bar. The result shown is selected, and opened when it is in folded text.
59- Resolve Sync Conflicts… :: shown while the file has Syncthing conflict copies; see Conflicts below. 59- Resolve Sync Conflicts… :: shown while the file has Syncthing conflict copies; see Conflicts below.
60- Recovery Versions… :: shown while the recovery folder holds versions of the file; see Conflicts below. 60- Recovery Versions… :: on iPad, shown while the recovery folder holds versions of the file; see Conflicts below.
61- Undo :: touch and hold it for Redo. 61- Undo :: touch and hold it for Redo.
62- Export :: the export formats, as in the reader; see Export below. 62- Export :: on iPad, the export formats; see Export below.
63- Commands :: every command; see Commands below. 63- Commands :: every command; see Commands below.
64 64
65On iPhone, Recovery Versions…, Export… and Export Subtree… are in Commands, so the file name has room at every text size.
66
65The key bar holds what you repeat at the caret while typing, the toolbar what acts on the whole file, and Commands everything else. 67The key bar holds what you repeat at the caret while typing, the toolbar what acts on the whole file, and Commands everything else.
66 68
67Messages from commands show at the top of the editor and the column view, and at the bottom of the reader, the agenda and the board, for a few seconds; tap one to dismiss it. VoiceOver reads each message as it appears. An error opening, saving or reading a file shows what failed on its first line, such as =Couldn't Save File=. 69Messages from commands show at the top of the editor and the column view, and at the bottom of the reader, the agenda and the board, for a few seconds; tap one to dismiss it. VoiceOver reads each message as it appears. An error opening, saving or reading a file shows what failed on its first line, such as =Couldn't Save File=.
@@ -164,13 +166,19 @@ When the buttons don't fit the width, the bar shows as many as fit, in order, an
164 166
165While a snippet's fields are filled in, Previous Snippet Field and Next Snippet Field take the places of Promote and Demote, so the fields work without a hardware keyboard; Promote and Demote come back when the snippet ends. A bar without Promote or Demote shows the field buttons first. 167While a snippet's fields are filled in, Previous Snippet Field and Next Snippet Field take the places of Promote and Demote, so the fields work without a hardware keyboard; Promote and Demote come back when the snippet ends. A bar without Promote or Demote shows the field buttons first.
166 168
169*** Suggestions
170
171While completion has candidates at the caret, the bar shows them in place of its buttons, as the system's QuickType bar does: the candidates the completion list would show, in its order, each with what the list adds after it, such as a snippet's name (with a snippet symbol) or a template's block. Tap one to insert it as choosing it from the list does; a snippet expands. The suggestions scroll sideways when they don't fit; the × at the end stays in place and puts them away, bringing the buttons back until the word is finished or Complete at Point is run again. The row is as tall as the buttons and follows the text size the same way.
172
173Suggestions appear when the list would open by itself (Settings ▸ Completion, with its pause and minimum length) and on Complete at Point in Commands. They take the list's place while the on-screen keyboard is used, on iPhone and iPad; with a hardware keyboard the list opens at the caret instead, so its keys move through it, and the bar keeps its buttons.
174
167** Commands 175** Commands
168 176
169Commands, in the key bar and in the toolbar of the editor, the reader and the agenda, lists the commands of the screen. With nothing typed, the ten you ran from Commands most recently come first under Recent, then every command by subject, in the Org menu's groups (Visibility, Headings, TODO and Tags, and so on) followed by Clock, Export, File, Edit and View. Type to search: the letters you type must appear in the title in order, as in the Mac's command palette, and commands you run often rank a little higher. The command runs once the list closes. 177Commands, in the key bar and in the toolbar of the editor, the reader and the agenda, lists the commands of the screen. With nothing typed, the ten you ran from Commands most recently come first under Recent, then every command by subject, in the Org menu's groups (Visibility, Headings, TODO and Tags, and so on) followed by Clock, Export, File, Edit and View. Type to search: the letters you type must appear in the title in order, as in the Mac's command palette, and commands you run often rank a little higher. The command runs once the list closes.
170 178
171Named keyboard macros are listed by name under Edit, and Next Snippet Field and Previous Snippet Field under Text with the other snippet commands. In the editor, a command that doesn't apply at the caret is listed greyed, with the reason, such as =Not in a list= or =No table at point=, so a search finds everything the editor can do. With a hardware keyboard attached, each command shows its Emacs key. 179Named keyboard macros are listed by name under Edit, and Next Snippet Field and Previous Snippet Field under Text with the other snippet commands. In the editor, a command that doesn't apply at the caret is listed greyed, with the reason, such as =Not in a list= or =No table at point=, so a search finds everything the editor can do. With a hardware keyboard attached, each command shows its Emacs key.
172 180
173The reader's list has Find, Outline, Export…, Show or Hide Markup, Capture… and the clock commands that need no caret. The agenda's has its views, Tags and Properties…, Search…, Save as View…, Today, Earlier, Later, Go to Date…, Log Mode, Filter…, Select, Board, Capture… and the same clock commands. 181The editor's list has Export… and Export Subtree… under Export. The reader's list has Find, Outline, Export…, Show or Hide Markup, Capture… and the clock commands that need no caret. The agenda's has its views, Tags and Properties…, Search…, Save as View…, Today, Earlier, Later, Go to Date…, Log Mode, Filter…, Select, Board, Capture… and the same clock commands.
174 182
175When a command asks a question, a sheet opens: 183When a command asks a question, a sheet opens:
176 184
@@ -222,7 +230,7 @@ See [[file:03-keys.org][Keys and commands]] for the Emacs bindings.
222 230
223** Completion 231** Completion
224 232
225With a hardware keyboard, Complete at Point (=C-M-i=, or =C-SPC= in Doom's insert state), Expand Word (=M-/=, or =F5= with the Mac keys) and Complete Word (=C-M-/=, or =C-n= and =C-p= in Doom's insert state) work as on the Mac; see [[file:02-the-editor.org][The editor]]. The list shows up to 8 rows under the caret; the keys move through it as on the Mac, and tapping a row inserts it. The settings in Settings ▸ Completion are the Mac's: whether the list opens by itself, after which pause and how many characters, prefix or fuzzy matching, and words in the list. With them on, the list also opens as you type on the on-screen keyboard, where tapping a row is the way to choose. 233With a hardware keyboard, Complete at Point (=C-M-i=, or =C-SPC= in Doom's insert state), Expand Word (=M-/=, or =F5= with the Mac keys) and Complete Word (=C-M-/=, or =C-n= and =C-p= in Doom's insert state) work as on the Mac; see [[file:02-the-editor.org][The editor]]. The list shows up to 8 rows under the caret; the keys move through it as on the Mac, and tapping a row inserts it. The settings in Settings ▸ Completion are the Mac's: whether the list opens by itself, after which pause and how many characters, prefix or fuzzy matching, and words in the list. With them on, candidates also show as you type on the on-screen keyboard, in the key bar's place; see Suggestions under The key bar.
226 234
227** Snippets 235** Snippets
228 236
@@ -391,11 +399,11 @@ The app icon's badge counts the entries in the agenda's Overdue section that are
391 399
392* Export 400* Export
393 401
394Export (in the editor's toolbar, and Export… in the reader's Commands) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX or ASCII export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " or "Can't export to plain text: " and the reason show at the bottom of the screen. 402Export (in the editor's toolbar on iPad, and Export… in the Commands of the editor and the reader) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX or ASCII export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " or "Can't export to plain text: " and the reason show at the bottom of the screen.
395 403
396PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. PDF through LaTeX isn't available on iOS. 404PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. PDF through LaTeX isn't available on iOS.
397 405
398Body Only in the Export menu leaves out the title and the page around the text in HTML, Markdown, LaTeX and Plain Text (ASCII), and is kept for each file; the other formats say they have no body-only export while it is on. Export Subtree…, in the editor's Export menu, shares the subtree at the caret in any of the formats. 406Body Only in the Export menu leaves out the title and the page around the text in HTML, Markdown, LaTeX and Plain Text (ASCII), and is kept for each file; the other formats say they have no body-only export while it is on. Export Subtree…, in the editor's Commands and its Export menu on iPad, shares the subtree at the caret in any of the formats.
399 407
400The Export menu also has Export Agenda Files to iCalendar, which writes an =.ics= beside each agenda file, and Combine Agenda Files into iCalendar, which shares one calendar of them all. Commands has these, Copy as Rich Text, and Export to HTML and Open, which shows the HTML export in Quick Look. Without orgstar+, the Export menu's items that need it end in "(orgstar+)" and open the orgstar+ screen. 408The Export menu also has Export Agenda Files to iCalendar, which writes an =.ics= beside each agenda file, and Combine Agenda Files into iCalendar, which shares one calendar of them all. Commands has these, Copy as Rich Text, and Export to HTML and Open, which shows the HTML export in Quick Look. Without orgstar+, the Export menu's items that need it end in "(orgstar+)" and open the orgstar+ screen.
401 409
@@ -432,7 +440,7 @@ The version you don't keep goes to the recovery folder.
432 440
433Resolve Sync Conflicts… (in the editor's toolbar while there are copies, and in Commands) lists Syncthing's conflict copies of the file (=name.sync-conflict-…=), each compared with the file, with Keep File, Merge and Use Copy. The copy goes to the recovery folder and is removed. When a file with conflict copies opens in the editor, a message says how many there are. 441Resolve Sync Conflicts… (in the editor's toolbar while there are copies, and in Commands) lists Syncthing's conflict copies of the file (=name.sync-conflict-…=), each compared with the file, with Keep File, Merge and Use Copy. The copy goes to the recovery folder and is removed. When a file with conflict copies opens in the editor, a message says how many there are.
434 442
435Recovery Versions… (in the editor's toolbar while there are versions, and in Commands) lists the versions of the file kept in the recovery folder, newest first, each compared with the editor's text. Restore puts a version's text in the editor as an edit you can undo. 443Recovery Versions… (in Commands, and in the editor's toolbar on iPad while there are versions) lists the versions of the file kept in the recovery folder, newest first, each compared with the editor's text. Restore puts a version's text in the editor as an edit you can undo.
436 444
437See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work. 445See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work.
438 446
l10n/Localizable.xcstrings +35 · view
@@ -18970,6 +18970,41 @@
18970 } 18970 }
18971 } 18971 }
18972 }, 18972 },
18973 "Hide Suggestions": {
18974 "comment": "Key bar: puts the completion suggestions away and shows the keys again",
18975 "localizations": {
18976 "de": {
18977 "stringUnit": {
18978 "state": "translated",
18979 "value": "Vorschläge ausblenden"
18980 }
18981 },
18982 "es": {
18983 "stringUnit": {
18984 "state": "translated",
18985 "value": "Ocultar sugerencias"
18986 }
18987 },
18988 "fr": {
18989 "stringUnit": {
18990 "state": "translated",
18991 "value": "Masquer les suggestions"
18992 }
18993 },
18994 "ja": {
18995 "stringUnit": {
18996 "state": "translated",
18997 "value": "候補を隠す"
18998 }
18999 },
19000 "pt-BR": {
19001 "stringUnit": {
19002 "state": "translated",
19003 "value": "Ocultar Sugestões"
19004 }
19005 }
19006 }
19007 },
18973 "Hide entries from earlier days": { 19008 "Hide entries from earlier days": {
18974 "localizations": { 19009 "localizations": {
18975 "de": { 19010 "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