iOS: suggestion row above the keyboard; editor file name !484
5 files changed, +53 −11
Changed files (5)
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/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/MobileEditor.swift +1 −1 · view
| @@ -508,7 +508,7 @@ final class MobileEditor: NSObject, DocumentBuffer { | |||
| 508 | 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 |
| 509 | case _ where id.hasPrefix(NamedMacros.commandPrefix): return true | 509 | case _ where id.hasPrefix(NamedMacros.commandPrefix): return true |
| 510 | 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 |
| 511 | 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 |
| 512 | case _ where id.hasPrefix("app.publish"): return onAppCommand != nil | 512 | case _ where id.hasPrefix("app.publish"): return onAppCommand != nil |
| 513 | case _ where Self.linkCommands.contains(id): return onAppCommand != nil | 513 | case _ where Self.linkCommands.contains(id): return onAppCommand != nil |
| 514 | case "org.link.open": return OpenLinkAtPoint().applies(in: context) | 514 | case "org.link.open": return OpenLinkAtPoint().applies(in: context) |
Tests/OrgAppTests/EditorCommandListTests.swift added +24 · view
| @@ -0,0 +1,24 @@ | |||
| 1 | import Foundation | ||
| 2 | import 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`. | ||
| 7 | struct 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 | } | ||
docs/manual/guide/14-ios.org +8 −6 · 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 | ||
| 65 | On iPhone, Recovery Versions…, Export… and Export Subtree… are in Commands, so the file name has room at every text size. | ||
| 66 | |||
| 65 | The key bar holds what you repeat at the caret while typing, the toolbar what acts on the whole file, and Commands everything else. | 67 | The 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 | ||
| 67 | Messages 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=. | 69 | Messages 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=. |
| @@ -176,7 +178,7 @@ Commands, in the key bar and in the toolbar of the editor, the reader and the ag | |||
| 176 | 178 | ||
| 177 | Named 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. | 179 | Named 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. |
| 178 | 180 | ||
| 179 | 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. | 181 | The 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. |
| 180 | 182 | ||
| 181 | When a command asks a question, a sheet opens: | 183 | When a command asks a question, a sheet opens: |
| 182 | 184 | ||
| @@ -397,11 +399,11 @@ The app icon's badge counts the entries in the agenda's Overdue section that are | |||
| 397 | 399 | ||
| 398 | * Export | 400 | * Export |
| 399 | 401 | ||
| 400 | Export (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. | 402 | Export (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. |
| 401 | 403 | ||
| 402 | PDF 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. | 404 | PDF 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. |
| 403 | 405 | ||
| 404 | Body 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. | 406 | Body 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. |
| 405 | 407 | ||
| 406 | The 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. | 408 | The 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. |
| 407 | 409 | ||
| @@ -438,7 +440,7 @@ The version you don't keep goes to the recovery folder. | |||
| 438 | 440 | ||
| 439 | Resolve 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. | 441 | Resolve 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. |
| 440 | 442 | ||
| 441 | Recovery 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. | 443 | Recovery 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. |
| 442 | 444 | ||
| 443 | See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work. | 445 | See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work. |
| 444 | 446 | ||