Commit 754eac2f33
Verified · cmc
Changed files (21)
- Sources/OrgApp/CommandRanking.swift +1 −1
- Sources/OrgApp/CommandTitles.swift +3
- Sources/OrgApp/Printing.swift added +270
- Sources/OrgApp/ProAccess.swift +2 −1
- Sources/OrgCore/Export/ExportScope.swift +11
- Sources/OrgEditorAppKit/EditorCommands.swift +3
- Sources/Orgstar/AgendaView.swift +21
- Sources/Orgstar/ContentView.swift +35 −1
- Sources/Orgstar/DevelopmentHooks.swift +2
- Sources/Orgstar/OrgstarApp.swift +21
- Sources/OrgstarMobile/AgendaScreen.swift +17
- Sources/OrgstarMobile/EditorScreen.swift +19 −1
- Sources/OrgstarMobile/ExportMenu.swift +36 −8
- Sources/OrgstarMobile/MobileEditor.swift +3
- Tests/OrgAppTests/PrintingTests.swift added +179
- docs/manual/guide/03-keys.org +4
- docs/manual/guide/04-outlines.org +1 −1
- docs/manual/guide/07-agenda.org +6
- docs/manual/guide/12-export.org +17 −1
- docs/manual/guide/14-ios.org +4 −2
- l10n/Localizable.xcstrings +207
Sources/OrgApp/CommandRanking.swift +1 −1 · view
| @@ -93,7 +93,7 @@ public enum CommandGroups { | ||
| 93 | 93 | /// The Org menu's groups and the app's commands outside the Org menu. |
| 94 | 94 | public static let commandList: [Group] = orgMenu + [ |
| 95 | 95 | Group(title: String(localized: "Clock", comment: "Commands list section"), prefixes: ["app.clock."]), |
| 96 | Group(title: String(localized: "Export", comment: "Commands list section"), prefixes: ["app.export", "app.copy-rich-text", "app.publish", "app.share-subtree"]), | |
| 96 | Group(title: String(localized: "Export", comment: "Commands list section"), prefixes: ["app.export", "app.copy-rich-text", "app.print", "app.publish", "app.share-subtree"]), | |
| 97 | 97 | Group(title: String(localized: "File", comment: "Commands list section"), prefixes: ["app.save", "app.word-count", "app.recovery", "app.sync-conflicts", "app.lint", "app.working-copy"]), |
| 98 | 98 | Group(title: String(localized: "Edit", comment: "Commands list section"), prefixes: ["edit.", "macro."]), |
| 99 | 99 | Group(title: String(localized: "View", comment: "Commands list section"), prefixes: ["app.toggle-markup", "editor.", "app.split-", "app.pane-"]), |
Sources/OrgApp/CommandTitles.swift +3 · view
| @@ -237,6 +237,9 @@ enum CommandTitles { | ||
| 237 | 237 | String(localized: "Previous TODO Keyword", comment: "Command title"), |
| 238 | 238 | String(localized: "Previous Table Field", comment: "Command title"), |
| 239 | 239 | String(localized: "Previous table.el Cell", comment: "Command title"), |
| 240 | String(localized: "Print Selection…", comment: "Command title"), | |
| 241 | String(localized: "Print Subtree…", comment: "Command title"), | |
| 242 | String(localized: "Print…", comment: "Command title"), | |
| 240 | 243 | String(localized: "Promote Heading", comment: "Command title"), |
| 241 | 244 | String(localized: "Promote Subtree", comment: "Command title"), |
| 242 | 245 | String(localized: "Property Action…", comment: "Command title"), |
Sources/OrgApp/Printing.swift added +270 · view
| @@ -0,0 +1,270 @@ | ||
| 1 | import Foundation | |
| 2 | import OrgCore | |
| 3 | import OrgPresentation | |
| 4 | import PDFKit | |
| 5 | #if os(macOS) | |
| 6 | import AppKit | |
| 7 | #else | |
| 8 | import UIKit | |
| 9 | #endif | |
| 10 | ||
| 11 | /// What Print… prints of an org file. | |
| 12 | public enum PrintScope: Sendable, Equatable { | |
| 13 | case file | |
| 14 | /// The subtree containing this offset, as Export Subtree exports it. | |
| 15 | case subtree(Int) | |
| 16 | /// The selected text, with the file's keywords. | |
| 17 | case selection(Range<Int>) | |
| 18 | } | |
| 19 | ||
| 20 | /// Printing: the page PDF export makes, with its margins, font and page numbers, through the | |
| 21 | /// system's print panel. A file's text comes from its buffer, as PDF export takes it, so an | |
| 22 | /// entry encrypted on disk prints as its message unless it was decrypted in the editor. The | |
| 23 | /// agenda prints as `AgendaPrint` lays it out. | |
| 24 | @MainActor | |
| 25 | public enum Printing { | |
| 26 | /// The commands that print an org file: `app.print`, `app.print-subtree`, `app.print-selection`. | |
| 27 | public static let commands = ["app.print", "app.print-subtree", "app.print-selection"] | |
| 28 | ||
| 29 | /// When set, jobs are saved to this PDF file without the panel, for checking from scripts. | |
| 30 | nonisolated(unsafe) public static var saveTo: URL? | |
| 31 | ||
| 32 | /// The page PDF export makes of `scope` of `text`, the buffer of the org file at `path`; nil | |
| 33 | /// before the first heading for a subtree, and for an empty selection. | |
| 34 | public static func page(_ text: String, path: String, scope: PrintScope, settings: OrgSettings, codeStyle: HTMLCodeStyle?, language: String) -> String? { | |
| 35 | let printed: String | |
| 36 | switch scope { | |
| 37 | case .file: | |
| 38 | printed = text | |
| 39 | case .subtree(let caret): | |
| 40 | guard let subtree = ExportScope.subtree(text, at: caret, settings: settings) else { return nil } | |
| 41 | printed = subtree | |
| 42 | case .selection(let range): | |
| 43 | guard !range.isEmpty else { return nil } | |
| 44 | printed = ExportScope.region(text, range, settings: settings) | |
| 45 | } | |
| 46 | let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension | |
| 47 | return HTMLExport.page(printed, fallbackTitle: base, settings: settings, path: path, codeStyle: codeStyle, language: language) | |
| 48 | } | |
| 49 | ||
| 50 | /// The job's name: the page's title. | |
| 51 | nonisolated static func title(_ html: String) -> String { | |
| 52 | guard let match = html.firstMatch(of: /<title>([^<]*)<\/title>/) else { return "" } | |
| 53 | return String(match.1).replacingOccurrences(of: "<", with: "<").replacingOccurrences(of: ">", with: ">") | |
| 54 | .replacingOccurrences(of: """, with: "\"").replacingOccurrences(of: "&", with: "&") | |
| 55 | } | |
| 56 | ||
| 57 | /// `html` laid out in pages as PDF export lays it out, then shown in the print panel. | |
| 58 | /// `directory` is where relative image links are read from. | |
| 59 | public static func show(html: String, directory: URL?) async throws { | |
| 60 | try await present(try await pages(html: html, directory: directory), title: title(html), saveTo: saveTo) | |
| 61 | } | |
| 62 | ||
| 63 | /// `html` as the pages PDF export makes, with the PDF settings. | |
| 64 | static func pages(html: String, directory: URL?) async throws -> Data { | |
| 65 | try await PDFExport.pdf(html: html, directory: directory, options: OrgPreferences.pdfOptions()) | |
| 66 | } | |
| 67 | ||
| 68 | #if os(macOS) | |
| 69 | /// The pages in the print panel, a sheet on the key window, with its paper size, orientation | |
| 70 | /// and preview; or, with `saveTo`, saved there without the panel. The pages already have | |
| 71 | /// their margins; the printer's own scales them to fit. | |
| 72 | static func present(_ data: Data, title: String, saveTo: URL?) async throws { | |
| 73 | guard let document = PDFDocument(data: data) else { throw PDFExport.Failure(description: "The pages couldn't be made.") } | |
| 74 | let info = (NSPrintInfo.shared.copy() as? NSPrintInfo) ?? NSPrintInfo() | |
| 75 | info.topMargin = 0 | |
| 76 | info.bottomMargin = 0 | |
| 77 | info.leftMargin = 0 | |
| 78 | info.rightMargin = 0 | |
| 79 | if let saveTo { | |
| 80 | info.jobDisposition = .save | |
| 81 | info.dictionary()[NSPrintInfo.AttributeKey.jobSavingURL] = saveTo | |
| 82 | } | |
| 83 | guard let operation = document.printOperation(for: info, scalingMode: .pageScaleDownToFit, autoRotate: true) else { | |
| 84 | throw PDFExport.Failure(description: "The pages couldn't be printed.") | |
| 85 | } | |
| 86 | operation.jobTitle = title | |
| 87 | operation.showsPrintPanel = saveTo == nil | |
| 88 | operation.printPanel.options.formUnion([.showsPaperSize, .showsOrientation, .showsScaling, .showsPreview]) | |
| 89 | // A sheet on the key window; saved without a panel, on a window never shown, as PDF | |
| 90 | // export renders its pages. | |
| 91 | let window = (saveTo == nil ? NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: \.isVisible) : nil) | |
| 92 | ?? NSWindow(contentRect: CGRect(x: 0, y: 0, width: 100, height: 100), styleMask: .borderless, backing: .buffered, defer: true) | |
| 93 | let done = Done() | |
| 94 | await withCheckedContinuation { continuation in | |
| 95 | done.continuation = continuation | |
| 96 | operation.runModal(for: window, delegate: done, didRun: #selector(Done.printOperationDidRun(_:success:contextInfo:)), contextInfo: nil) | |
| 97 | } | |
| 98 | } | |
| 99 | ||
| 100 | private final class Done: NSObject { | |
| 101 | var continuation: CheckedContinuation<Void, Never>? | |
| 102 | ||
| 103 | @objc func printOperationDidRun(_ operation: NSPrintOperation, success: Bool, contextInfo: UnsafeMutableRawPointer?) { | |
| 104 | continuation?.resume() | |
| 105 | continuation = nil | |
| 106 | } | |
| 107 | } | |
| 108 | #else | |
| 109 | /// The pages in the system's print sheet. | |
| 110 | static func present(_ data: Data, title: String, saveTo: URL?) async throws { | |
| 111 | let info = UIPrintInfo.printInfo() | |
| 112 | info.jobName = title | |
| 113 | info.outputType = .general | |
| 114 | let controller = UIPrintInteractionController.shared | |
| 115 | controller.printInfo = info | |
| 116 | controller.printingItem = data | |
| 117 | controller.present(animated: true) | |
| 118 | } | |
| 119 | #endif | |
| 120 | } | |
| 121 | ||
| 122 | /// The agenda as shown, as a page to print: the title, then each day's header with its overdue | |
| 123 | /// entries, rows and time grid, or the entries of a list view, or each block's. | |
| 124 | public enum AgendaPrint { | |
| 125 | public enum Part: Equatable, Sendable { | |
| 126 | /// A block's title. | |
| 127 | case heading(String) | |
| 128 | /// A day; `overdueShown` false leaves today's overdue entries folded, as the view can. | |
| 129 | case day(AgendaDayGroup, overdueShown: Bool) | |
| 130 | /// The entries of a TODO list, match or search. | |
| 131 | case entries([AgendaRow]) | |
| 132 | } | |
| 133 | ||
| 134 | /// The page for `parts` under `title`, with `subtitle` (the folders shown, the filter) below it. | |
| 135 | public static func page(title: String, subtitle: String? = nil, parts: [Part], today: Int, calendar: Calendar = .current, locale: Locale = .current) -> String { | |
| 136 | var body = "<h1 class=\"title\">\(escape(title))</h1>\n" | |
| 137 | if let subtitle, !subtitle.isEmpty { body += "<p class=\"subtitle\">\(escape(subtitle))</p>\n" } | |
| 138 | for part in parts { | |
| 139 | switch part { | |
| 140 | case .heading(let text): | |
| 141 | body += "<h2>\(escape(text))</h2>\n" | |
| 142 | case .day(let group, let overdueShown): | |
| 143 | body += "<h3\(group.isToday ? " class=\"today\"" : "")>\(escape(dayHeader(group, today: today, calendar: calendar, locale: locale)))</h3>\n" | |
| 144 | if group.isToday, !group.overdue.isEmpty { | |
| 145 | body += "<p class=\"overdue\">\(escape(String(localized: "Overdue", bundle: .main))) \(group.overdue.count)</p>\n" | |
| 146 | if overdueShown { body += table(group.overdue) } | |
| 147 | } | |
| 148 | if group.rows.isEmpty { | |
| 149 | body += "<p class=\"empty\">\(escape(String(localized: "Nothing scheduled", bundle: .main)))</p>\n" | |
| 150 | } else { | |
| 151 | // A page isn't live: no current-time line. | |
| 152 | body += table(group.lines(now: 0).compactMap { line -> Line? in | |
| 153 | switch line { | |
| 154 | case .row(let index): .row(group.rows[index]) | |
| 155 | case .grid(let time): .grid(time) | |
| 156 | case .now: nil | |
| 157 | } | |
| 158 | }) | |
| 159 | } | |
| 160 | case .entries(let rows): | |
| 161 | body += rows.isEmpty ? "<p class=\"empty\">\(escape(String(localized: "No entries", bundle: .main)))</p>\n" : table(rows, gutter: false) | |
| 162 | } | |
| 163 | } | |
| 164 | return """ | |
| 165 | <!DOCTYPE html> | |
| 166 | <html lang="\(escape(locale.language.languageCode?.identifier ?? "en"))"> | |
| 167 | <head> | |
| 168 | <meta charset="utf-8"> | |
| 169 | <title>\(escape(title))</title> | |
| 170 | <style> | |
| 171 | body { font-family: -apple-system, sans-serif; line-height: 1.35; } | |
| 172 | h1.title { font-size: 16pt; margin: 0 0 2pt; } | |
| 173 | p.subtitle { color: #666; margin: 0 0 8pt; } | |
| 174 | h2 { font-size: 13pt; margin: 14pt 0 4pt; } | |
| 175 | h3 { font-size: 11pt; margin: 12pt 0 4pt; padding-bottom: 2pt; border-bottom: 0.5pt solid #bbb; } | |
| 176 | h3.today { font-weight: 800; } | |
| 177 | p.overdue { color: #b00; font-weight: 600; margin: 4pt 0; } | |
| 178 | p.empty { color: #666; margin: 4pt 0; } | |
| 179 | table { border-collapse: collapse; width: 100%; } | |
| 180 | td { vertical-align: top; padding: 2pt 6pt 2pt 0; } | |
| 181 | td.gutter { width: 80pt; white-space: nowrap; color: #444; font-variant-numeric: tabular-nums; } | |
| 182 | tr.overdue td.gutter { color: #b00; } | |
| 183 | tr.done .title { color: #777; text-decoration: line-through; } | |
| 184 | tr.grid td { color: #999; font-size: 9pt; border-top: 0.5pt dashed #ccc; padding-top: 1pt; padding-bottom: 1pt; } | |
| 185 | .meta { color: #666; font-size: 9pt; } | |
| 186 | .todo { font-weight: 700; } | |
| 187 | </style> | |
| 188 | </head> | |
| 189 | <body> | |
| 190 | \(body)</body> | |
| 191 | </html> | |
| 192 | ||
| 193 | """ | |
| 194 | } | |
| 195 | ||
| 196 | private enum Line { | |
| 197 | case row(AgendaRow) | |
| 198 | case grid(Int) | |
| 199 | } | |
| 200 | ||
| 201 | private static func table(_ rows: [AgendaRow], gutter: Bool = true) -> String { | |
| 202 | table(rows.map(Line.row), gutter: gutter) | |
| 203 | } | |
| 204 | ||
| 205 | private static func table(_ lines: [Line], gutter: Bool = true) -> String { | |
| 206 | var html = "<table>\n" | |
| 207 | for line in lines { | |
| 208 | switch line { | |
| 209 | case .grid(let time): | |
| 210 | html += "<tr class=\"grid\"><td class=\"gutter\">\(String(format: "%02d:%02d", time / 100, time % 100))</td><td></td></tr>\n" | |
| 211 | case .row(let row): | |
| 212 | let classes = [row.status == .overdue ? "overdue" : nil, row.isDone ? "done" : nil].compactMap { $0 } | |
| 213 | html += "<tr\(classes.isEmpty ? "" : " class=\"\(classes.joined(separator: " "))\"")>" | |
| 214 | if gutter { html += "<td class=\"gutter\">\(row.gutterLines.map(escape).joined(separator: "<br>"))</td>" } | |
| 215 | html += "<td>\(entry(row))</td></tr>\n" | |
| 216 | } | |
| 217 | } | |
| 218 | return html + "</table>\n" | |
| 219 | } | |
| 220 | ||
| 221 | /// The category, detail, progress and tags over the TODO keyword, priority and title, as | |
| 222 | /// the view's rows have them. | |
| 223 | private static func entry(_ row: AgendaRow) -> String { | |
| 224 | let meta = [row.category, row.prefixDetail, row.progress, row.detail].compactMap { $0 }.filter { !$0.isEmpty } | |
| 225 | + (row.tags.isEmpty ? [] : [":" + row.tags.joined(separator: ":") + ":"]) | |
| 226 | var html = meta.isEmpty ? "" : "<div class=\"meta\">\(meta.map(escape).joined(separator: " · "))</div>" | |
| 227 | var title: [String] = [] | |
| 228 | if let todo = row.todo { title.append("<span class=\"todo\">\(escape(todo))</span>") } | |
| 229 | if let priority = row.priority { title.append("[#\(escape(priority))]") } | |
| 230 | title.append("<span class=\"title\">\(escape(row.title))</span>") | |
| 231 | html += "<div>\(title.joined(separator: " "))</div>" | |
| 232 | return html | |
| 233 | } | |
| 234 | ||
| 235 | /// `Today · Thursday 26 November 2026`. | |
| 236 | static func dayHeader(_ group: AgendaDayGroup, today: Int, calendar: Calendar, locale: Locale) -> String { | |
| 237 | let formatter = DateFormatter() | |
| 238 | formatter.locale = locale | |
| 239 | formatter.calendar = calendar | |
| 240 | formatter.timeZone = calendar.timeZone | |
| 241 | formatter.setLocalizedDateFormatFromTemplate("EEEEdMMMMy") | |
| 242 | let date = formatter.string(from: group.date(calendar: calendar)) | |
| 243 | return group.relativeName(today: today).map { $0 + " · " + date } ?? date | |
| 244 | } | |
| 245 | ||
| 246 | static func escape(_ s: String) -> String { | |
| 247 | s.replacingOccurrences(of: "&", with: "&").replacingOccurrences(of: "<", with: "<") | |
| 248 | .replacingOccurrences(of: ">", with: ">").replacingOccurrences(of: "\"", with: """) | |
| 249 | } | |
| 250 | } | |
| 251 | ||
| 252 | extension AgendaModel { | |
| 253 | /// What the view shows, as `AgendaPrint` lays it out: its days, its entries, or each block's | |
| 254 | /// title over its days or entries, with `filter` and empty days as the view has them. | |
| 255 | public func printParts(showAllDates: Bool, filter: AgendaFilter, overdueShown: Bool) -> [AgendaPrint.Part] { | |
| 256 | let rows = { (list: [AgendaItem]) in list.filter(filter.keeps).compactMap { AgendaRow(item: $0, day: self.today, today: self.today) } } | |
| 257 | switch mode { | |
| 258 | case .agenda: | |
| 259 | return groups(showAllDates: showAllDates, filter: filter).map { .day($0, overdueShown: overdueShown) } | |
| 260 | case .blocks: | |
| 261 | return blocks.flatMap { block -> [AgendaPrint.Part] in | |
| 262 | [.heading(block.header)] + (block.isAgenda | |
| 263 | ? groups(block, showAllDates: showAllDates, filter: filter).map { .day($0, overdueShown: overdueShown) } | |
| 264 | : [.entries(rows(block.list))]) | |
| 265 | } | |
| 266 | default: | |
| 267 | return [.entries(rows(list))] | |
| 268 | } | |
| 269 | } | |
| 270 | } | |
Sources/OrgApp/ProAccess.swift +2 −1 · view
| @@ -50,7 +50,8 @@ extension ProFeature { | ||
| 50 | 50 | /// Decrypting stays free so no one is locked out of their own text. |
| 51 | 51 | public static func required(byCommand id: String) -> ProFeature? { |
| 52 | 52 | switch id { |
| 53 | case "app.copy-rich-text": .export | |
| 53 | // The print panel saves PDFs. The agenda prints without orgstar+. | |
| 54 | case "app.copy-rich-text", "app.print", "app.print-subtree", "app.print-selection": .export | |
| 54 | 55 | case let id where id.hasPrefix("app.export."): required(byExport: String(id.dropFirst("app.export.".count))) |
| 55 | 56 | case let id where id.hasPrefix("app.publish"): .export |
| 56 | 57 | case "app.crypt.encrypt-entry", "app.crypt.encrypt-entries": .encryption |
Sources/OrgCore/Export/ExportScope.swift +11 · view
| @@ -56,6 +56,17 @@ public enum ExportScope { | ||
| 56 | 56 | return lines.joined(separator: "\n") + "\n" + body |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | /// The text in `range` as a document of its own, as Org exports the active region: the | |
| 60 | /// file's keyword lines before the first heading, then the region. Keyword lines inside the | |
| 61 | /// region aren't repeated. | |
| 62 | public static func region(_ text: String, _ range: Range<Int>, settings: OrgSettings = .default) -> String { | |
| 63 | let ns = text as NSString | |
| 64 | let start = min(max(0, range.lowerBound), ns.length) | |
| 65 | let selected = ns.substring(with: NSRange(location: start, length: min(range.count, ns.length - start))) | |
| 66 | let keywords = preamble(OrgParser.parse(text, defaults: settings)).filter { !selected.contains($0) } | |
| 67 | return keywords.isEmpty ? selected : keywords.joined(separator: "\n") + "\n" + selected | |
| 68 | } | |
| 69 | ||
| 59 | 70 | /// Keywords of the file that name it or its export, left out of a shared entry. |
| 60 | 71 | static let fileOnlyKeywords: Set<String> = ["TITLE", "SUBTITLE", "EXPORT_FILE_NAME"] |
| 61 | 72 | |
Sources/OrgEditorAppKit/EditorCommands.swift +3 · view
| @@ -201,6 +201,9 @@ public enum EditorCommands { | ||
| 201 | 201 | EditorCommand(id: "app.export.rtf", title: "Export to RTF", action: .app), |
| 202 | 202 | EditorCommand(id: "app.export.plain-text", title: "Export to Plain Text", action: .app), |
| 203 | 203 | EditorCommand(id: "app.copy-rich-text", title: "Copy as Rich Text", action: .app), |
| 204 | EditorCommand(id: "app.print", title: "Print…", action: .app), | |
| 205 | EditorCommand(id: "app.print-subtree", title: "Print Subtree…", action: .app), | |
| 206 | EditorCommand(id: "app.print-selection", title: "Print Selection…", action: .app), | |
| 204 | 207 | EditorCommand(id: "app.export.pdf", title: "Export to PDF with Emacs", action: .app), |
| 205 | 208 | EditorCommand(id: "app.export.odt", title: "Export to ODT", action: .app), |
| 206 | 209 | EditorCommand(id: "app.export.latex", title: "Export to LaTeX", action: .app), |
Sources/Orgstar/AgendaView.swift +21 · view
| @@ -373,6 +373,11 @@ struct AgendaView: View { | ||
| 373 | 373 | .onChange(of: commands.agendaRequest?.start, initial: true) { showRequestedDays() } |
| 374 | 374 | .onChange(of: commands.agendaRequest?.days) { showRequestedDays() } |
| 375 | 375 | .background { Refresher(base: refreshKey, session: session, workspace: workspace, refresh: refresh) } |
| 376 | .task(id: commands.agendaPrintRequested) { | |
| 377 | guard commands.agendaPrintRequested else { return } | |
| 378 | commands.agendaPrintRequested = false | |
| 379 | await printAgenda() | |
| 380 | } | |
| 376 | 381 | .task { |
| 377 | 382 | loadViews() |
| 378 | 383 | // The now line moves each minute; a new day refreshes the statuses. |
| @@ -385,6 +390,22 @@ struct AgendaView: View { | ||
| 385 | 390 | } |
| 386 | 391 | } |
| 387 | 392 | |
| 393 | /// File ▸ Print…: the agenda as it shows now, in the print panel, on pages laid out as PDF | |
| 394 | /// export lays them out. A window just opened to print computes the agenda first. | |
| 395 | private func printAgenda() async { | |
| 396 | if agenda.days.isEmpty, agenda.list.isEmpty, agenda.blocks.isEmpty { await refresh() } | |
| 397 | // A refresh started meanwhile replaces this one's days. | |
| 398 | while agenda.isComputing { try? await Task.sleep(for: .milliseconds(50)) } | |
| 399 | let subtitle = [isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : nil, shownFolders, | |
| 400 | filter.isEmpty ? nil : String(localized: "Filter: \(filter.description)")].compactMap { $0 }.joined(separator: " · ") | |
| 401 | let parts = agenda.printParts(showAllDates: showAllDates, filter: filter, overdueShown: overdueShown) | |
| 402 | do { | |
| 403 | try await Printing.show(html: AgendaPrint.page(title: title, subtitle: subtitle, parts: parts, today: agenda.today), directory: nil) | |
| 404 | } catch { | |
| 405 | message = String(localized: "Can't print: \(String(describing: error))") | |
| 406 | } | |
| 407 | } | |
| 408 | ||
| 388 | 409 | // MARK: - Days |
| 389 | 410 | |
| 390 | 411 | private var todayColor: Color { theme.color("agenda-today") ?? .accentColor } |
Sources/Orgstar/ContentView.swift +35 −1 · view
| @@ -646,6 +646,35 @@ struct ContentView: View { | ||
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | /// Print…, Print Subtree… and Print Selection…: the page PDF export makes of the file, the | |
| 650 | /// subtree at the caret or the selection, in the print panel. | |
| 651 | private func printFile(_ id: String) { | |
| 652 | guard let path = session.path, let text = session.document?.text, let editor = commands.editor else { return commands.show(String(localized: "No file is open")) } | |
| 653 | guard readsIncludes(text, path: path) else { return } | |
| 654 | let context = editor.context() | |
| 655 | let scope: PrintScope | |
| 656 | switch id { | |
| 657 | case "app.print-subtree": scope = .subtree(context.caret) | |
| 658 | case "app.print-selection": | |
| 659 | guard let selection = context.selection.first(where: { !$0.isEmpty }) else { return commands.show(String(localized: "No text is selected")) } | |
| 660 | scope = .selection(selection) | |
| 661 | default: scope = .file | |
| 662 | } | |
| 663 | let defaults = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile) | |
| 664 | guard let html = Printing.page(text, path: path, scope: scope, settings: defaults, codeStyle: HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme), | |
| 665 | language: OrgPreferences.exportLanguage()) else { return commands.show(String(localized: "Not in a subtree")) } | |
| 666 | let directory = URL(fileURLWithPath: path).deletingLastPathComponent() | |
| 667 | // Images that can't be read are left out, so offer access to them first. | |
| 668 | _ = reach(PDFExport.imageFiles(html, directory: directory).filter(WorkspaceModel.isThere)) | |
| 669 | Task { | |
| 670 | do { | |
| 671 | try await Printing.show(html: html, directory: directory) | |
| 672 | } catch { | |
| 673 | commands.show(String(localized: "Can't print: \(String(describing: error))")) | |
| 674 | } | |
| 675 | } | |
| 676 | } | |
| 677 | ||
| 649 | 678 | /// Whether the caret is in a heading's subtree, which the export dialog can export alone. |
| 650 | 679 | private var exportSubtreeAvailable: Bool { |
| 651 | 680 | guard let text = session.document?.text, let caret = commands.editor?.context().caret else { return false } |
| @@ -1357,7 +1386,7 @@ struct ContentView: View { | ||
| 1357 | 1386 | return commands.show(Self.unavailable(EditorCommands.all.first { $0.id == id }?.title ?? id)) |
| 1358 | 1387 | } |
| 1359 | 1388 | if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return } |
| 1360 | let orgOnly = ["app.refile", "app.refile.copy", "app.archive", "app.clock.in", "app.clock.default", "app.copy-rich-text", "app.export-subtree", "app.export-body-only", "app.share-subtree"].contains(id) || (id.hasPrefix("app.export.") && !id.hasPrefix("app.export.icalendar-")) || id.hasPrefix("org.") | |
| 1389 | let orgOnly = ["app.refile", "app.refile.copy", "app.archive", "app.clock.in", "app.clock.default", "app.copy-rich-text", "app.export-subtree", "app.export-body-only", "app.share-subtree"].contains(id) || Printing.commands.contains(id) || (id.hasPrefix("app.export.") && !id.hasPrefix("app.export.icalendar-")) || id.hasPrefix("org.") | |
| 1361 | 1390 | if orgOnly, !session.isOrg { |
| 1362 | 1391 | commands.show(String(localized: "Not an org file")) |
| 1363 | 1392 | return |
| @@ -1561,6 +1590,11 @@ struct ContentView: View { | ||
| 1561 | 1590 | openWindow(id: "lint-folders") |
| 1562 | 1591 | case "app.copy-rich-text": |
| 1563 | 1592 | copyRichText() |
| 1593 | case "app.print", "app.print-subtree", "app.print-selection": | |
| 1594 | printFile(id) | |
| 1595 | case "app.print-agenda": | |
| 1596 | commands.agendaPrintRequested = true | |
| 1597 | openWindow(id: "agenda") | |
| 1564 | 1598 | case "app.share-subtree": |
| 1565 | 1599 | guard let path = session.path else { return commands.show(String(localized: "No file is open")) } |
| 1566 | 1600 | if let refusal = session.refusesSubtreeShare(path, at: session.caret) { return commands.show(refusal) } |
Sources/Orgstar/DevelopmentHooks.swift +2 · view
| @@ -15,6 +15,7 @@ import OrgEditorAppKit | ||
| 15 | 15 | /// - `ORGSTAR_PASTEBOARD`: the name of a pasteboard to paste images and files from, instead of |
| 16 | 16 | /// the clipboard. |
| 17 | 17 | /// - `ORGSTAR_APPEARANCE`: `dark` or `light`, instead of the system's. |
| 18 | /// - `ORGSTAR_PRINT_TO`: print jobs are saved to this PDF path without the print panel. | |
| 18 | 19 | /// - `ORGSTAR_SNAPSHOT`: after `ORGSTAR_SNAPSHOT_DELAY` seconds (default 3), render the main |
| 19 | 20 | /// window to this PNG path and quit. Rendering from inside the app needs no screen-recording |
| 20 | 21 | /// permission. |
| @@ -27,6 +28,7 @@ enum DevelopmentHooks { | ||
| 27 | 28 | static var urlToOpen: String? { ProcessInfo.processInfo.environment["ORGSTAR_URL"] } |
| 28 | 29 | /// `ORGSTAR_SNAPSHOT` is set: the run renders a window and quits. |
| 29 | 30 | static var snapshotting: Bool { ProcessInfo.processInfo.environment["ORGSTAR_SNAPSHOT"] != nil } |
| 31 | static var printTo: URL? { ProcessInfo.processInfo.environment["ORGSTAR_PRINT_TO"].map { URL(fileURLWithPath: $0) } } | |
| 30 | 32 | static var answers: [String] { ProcessInfo.processInfo.environment["ORGSTAR_ANSWERS"]?.split(separator: ",").map(String.init) ?? [] } |
| 31 | 33 | |
| 32 | 34 | @MainActor |
Sources/Orgstar/OrgstarApp.swift +21 · view
| @@ -34,6 +34,8 @@ final class AppCommands { | ||
| 34 | 34 | private var jumpID = 0 |
| 35 | 35 | /// Days the agenda window should show, from a followed timestamp. |
| 36 | 36 | var agendaRequest: (start: Int, days: Int)? |
| 37 | /// File ▸ Print… with the agenda window in front: the agenda window prints what it shows. | |
| 38 | var agendaPrintRequested = false | |
| 37 | 39 | /// The editor with focus, for menus and the palette. |
| 38 | 40 | var editor: OrgEditor? |
| 39 | 41 | /// The editors and text views of every pane in every window. |
| @@ -513,6 +515,9 @@ struct OrgstarApp: App { | ||
| 513 | 515 | |
| 514 | 516 | init() { |
| 515 | 517 | PDFExport.mathJaxURL = OrgMathJax.script |
| 518 | #if !APPSTORE | |
| 519 | Printing.saveTo = DevelopmentHooks.printTo | |
| 520 | #endif | |
| 516 | 521 | DiagramBlocks.vizURL = OrgMathJax.viz |
| 517 | 522 | DiagramBlocks.mermaidURL = OrgMathJax.mermaid |
| 518 | 523 | #if APPSTORE |
| @@ -671,6 +676,22 @@ struct OrgstarApp: App { | ||
| 671 | 676 | .keyboardShortcut("s", modifiers: [.command, .option]) |
| 672 | 677 | .disabled(session.dirtyPaths.isEmpty) |
| 673 | 678 | } |
| 679 | CommandGroup(replacing: .printItem) { | |
| 680 | Button("Page Setup…") { NSPageLayout().runModal() } | |
| 681 | // ⌘P is Quick Open. | |
| 682 | Button("Print…") { | |
| 683 | if NSApp.keyWindow?.identifier?.rawValue.contains("agenda") == true { | |
| 684 | commands.agendaPrintRequested = true | |
| 685 | } else { | |
| 686 | commands.run("app.print") | |
| 687 | } | |
| 688 | } | |
| 689 | .keyboardShortcut("p", modifiers: [.command, .option]) | |
| 690 | Button("Print Subtree…") { commands.run("app.print-subtree") } | |
| 691 | .disabled(!session.isOrg) | |
| 692 | Button("Print Selection…") { commands.run("app.print-selection") } | |
| 693 | .disabled(!session.isOrg) | |
| 694 | } | |
| 674 | 695 | CommandGroup(after: .sidebar) { |
| 675 | 696 | Button("Split Pane Below") { commands.run("app.split-below") } |
| 676 | 697 | .keyboardShortcut("2", modifiers: [.command, .control]) |
Sources/OrgstarMobile/AgendaScreen.swift +17 · view
| @@ -218,6 +218,7 @@ struct AgendaScreen: View, Equatable { | ||
| 218 | 218 | Button("Select", systemImage: "checkmark.circle") { selecting = true } |
| 219 | 219 | Divider() |
| 220 | 220 | Button("Board", systemImage: "rectangle.split.3x1") { showingBoard = true } |
| 221 | Button("Print…", systemImage: "printer") { printAgenda() } | |
| 221 | 222 | } label: { |
| 222 | 223 | Label("Views", systemImage: "list.bullet.rectangle") |
| 223 | 224 | } |
| @@ -636,6 +637,7 @@ struct AgendaScreen: View, Equatable { | ||
| 636 | 637 | CommandRow(id: "agenda.filter", title: String(localized: "Filter…")), |
| 637 | 638 | CommandRow(id: "agenda.select", title: String(localized: "Select")), |
| 638 | 639 | CommandRow(id: "agenda.board", title: CommandTitle.localized("Board")), |
| 640 | CommandRow(id: "agenda.print", title: CommandTitle.localized("Print…")), | |
| 639 | 641 | CommandRow(id: "app.capture", title: CommandTitle.localized("Capture…")), |
| 640 | 642 | ] |
| 641 | 643 | return rows + MobileClock.screenCommands.map { CommandRow(id: $0.id, title: CommandTitle.localized($0.title)) } |
| @@ -656,11 +658,26 @@ struct AgendaScreen: View, Equatable { | ||
| 656 | 658 | case "agenda.filter": showingFilter = true |
| 657 | 659 | case "agenda.select": selecting = true |
| 658 | 660 | case "agenda.board": showingBoard = true |
| 661 | case "agenda.print": printAgenda() | |
| 659 | 662 | case "app.capture": model.captureRequest = CaptureRequest() |
| 660 | 663 | default: _ = MobileClock.run(id, model: model, workspace: workspace) { message = $0 } |
| 661 | 664 | } |
| 662 | 665 | } |
| 663 | 666 | |
| 667 | /// Print…: the agenda as shown, in the print sheet, on pages laid out as PDF export lays them out. | |
| 668 | private func printAgenda() { | |
| 669 | let parts = agenda.printParts(showAllDates: OrgPreferences.agendaShowAllDates(), filter: filter, overdueShown: overdueExpanded) | |
| 670 | let subtitle = [shownFolders, filter.isEmpty ? nil : String(localized: "Filter: \(filter.description)")].compactMap { $0 }.joined(separator: " · ") | |
| 671 | let html = AgendaPrint.page(title: title, subtitle: subtitle, parts: parts, today: agenda.today) | |
| 672 | Task { | |
| 673 | do { | |
| 674 | try await Printing.show(html: html, directory: nil) | |
| 675 | } catch { | |
| 676 | message = String(localized: "Can't print: \(String(describing: error))") | |
| 677 | } | |
| 678 | } | |
| 679 | } | |
| 680 | ||
| 664 | 681 | private func jump(to day: Int) { |
| 665 | 682 | show(range, around: day) |
| 666 | 683 | } |
Sources/OrgstarMobile/EditorScreen.swift +19 −1 · view
| @@ -517,6 +517,8 @@ struct EditorScreen: View { | ||
| 517 | 517 | sheet = .export |
| 518 | 518 | } else if id == EditorScreen.exportSubtreeCommand { |
| 519 | 519 | exportSubtree() |
| 520 | } else if Printing.commands.contains(id) { | |
| 521 | printFile(id) | |
| 520 | 522 | } else if id == "app.share-subtree" { |
| 521 | 523 | if let caret = self.editor?.editContext().caret, let refusal = session.refusesSubtreeShare(path, at: caret) { |
| 522 | 524 | message = refusal |
| @@ -712,6 +714,20 @@ extension EditorScreen { | ||
| 712 | 714 | sheet = .exportSubtree(context.caret) |
| 713 | 715 | } |
| 714 | 716 | |
| 717 | /// Print…, Print Subtree… and Print Selection…, from Commands. | |
| 718 | private func printFile(_ id: String) { | |
| 719 | guard let context = editor?.editContext() else { return } | |
| 720 | let scope: PrintScope | |
| 721 | switch id { | |
| 722 | case "app.print-subtree": scope = .subtree(context.caret) | |
| 723 | case "app.print-selection": | |
| 724 | guard let selection = context.selection.first(where: { !$0.isEmpty }) else { return message = String(localized: "No text is selected") } | |
| 725 | scope = .selection(selection) | |
| 726 | default: scope = .file | |
| 727 | } | |
| 728 | ExportItems.startPrinting(path: path, text: context.text, scope: scope, theme: model.theme) { message = $0 } | |
| 729 | } | |
| 730 | ||
| 715 | 731 | /// `org-html-export-to-html` and open: the page in Quick Look, from a temporary file. |
| 716 | 732 | private func exportHTMLAndOpen() { |
| 717 | 733 | guard let text = session.document(of: path)?.text else { return } |
| @@ -1220,7 +1236,9 @@ struct CommandPalette: View { | ||
| 1220 | 1236 | switch id { |
| 1221 | 1237 | case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions") |
| 1222 | 1238 | 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") |
| 1223 | case EditorScreen.exportSubtreeCommand, "app.share-subtree": | |
| 1239 | case "app.print-selection": | |
| 1240 | return context.selection.contains { !$0.isEmpty } ? nil : String(localized: "No text is selected") | |
| 1241 | case EditorScreen.exportSubtreeCommand, "app.share-subtree", "app.print-subtree": | |
| 1224 | 1242 | 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") |
| 1225 | 1243 | default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context) |
| 1226 | 1244 | } |
Sources/OrgstarMobile/ExportMenu.swift +36 −8 · view
| @@ -227,6 +227,11 @@ struct ExportItems: View { | ||
| 227 | 227 | if let exportSubtree { |
| 228 | 228 | Button("Export Subtree…", systemImage: "list.bullet.indent") { exportSubtree() } |
| 229 | 229 | } |
| 230 | if OrgExport.Format.pdf.locked { | |
| 231 | Button("\(String(localized: "Print…")) (orgstar+)", systemImage: "printer") { ProAccess.shared.allows(.export) } | |
| 232 | } else { | |
| 233 | Button("Print…", systemImage: "printer") { Self.startPrinting(path: path, text: text, scope: .file, theme: model.theme, report: report) } | |
| 234 | } | |
| 230 | 235 | if let calendars = AgendaCalendars(model: model) { |
| 231 | 236 | if dividers { Divider() } |
| 232 | 237 | if OrgExport.Format.icalendar.locked { |
| @@ -254,6 +259,22 @@ struct ExportItems: View { | ||
| 254 | 259 | settings.save(for: path) |
| 255 | 260 | } |
| 256 | 261 | |
| 262 | /// Print…: the page PDF export makes of `scope` of `text`, the buffer of the file at `path`, | |
| 263 | /// in the print sheet. `report` gets the reason it can't print. | |
| 264 | @MainActor | |
| 265 | static func startPrinting(path: String, text: String, scope: PrintScope, theme: ThemeSpec, report: @escaping (String) -> Void) { | |
| 266 | let settings = OrgPreferences.orgSettings().resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile) | |
| 267 | guard let html = Printing.page(text, path: path, scope: scope, settings: settings, codeStyle: HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: theme), | |
| 268 | language: OrgPreferences.exportLanguage()) else { return report(String(localized: "Not in a subtree")) } | |
| 269 | Task { | |
| 270 | do { | |
| 271 | try await Printing.show(html: html, directory: URL(fileURLWithPath: path).deletingLastPathComponent()) | |
| 272 | } catch { | |
| 273 | report(String(localized: "Can't print: \(String(describing: error))")) | |
| 274 | } | |
| 275 | } | |
| 276 | } | |
| 277 | ||
| 257 | 278 | /// The file on the clipboard as HTML, RTF and plain text, to paste formatted. Returns a message. |
| 258 | 279 | @MainActor |
| 259 | 280 | static func copy(path: String, text: String, theme: ThemeSpec) -> String { |
| @@ -327,14 +348,21 @@ struct SubtreeExportScreen: View { | ||
| 327 | 348 | NavigationStack { |
| 328 | 349 | let bodyOnly = ExportSettings.saved(for: path).bodyOnly |
| 329 | 350 | let name = ExportScope.fileName(tree, subtreeAt: caret, settings: OrgPreferences.orgSettings()) |
| 330 | List(OrgExport.Format.allCases.filter { !$0.locked }, id: \.self) { format in | |
| 331 | if bodyOnly, !format.allowsBodyOnly { | |
| 332 | LabeledContent(format.name) { Text("No body-only export") }.foregroundStyle(.secondary) | |
| 333 | } else { | |
| 334 | let export = OrgExport(text: tree.text, path: path, format: format, settings: OrgPreferences.orgSettings(), | |
| 335 | codeStyle: HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: model.theme), name: name, | |
| 336 | subtree: caret, bodyOnly: bodyOnly) | |
| 337 | ShareLink(item: export, preview: SharePreview(export.fileName)) { Text(format.name) } | |
| 351 | List { | |
| 352 | ForEach(OrgExport.Format.allCases.filter { !$0.locked }, id: \.self) { format in | |
| 353 | if bodyOnly, !format.allowsBodyOnly { | |
| 354 | LabeledContent(format.name) { Text("No body-only export") }.foregroundStyle(.secondary) | |
| 355 | } else { | |
| 356 | let export = OrgExport(text: tree.text, path: path, format: format, settings: OrgPreferences.orgSettings(), | |
| 357 | codeStyle: HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: model.theme), name: name, | |
| 358 | subtree: caret, bodyOnly: bodyOnly) | |
| 359 | ShareLink(item: export, preview: SharePreview(export.fileName)) { Text(format.name) } | |
| 360 | } | |
| 361 | } | |
| 362 | if !OrgExport.Format.pdf.locked { | |
| 363 | Button("Print…", systemImage: "printer") { | |
| 364 | ExportItems.startPrinting(path: path, text: tree.text, scope: .subtree(caret), theme: model.theme) { _ in } | |
| 365 | } | |
| 338 | 366 | } |
| 339 | 367 | } |
| 340 | 368 | .navigationTitle("Export Subtree") |
Sources/OrgstarMobile/MobileEditor.swift +3 · view
| @@ -512,6 +512,9 @@ final class MobileEditor: NSObject, DocumentBuffer { | ||
| 512 | 512 | case _ where id.hasPrefix(NamedMacros.commandPrefix): return true |
| 513 | 513 | case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil |
| 514 | 514 | case "app.export-dialog", "app.export-subtree-dialog", "app.share-subtree", "app.copy-rich-text", "app.export.html-open", "app.export-body-only", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil |
| 515 | case "app.print": return onAppCommand != nil | |
| 516 | case "app.print-subtree": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil | |
| 517 | case "app.print-selection": return onAppCommand != nil && context.selection.contains { !$0.isEmpty } | |
| 515 | 518 | case _ where id.hasPrefix("app.publish"): return onAppCommand != nil |
| 516 | 519 | case "app.working-copy.sync", "app.cite.insert": return onAppCommand != nil |
| 517 | 520 | case _ where Self.linkCommands.contains(id): return onAppCommand != nil |
Tests/OrgAppTests/PrintingTests.swift added +179 · view
| @@ -0,0 +1,179 @@ | ||
| 1 | import Foundation | |
| 2 | import OrgCore | |
| 3 | import OrgDocument | |
| 4 | import OrgMathJax | |
| 5 | import PDFKit | |
| 6 | import Testing | |
| 7 | @testable import OrgApp | |
| 8 | ||
| 9 | /// What Print… sends to the printer: the page PDF export makes of the file, the subtree or the | |
| 10 | /// selection, and the agenda as shown. | |
| 11 | @MainActor | |
| 12 | struct PrintingTests { | |
| 13 | init() { PDFExport.mathJaxURL = OrgMathJax.script } | |
| 14 | ||
| 15 | static let text = "#+TITLE: Notes\n* One\nFirst body.\n** Inner\nInner body.\n* Two\nSecond body.\n" | |
| 16 | ||
| 17 | func page(_ scope: PrintScope, text: String = Self.text) -> String? { | |
| 18 | Printing.page(text, path: "/notes/a.org", scope: scope, settings: .default, codeStyle: nil, language: "en") | |
| 19 | } | |
| 20 | ||
| 21 | func offset(of needle: String, in text: String = Self.text) -> Int { (text as NSString).range(of: needle).location } | |
| 22 | ||
| 23 | @Test func eachScope() throws { | |
| 24 | let file = try #require(page(.file)) | |
| 25 | #expect(file.contains("<title>Notes</title>") && file.contains("First body.") && file.contains("Second body.")) | |
| 26 | #expect(file == HTMLExport.page(Self.text, fallbackTitle: "a", settings: .default, path: "/notes/a.org", language: "en")) | |
| 27 | ||
| 28 | // As Export Subtree: the heading is the title, its children promoted. | |
| 29 | let subtree = try #require(page(.subtree(offset(of: "First body.")))) | |
| 30 | #expect(subtree.contains("<title>One</title>") && subtree.contains("Inner body.")) | |
| 31 | #expect(!subtree.contains("Second body.")) | |
| 32 | #expect(page(.subtree(0)) == nil) | |
| 33 | ||
| 34 | // The selection with the file's keywords. | |
| 35 | let start = offset(of: "Second body.") | |
| 36 | let selection = try #require(page(.selection(start..<(start + 6)))) | |
| 37 | #expect(selection.contains("<title>Notes</title>") && selection.contains("Second")) | |
| 38 | #expect(!selection.contains("Second body.") && !selection.contains("First body.")) | |
| 39 | #expect(page(.selection(start..<start)) == nil) | |
| 40 | } | |
| 41 | ||
| 42 | @Test func regionKeepsTheFileKeywordsOnce() { | |
| 43 | #expect(ExportScope.region(Self.text, 0..<15) == "#+TITLE: Notes\n") | |
| 44 | let start = offset(of: "* Two") | |
| 45 | #expect(ExportScope.region(Self.text, start..<(start + 5)) == "#+TITLE: Notes\n* Two") | |
| 46 | #expect(ExportScope.region("* A\nbody\n", 4..<8) == "body") | |
| 47 | } | |
| 48 | ||
| 49 | /// The pages the print panel gets: PDF export's layout, with page numbers. The print | |
| 50 | /// operation itself isn't run here: it stops the test process's main run loop. | |
| 51 | @Test func printsThePDFExportPages() async throws { | |
| 52 | let html = try #require(page(.subtree(offset(of: "First body.")))) | |
| 53 | let document = try #require(PDFDocument(data: try await Printing.pages(html: html, directory: nil))) | |
| 54 | let text = document.string ?? "" | |
| 55 | #expect(text.contains("One") && text.contains("Inner body.")) | |
| 56 | #expect(!text.contains("Second body.")) | |
| 57 | #expect(document.page(at: 0)?.annotations.first { $0.type == "FreeText" }?.contents == "1") | |
| 58 | #expect(Printing.title(html) == "One") | |
| 59 | } | |
| 60 | ||
| 61 | /// Printing a file needs orgstar+ as PDF export does, since the print panel saves PDFs; the | |
| 62 | /// agenda prints without it. | |
| 63 | @Test func gating() { | |
| 64 | for id in Printing.commands { #expect(ProFeature.required(byCommand: id) == .export) } | |
| 65 | #expect(ProFeature.required(byCommand: "app.print-agenda") == nil) | |
| 66 | let access = ProAccess(defaults: TestDefaults("orgstar-printing")) | |
| 67 | #expect(!access.allows(ProFeature.required(byCommand: "app.print")!)) | |
| 68 | #expect(access.paywall == .export) | |
| 69 | } | |
| 70 | ||
| 71 | /// An entry encrypted on disk prints as its message, as PDF export exports it, until it's | |
| 72 | /// decrypted in the editor. | |
| 73 | @Test func encryptedEntriesPrintOnlyOnceDecrypted() throws { | |
| 74 | let secret = "Account 12345" | |
| 75 | let plain = "* Plain\nOpen text.\n* Bank :crypt:\n\(secret)\n* Last\n" | |
| 76 | let encrypted = try #require(try OrgCrypt.encrypt(plain, at: offset(of: "* Bank", in: plain), passphrase: "pw")) | |
| 77 | let notes = try Folder() | |
| 78 | let file = try notes.write("a.org", encrypted) | |
| 79 | let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".recovery"))) | |
| 80 | session.saveMode = .explicit | |
| 81 | session.encryptsTaggedEntries = true | |
| 82 | session.passphrases = FakeKeychain.passphrases(.undecided).passphrases | |
| 83 | session.open(file.path) | |
| 84 | let text = try #require(session.document?.text) | |
| 85 | let bank = offset(of: "* Bank", in: text) | |
| 86 | for scope in [PrintScope.file, .subtree(bank), .selection(0..<(text as NSString).length)] { | |
| 87 | let html = try #require(page(scope, text: text)) | |
| 88 | #expect(!html.contains(secret)) | |
| 89 | #expect(html.contains("Bank")) | |
| 90 | } | |
| 91 | ||
| 92 | let buffer = StateBuffer(try #require(session.document)) | |
| 93 | session.attach(buffer) | |
| 94 | let decrypted = try OrgCrypt.decryptInPlace(text, at: bank, passphrase: "pw") | |
| 95 | try buffer.update { try $0.apply([TextEdit(range: 0..<($0.text as NSString).length, replacement: decrypted)], baseRevision: $0.revision) } | |
| 96 | session.bufferChanged() | |
| 97 | let shown = try #require(session.document?.text) | |
| 98 | #expect(try #require(page(.file, text: shown)).contains(secret)) | |
| 99 | #expect(try #require(page(.subtree(offset(of: "* Bank", in: shown)), text: shown)).contains(secret)) | |
| 100 | } | |
| 101 | ||
| 102 | // MARK: - Agenda | |
| 103 | ||
| 104 | static let calendar: Calendar = { | |
| 105 | var calendar = Calendar(identifier: .gregorian) | |
| 106 | calendar.timeZone = TimeZone(identifier: "UTC")! | |
| 107 | return calendar | |
| 108 | }() | |
| 109 | static let now = calendar.date(from: DateComponents(year: 2026, month: 11, day: 26, hour: 8))! | |
| 110 | ||
| 111 | func agenda(_ mode: AgendaMode) async throws -> (AgendaModel, Folder) { | |
| 112 | let notes = try Folder() | |
| 113 | try notes.write("work.org", """ | |
| 114 | * TODO Call the bank :phone: | |
| 115 | SCHEDULED: <2026-11-26 Thu 09:00> | |
| 116 | * TODO [#A] Send the report | |
| 117 | DEADLINE: <2026-11-20 Fri> | |
| 118 | * DONE Filed | |
| 119 | CLOSED: [2026-11-25 Wed 10:00] | |
| 120 | * TODO Read <b>this</b> | |
| 121 | SCHEDULED: <2026-11-27 Fri> | |
| 122 | ||
| 123 | """) | |
| 124 | let workspace = try WorkspaceModel(directory: nil) | |
| 125 | try await workspace.addRoot(notes.url) | |
| 126 | let agenda = AgendaModel(workspace: workspace) | |
| 127 | agenda.mode = mode | |
| 128 | await agenda.refresh(open: [:], now: Self.now, calendar: Self.calendar) | |
| 129 | return (agenda, notes) | |
| 130 | } | |
| 131 | ||
| 132 | func page(_ agenda: AgendaModel, filter: AgendaFilter = AgendaFilter(), overdueShown: Bool = true, showAllDates: Bool = false) -> String { | |
| 133 | AgendaPrint.page(title: "Agenda", subtitle: "work", parts: agenda.printParts(showAllDates: showAllDates, filter: filter, overdueShown: overdueShown), | |
| 134 | today: agenda.today, calendar: Self.calendar, locale: Locale(identifier: "en_US")) | |
| 135 | } | |
| 136 | ||
| 137 | @Test func agendaDaysAsShown() async throws { | |
| 138 | let (agenda, notes) = try await agenda(.agenda(span: 2, startOffset: nil)) | |
| 139 | _ = notes | |
| 140 | let html = page(agenda) | |
| 141 | #expect(html.contains("<title>Agenda</title>") && html.contains("<p class=\"subtitle\">work</p>")) | |
| 142 | #expect(html.contains("Today · Thursday, November 26, 2026") && html.contains("Tomorrow · Friday, November 27, 2026")) | |
| 143 | #expect(html.contains("<span class=\"todo\">TODO</span> <span class=\"title\">Call the bank</span>")) | |
| 144 | #expect(html.contains("09:00") && html.contains("work · :phone:")) | |
| 145 | #expect(html.contains("<p class=\"overdue\">Overdue 1</p>") && html.contains("[#A] <span class=\"title\">Send the report</span>")) | |
| 146 | // Escaped, not markup. | |
| 147 | #expect(html.contains("Read <b>this</b>")) | |
| 148 | // Folded overdue entries stay folded; a filter leaves out what it hides. | |
| 149 | let folded = page(agenda, overdueShown: false) | |
| 150 | #expect(folded.contains("Overdue 1") && !folded.contains("Send the report")) | |
| 151 | var filter = AgendaFilter() | |
| 152 | filter.tags = ["-phone"] | |
| 153 | #expect(!page(agenda, filter: filter).contains("Call the bank")) | |
| 154 | } | |
| 155 | ||
| 156 | @Test func agendaListsAndEmptyDays() async throws { | |
| 157 | let (list, notes) = try await agenda(.todo(keywords: nil)) | |
| 158 | _ = notes | |
| 159 | let html = page(list) | |
| 160 | #expect(html.contains("Call the bank") && html.contains("Send the report") && !html.contains("Filed")) | |
| 161 | #expect(!html.contains("class=\"gutter\"")) | |
| 162 | var none = AgendaFilter() | |
| 163 | none.tags = ["+nothing"] | |
| 164 | #expect(page(list, filter: none).contains("No entries")) | |
| 165 | ||
| 166 | let (days, more) = try await agenda(.agenda(span: 1, startOffset: 3)) | |
| 167 | _ = more | |
| 168 | #expect(!page(days).contains("<h3")) | |
| 169 | #expect(page(days, showAllDates: true).contains("Sunday, November 29, 2026</h3>\n<p class=\"empty\">Nothing scheduled</p>")) | |
| 170 | } | |
| 171 | ||
| 172 | /// The agenda's page goes through the same pages as a file's. | |
| 173 | @Test func agendaPrintsAsPages() async throws { | |
| 174 | let (agenda, notes) = try await agenda(.agenda(span: 2, startOffset: nil)) | |
| 175 | _ = notes | |
| 176 | let text = try #require(PDFDocument(data: try await Printing.pages(html: page(agenda), directory: nil))).string ?? "" | |
| 177 | #expect(text.contains("Call the bank") && text.contains("Send the report")) | |
| 178 | } | |
| 179 | } | |
docs/manual/guide/03-keys.org +4 · view
| @@ -116,6 +116,7 @@ These come from the menu bar and work in every preset. In the Doom preset, keys | ||
| 116 | 116 | | File | Close Window | =⇧⌘W= | |
| 117 | 117 | | File | Save | =⌘S= | |
| 118 | 118 | | File | Save All | =⌥⌘S= | |
| 119 | | File | Print… (in the agenda window, prints the agenda) | =⌥⌘P= | | |
| 119 | 120 | | Edit ▸ Find | Find… | =⌘F= | |
| 120 | 121 | | Edit ▸ Find | Find and Replace… | =⌥⌘F= | |
| 121 | 122 | | Edit ▸ Find | Find Next | =⌘G= | |
| @@ -1069,6 +1070,9 @@ When a key appears in several rows, it runs the command whose condition holds at | ||
| 1069 | 1070 | | Export to RTF (=app.export.rtf=) | — | — | — | Exports to Rich Text Format. | |
| 1070 | 1071 | | Export to Plain Text (=app.export.plain-text=) | — | — | — | Exports the text without styles, without Emacs. | |
| 1071 | 1072 | | Copy as Rich Text (=app.copy-rich-text=) | — | — | — | Copies the selection, or the file, as HTML, RTF and plain text. | |
| 1073 | | Print… (=app.print=) | — | — | — | Prints the file, laid out as Export to PDF. File ▸ Print… (=⌥⌘P=). See [[file:12-export.org][Export]]. | | |
| 1074 | | Print Subtree… (=app.print-subtree=) | — | — | — | Prints the subtree at the caret. | | |
| 1075 | | Print Selection… (=app.print-selection=) | — | — | — | Prints the selected text. | | |
| 1072 | 1076 | | Export to PDF with Emacs (=app.export.pdf=) | =C-c C-e l p= | — | =SPC m e l p= (N) | Exports to PDF through Emacs (=org-latex-export-to-pdf=). | |
| 1073 | 1077 | | Export to LaTeX (=app.export.latex=) | =C-c C-e l l= | — | — | Exports to LaTeX without Emacs, as =org-latex-export-to-latex= does. | |
| 1074 | 1078 | | Export to ODT (=app.export.odt=) | =C-c C-e o o= | — | — | Exports to OpenDocument text without Emacs, as =org-odt-export-to-odt= does. | |
docs/manual/guide/04-outlines.org +1 −1 · view
| @@ -982,7 +982,7 @@ With =org-crypt-use-before-save-magic = true= in =config.toml=, every save, the | ||
| 982 | 982 | - When another program saves the file with tagged entries in plaintext, the file is held the same way until the passphrase lets orgstar keep a copy of that version encrypted and merge it. A version another program writes in the moment orgstar saves goes into the editor when no copy of it can be kept; if it conflicts, both versions are there between conflict markers, and the file is marked as in conflict. Keep Mine on such a file is held until the passphrase is given. For a file that isn't open (Replace in Files, agenda actions, the clock, capture, refile and archive into it), that version is put back as the other program wrote it, and the change isn't made: "The file changed on disk; nothing was changed." |
| 983 | 983 | - An entry that the passphrase can't encrypt (text typed below a message encrypted with another passphrase, or to a public key) holds the file too; the notice says why, without an Encrypt… button. |
| 984 | 984 | - Closing the file, its window, or quitting while it's held asks for the passphrase, or whether to leave without saving; any other save that fails then offers Don't Save. On iOS, the edits stay in memory while orgstar is in the background, and the notice is there on return; if iOS ends orgstar meanwhile, the edits are lost, and orgstar says so when it next opens. |
| 985 | - While an entry is decrypted in the editor, the agenda, widgets, the watch and reminders read the file from disk, where the entry is encrypted. The index, Spotlight and Quick Look read files from disk too. iCalendar export and publishing read such a file from disk and say so. Recalculating a table in Emacs, exporting with Emacs and =elisp:= links in Emacs aren't given a copy of the file. Clocking in to a heading inside such an entry shows "Encrypted entry" in the clock's history, widgets, the Live Activity and the menu bar; the history finds the heading again by a keyed hash of its title, with a key orgstar keeps in the Keychain on this device, or, without one, only until orgstar quits. Handoff doesn't offer the file, and Share Subtree… shares tagged entries encrypted as they are on disk, or, without the passphrase or when they can't be encrypted, not at all. Shared from inside an encrypted entry, a heading is shared as an entry titled "Encrypted entry" with the tag, whose one message holds the heading and everything under it. | |
| 985 | - While an entry is decrypted in the editor, the agenda, widgets, the watch and reminders read the file from disk, where the entry is encrypted. The index, Spotlight and Quick Look read files from disk too. iCalendar export and publishing read such a file from disk and say so. Exporting and printing the file itself use the editor's text, so they include an entry decrypted in the file and leave an entry that is still encrypted there as its message. Recalculating a table in Emacs, exporting with Emacs and =elisp:= links in Emacs aren't given a copy of the file. Clocking in to a heading inside such an entry shows "Encrypted entry" in the clock's history, widgets, the Live Activity and the menu bar; the history finds the heading again by a keyed hash of its title, with a key orgstar keeps in the Keychain on this device, or, without one, only until orgstar quits. Handoff doesn't offer the file, and Share Subtree… shares tagged entries encrypted as they are on disk, or, without the passphrase or when they can't be encrypted, not at all. Shared from inside an encrypted entry, a heading is shared as an entry titled "Encrypted entry" with the tag, whose one message holds the heading and everything under it. | |
| 986 | 986 | |
| 987 | 987 | * Encrypted files |
| 988 | 988 | |
docs/manual/guide/07-agenda.org +6 · view
| @@ -719,6 +719,12 @@ When no entry matches, the board says so in place of the table or columns. | ||
| 719 | 719 | |
| 720 | 720 | Choose Board from the Views menu in the Agenda tab. The board opens over the agenda with a List / Kanban switch at the top, a match field under it (press Search to apply it), and Done to close it. The list shows the entries sorted by keyword, then title; tap one to open it. In Kanban, columns scroll sideways; touch and hold a card, then drag it to another column to set that keyword. A card's or row's menu has Move To (a keyword, or None), Set Property… (=NAME value=) and Open. The Kanban or List choice and the match are remembered, separately from the Mac's. |
| 721 | 721 | |
| 722 | * Printing the agenda | |
| 723 | ||
| 724 | File ▸ Print… (=⌥⌘P=) with the agenda window in front prints the agenda as it shows: its title, the folders shown and the filter, then each day's header with today's overdue entries (only their count while Overdue is folded), the entries with their time or status, category, tags, TODO keyword and priority, and the time grid; or the entries of a TODO list, match or search; or each block of a block agenda under its title. There is no current-time line. The pages are laid out as Export to PDF lays out a file, with its margins and page numbers, in the print panel. Printing the agenda doesn't need orgstar+. On iOS, Print… is in the agenda's Views menu and in its Commands. | |
| 725 | ||
| 726 | An entry encrypted with =crypt= shows in the agenda, and so in the print, only by its heading; see [[file:04-outlines.org][Outlines]]. | |
| 727 | ||
| 722 | 728 | * Desktop widgets |
| 723 | 729 | |
| 724 | 730 | On the Mac, orgstar's widgets go on the desktop and in Notification Center: right-click the desktop, choose Edit Widgets…, and pick orgstar in the gallery. They appear there once orgstar has run. |
docs/manual/guide/12-export.org +17 −1 · view
| @@ -59,7 +59,7 @@ The Export menu offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, O | ||
| 59 | 59 | |
| 60 | 60 | Body Only in the Export menu leaves out the title and the page around the text, as in the Mac's export dialog, and is kept for each file. While it is on, PDF, Word, Rich Text (RTF), Plain Text, ODT and iCalendar say "This format has no body-only export. Turn body-only export off for this file first." Turn Body-Only Export On or Off, in Commands or on =C-c C-e C-b= with a hardware keyboard, changes the same setting. Export Subtree…, in the editor's Export menu, lists the formats for the subtree at the caret, and follows Body Only too. There is no subtree setting on iOS: the menu's formats always export the whole file. |
| 61 | 61 | |
| 62 | The Export menu also has Export Agenda Files to iCalendar and Combine Agenda Files into iCalendar (see [[*iCalendar export][iCalendar export]]). Export to HTML and Open, in Commands or on =C-c C-e h o= with a hardware keyboard, shows the HTML export in Quick Look, with the file's images in the page; nothing is written beside the Org file; it follows Body Only. Copy as Rich Text is in Commands too. | |
| 62 | Print… in the Export menu prints the file; see [[*Printing][Printing]]. The Export menu also has Export Agenda Files to iCalendar and Combine Agenda Files into iCalendar (see [[*iCalendar export][iCalendar export]]). Export to HTML and Open, in Commands or on =C-c C-e h o= with a hardware keyboard, shows the HTML export in Quick Look, with the file's images in the page; nothing is written beside the Org file; it follows Body Only. Copy as Rich Text is in Commands too. | |
| 63 | 63 | |
| 64 | 64 | * HTML export |
| 65 | 65 | |
| @@ -232,6 +232,22 @@ Export to PDF makes the HTML export into a PDF, laid out and split into pages by | ||
| 232 | 232 | |
| 233 | 233 | For typeset output with LaTeX's classes and packages, use Export to PDF with Emacs instead (see /Exporting through Emacs/). |
| 234 | 234 | |
| 235 | * Printing | |
| 236 | ||
| 237 | Printing makes the same pages as Export to PDF, with its margins, font and page numbers, and hands them to the system's print panel, which shows a preview and the printer's own choices. Pages that don't fit the paper chosen there are scaled down to fit. Like PDF export, printing a file needs [[file:../install.org][orgstar+]], since the print panel can save a PDF; printing the agenda doesn't (see [[file:07-agenda.org][Agenda]]). | |
| 238 | ||
| 239 | | Command | Prints | | |
| 240 | |------------------+----------------------------------------------------------------------------------------------------------| | |
| 241 | | Print… | The whole file. | | |
| 242 | | Print Subtree… | The subtree at the caret, as a document of its own, as the export dialog's /Scope/ exports it. "Not in a subtree" before the first heading. | | |
| 243 | | Print Selection… | The selected text, under the file's title and with its =#+= keywords. "No text is selected" without a selection. | | |
| 244 | ||
| 245 | On the Mac the three are in the File menu and the command palette; Print… is =⌥⌘P=, since =⌘P= is Quick Open. File ▸ Page Setup… sets the paper size and orientation the pages are laid out for. Body Only and the file's subtree export setting don't apply to printing. | |
| 246 | ||
| 247 | On iOS, Print… is in the Export menu and prints the whole file; Export Subtree… has Print… for the subtree; all three commands are in Commands, where Print Selection… is greyed without a selection. The pages are US Letter or A4, as for PDF export, and the system's print sheet scales them to the paper. | |
| 248 | ||
| 249 | The text printed is the editor's, saved or not, as for export. An entry encrypted with =crypt= prints as its encrypted message unless it has been decrypted in the file (Decrypt Entry in File…); one only opened with Decrypt Entry… stays encrypted in the print. See [[file:04-outlines.org][Outlines]]. | |
| 250 | ||
| 235 | 251 | * LaTeX export |
| 236 | 252 | |
| 237 | 253 | Export to LaTeX writes the =.tex= file that Emacs's =org-latex-export-to-latex= writes under =emacs -Q= (Org 9.8.7), without Emacs, on the Mac and iOS. It has the same preamble, sectioning, lists, tables, verbatim source blocks, figures, footnotes, links and escaping. Two things differ: the =\label= keys are made from the document, so they stay the same between exports, where Emacs picks new random ones each time; and =\author= is the name of the Mac's user account, which is what =user-full-name= usually is, unless the file has =#+AUTHOR:=. |
docs/manual/guide/14-ios.org +4 −2 · view
| @@ -178,7 +178,7 @@ Commands, in the key bar and in the toolbar of the editor, the reader and the ag | ||
| 178 | 178 | |
| 179 | 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. |
| 180 | 180 | |
| 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. | |
| 181 | The editor's list has Export…, Export Subtree…, Print…, Print Subtree… and Print Selection… 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, Print…, Capture… and the same clock commands. | |
| 182 | 182 | |
| 183 | 183 | When a command asks a question, a sheet opens: |
| 184 | 184 | |
| @@ -265,7 +265,7 @@ Tap a result to open it in the reader. A heading result opens at that heading. | ||
| 265 | 265 | |
| 266 | 266 | The Agenda tab shows the agenda over all your folders, with the span and start day from the settings (10 days from 3 days ago by default). Each day lists its entries in rows: the time or a status such as =Due today= or =3d late= on the left, the category, tags and keyword above the title, as on the Mac (see Rows in [[file:07-agenda.org][The agenda]]). Days without entries are hidden, except today. Under today's header, today's overdue entries come first under Overdue, and a line marks the current time between timed entries. Pull down to refresh. |
| 267 | 267 | |
| 268 | - Views (top left) :: the built-in views and those in =views.toml=, Tags and Properties… (a match such as =+work-home= or ~TODO="WAIT"~), and Search… (a phrase, or snippets such as =+invoice -paid=); Save as View… keeps the match or search showing as a view in =views.toml=. Below them are Go to Date…, Filter… and Select, which picks entries for an action on all of them. | |
| 268 | - Views (top left) :: the built-in views and those in =views.toml=, Tags and Properties… (a match such as =+work-home= or ~TODO="WAIT"~), and Search… (a phrase, or snippets such as =+invoice -paid=); Save as View… keeps the match or search showing as a view in =views.toml=. Below them are Go to Date…, Filter… and Select, which picks entries for an action on all of them, then Board and Print…, which prints the agenda as it shows (see Printing the agenda in [[file:07-agenda.org][The agenda]]). | |
| 269 | 269 | - Commands (top right) :: the agenda's views and actions, Capture… and the clock commands, in one searchable list; see Commands under The editor. |
| 270 | 270 | - Folders (top right, with more than one folder) :: shows or hides each folder's files in the agenda, the widgets, the watch and the badge; the shown folders' names appear under the title. A Focus can hide folders too, and mute their reminders (see Hiding folders in [[file:07-agenda.org][The agenda]]). |
| 271 | 271 | - The bar at the bottom :: Earlier, Today, the span (Day, Week, Month or the configured span, and Log Mode, which adds closed entries and clocked time) and Later. At accessibility text sizes Today is in the span's menu, and each entry's time or status is on a line of its own above it. |
| @@ -415,6 +415,8 @@ PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.to | ||
| 415 | 415 | |
| 416 | 416 | 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. |
| 417 | 417 | |
| 418 | Print…, in the Export menu, prints the file in the system's print sheet, on the pages PDF export makes; Export Subtree… has Print… for the subtree, and the editor's Commands has Print…, Print Subtree… and Print Selection…. Printing needs orgstar+, as PDF export does. See Printing in [[file:12-export.org][Export]]. | |
| 419 | ||
| 418 | 420 | Share Subtree…, in the editor's Commands under Export, shares the entry at the caret as it is in the file: Share as Org File sends an =.org= file named after its heading, with Include attachments sending the entry's attached files beside it, and Share as Text sends the text. See [[file:01-files-and-folders.org][Files and folders]], Sharing a subtree. |
| 419 | 421 | |
| 420 | 422 | 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. |
l10n/Localizable.xcstrings +207 · view
| @@ -8491,6 +8491,40 @@ | ||
| 8491 | 8491 | } |
| 8492 | 8492 | } |
| 8493 | 8493 | }, |
| 8494 | "Can't print: %@": { | |
| 8495 | "localizations": { | |
| 8496 | "de": { | |
| 8497 | "stringUnit": { | |
| 8498 | "state": "translated", | |
| 8499 | "value": "Drucken nicht möglich: %@" | |
| 8500 | } | |
| 8501 | }, | |
| 8502 | "es": { | |
| 8503 | "stringUnit": { | |
| 8504 | "state": "translated", | |
| 8505 | "value": "No se puede imprimir: %@" | |
| 8506 | } | |
| 8507 | }, | |
| 8508 | "fr": { | |
| 8509 | "stringUnit": { | |
| 8510 | "state": "translated", | |
| 8511 | "value": "Impossible d'imprimer : %@" | |
| 8512 | } | |
| 8513 | }, | |
| 8514 | "ja": { | |
| 8515 | "stringUnit": { | |
| 8516 | "state": "translated", | |
| 8517 | "value": "プリントできません:%@" | |
| 8518 | } | |
| 8519 | }, | |
| 8520 | "pt-BR": { | |
| 8521 | "stringUnit": { | |
| 8522 | "state": "translated", | |
| 8523 | "value": "Não é possível imprimir: %@" | |
| 8524 | } | |
| 8525 | } | |
| 8526 | } | |
| 8527 | }, | |
| 8494 | 8528 | "Can't read %@": { |
| 8495 | 8529 | "localizations": { |
| 8496 | 8530 | "de": { |
| @@ -30208,6 +30242,40 @@ | ||
| 30208 | 30242 | } |
| 30209 | 30243 | } |
| 30210 | 30244 | }, |
| 30245 | "No text is selected": { | |
| 30246 | "localizations": { | |
| 30247 | "de": { | |
| 30248 | "stringUnit": { | |
| 30249 | "state": "translated", | |
| 30250 | "value": "Kein Text ausgewählt" | |
| 30251 | } | |
| 30252 | }, | |
| 30253 | "es": { | |
| 30254 | "stringUnit": { | |
| 30255 | "state": "translated", | |
| 30256 | "value": "No hay texto seleccionado" | |
| 30257 | } | |
| 30258 | }, | |
| 30259 | "fr": { | |
| 30260 | "stringUnit": { | |
| 30261 | "state": "translated", | |
| 30262 | "value": "Aucun texte n'est sélectionné" | |
| 30263 | } | |
| 30264 | }, | |
| 30265 | "ja": { | |
| 30266 | "stringUnit": { | |
| 30267 | "state": "translated", | |
| 30268 | "value": "テキストが選択されていません" | |
| 30269 | } | |
| 30270 | }, | |
| 30271 | "pt-BR": { | |
| 30272 | "stringUnit": { | |
| 30273 | "state": "translated", | |
| 30274 | "value": "Nenhum texto selecionado" | |
| 30275 | } | |
| 30276 | } | |
| 30277 | } | |
| 30278 | }, | |
| 30211 | 30279 | "Node Graph": { |
| 30212 | 30280 | "localizations": { |
| 30213 | 30281 | "de": { |
| @@ -33124,6 +33192,40 @@ | ||
| 33124 | 33192 | } |
| 33125 | 33193 | } |
| 33126 | 33194 | }, |
| 33195 | "Page Setup…": { | |
| 33196 | "localizations": { | |
| 33197 | "de": { | |
| 33198 | "stringUnit": { | |
| 33199 | "state": "translated", | |
| 33200 | "value": "Papierformat …" | |
| 33201 | } | |
| 33202 | }, | |
| 33203 | "es": { | |
| 33204 | "stringUnit": { | |
| 33205 | "state": "translated", | |
| 33206 | "value": "Ajustes de página…" | |
| 33207 | } | |
| 33208 | }, | |
| 33209 | "fr": { | |
| 33210 | "stringUnit": { | |
| 33211 | "state": "translated", | |
| 33212 | "value": "Format d'impression…" | |
| 33213 | } | |
| 33214 | }, | |
| 33215 | "ja": { | |
| 33216 | "stringUnit": { | |
| 33217 | "state": "translated", | |
| 33218 | "value": "ページ設定…" | |
| 33219 | } | |
| 33220 | }, | |
| 33221 | "pt-BR": { | |
| 33222 | "stringUnit": { | |
| 33223 | "state": "translated", | |
| 33224 | "value": "Configurar Página…" | |
| 33225 | } | |
| 33226 | } | |
| 33227 | } | |
| 33228 | }, | |
| 33127 | 33229 | "Page numbers": { |
| 33128 | 33230 | "localizations": { |
| 33129 | 33231 | "de": { |
| @@ -34480,6 +34582,111 @@ | ||
| 34480 | 34582 | } |
| 34481 | 34583 | } |
| 34482 | 34584 | }, |
| 34585 | "Print Selection…": { | |
| 34586 | "comment": "Command title", | |
| 34587 | "localizations": { | |
| 34588 | "de": { | |
| 34589 | "stringUnit": { | |
| 34590 | "state": "translated", | |
| 34591 | "value": "Auswahl drucken …" | |
| 34592 | } | |
| 34593 | }, | |
| 34594 | "es": { | |
| 34595 | "stringUnit": { | |
| 34596 | "state": "translated", | |
| 34597 | "value": "Imprimir selección…" | |
| 34598 | } | |
| 34599 | }, | |
| 34600 | "fr": { | |
| 34601 | "stringUnit": { | |
| 34602 | "state": "translated", | |
| 34603 | "value": "Imprimer la sélection…" | |
| 34604 | } | |
| 34605 | }, | |
| 34606 | "ja": { | |
| 34607 | "stringUnit": { | |
| 34608 | "state": "translated", | |
| 34609 | "value": "選択部分をプリント…" | |
| 34610 | } | |
| 34611 | }, | |
| 34612 | "pt-BR": { | |
| 34613 | "stringUnit": { | |
| 34614 | "state": "translated", | |
| 34615 | "value": "Imprimir Seleção…" | |
| 34616 | } | |
| 34617 | } | |
| 34618 | } | |
| 34619 | }, | |
| 34620 | "Print Subtree…": { | |
| 34621 | "comment": "Command title", | |
| 34622 | "localizations": { | |
| 34623 | "de": { | |
| 34624 | "stringUnit": { | |
| 34625 | "state": "translated", | |
| 34626 | "value": "Teilbaum drucken …" | |
| 34627 | } | |
| 34628 | }, | |
| 34629 | "es": { | |
| 34630 | "stringUnit": { | |
| 34631 | "state": "translated", | |
| 34632 | "value": "Imprimir subárbol…" | |
| 34633 | } | |
| 34634 | }, | |
| 34635 | "fr": { | |
| 34636 | "stringUnit": { | |
| 34637 | "state": "translated", | |
| 34638 | "value": "Imprimer le sous-arbre…" | |
| 34639 | } | |
| 34640 | }, | |
| 34641 | "ja": { | |
| 34642 | "stringUnit": { | |
| 34643 | "state": "translated", | |
| 34644 | "value": "サブツリーをプリント…" | |
| 34645 | } | |
| 34646 | }, | |
| 34647 | "pt-BR": { | |
| 34648 | "stringUnit": { | |
| 34649 | "state": "translated", | |
| 34650 | "value": "Imprimir Subárvore…" | |
| 34651 | } | |
| 34652 | } | |
| 34653 | } | |
| 34654 | }, | |
| 34655 | "Print…": { | |
| 34656 | "comment": "Command title", | |
| 34657 | "localizations": { | |
| 34658 | "de": { | |
| 34659 | "stringUnit": { | |
| 34660 | "state": "translated", | |
| 34661 | "value": "Drucken …" | |
| 34662 | } | |
| 34663 | }, | |
| 34664 | "es": { | |
| 34665 | "stringUnit": { | |
| 34666 | "state": "translated", | |
| 34667 | "value": "Imprimir…" | |
| 34668 | } | |
| 34669 | }, | |
| 34670 | "fr": { | |
| 34671 | "stringUnit": { | |
| 34672 | "state": "translated", | |
| 34673 | "value": "Imprimer…" | |
| 34674 | } | |
| 34675 | }, | |
| 34676 | "ja": { | |
| 34677 | "stringUnit": { | |
| 34678 | "state": "translated", | |
| 34679 | "value": "プリント…" | |
| 34680 | } | |
| 34681 | }, | |
| 34682 | "pt-BR": { | |
| 34683 | "stringUnit": { | |
| 34684 | "state": "translated", | |
| 34685 | "value": "Imprimir…" | |
| 34686 | } | |
| 34687 | } | |
| 34688 | } | |
| 34689 | }, | |
| 34483 | 34690 | "Priority": { |
| 34484 | 34691 | "localizations": { |
| 34485 | 34692 | "de": { |