Handoff, Working Copy sync, Share Subtree !490

merged merged by cmc on 2026-11-26 09:35 UTC · krz/orgstar:m5-batch2 into main

31 files changed, +2444 −9

Layout: unified · split

Changed files (31)
Sources/OrgApp/CommandRanking.swift +2 −2 · view
@@ -93,8 +93,8 @@ public enum CommandGroups {
93 /// The Org menu's groups and the app's commands outside the Org menu. 93 /// The Org menu's groups and the app's commands outside the Org menu.
94 public static let commandList: [Group] = orgMenu + [ 94 public static let commandList: [Group] = orgMenu + [
95 Group(title: String(localized: "Clock", comment: "Commands list section"), prefixes: ["app.clock."]), 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"]), 96 Group(title: String(localized: "Export", comment: "Commands list section"), prefixes: ["app.export", "app.copy-rich-text", "app.publish", "app.share-subtree"]),
97 Group(title: String(localized: "File", comment: "Commands list section"), prefixes: ["app.save", "app.word-count", "app.recovery", "app.sync-conflicts", "app.lint"]), 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 Group(title: String(localized: "Edit", comment: "Commands list section"), prefixes: ["edit.", "macro."]), 98 Group(title: String(localized: "Edit", comment: "Commands list section"), prefixes: ["edit.", "macro."]),
99 Group(title: String(localized: "View", comment: "Commands list section"), prefixes: ["app.toggle-markup", "editor.", "app.split-", "app.pane-"]), 99 Group(title: String(localized: "View", comment: "Commands list section"), prefixes: ["app.toggle-markup", "editor.", "app.split-", "app.pane-"]),
100 ] 100 ]
Sources/OrgApp/CommandTitles.swift +2 · view
@@ -293,6 +293,7 @@ enum CommandTitles {
293 String(localized: "Set Priority…", comment: "Command title"), 293 String(localized: "Set Priority…", comment: "Command title"),
294 String(localized: "Set Property…", comment: "Command title"), 294 String(localized: "Set Property…", comment: "Command title"),
295 String(localized: "Set Tags", comment: "Command title"), 295 String(localized: "Set Tags", comment: "Command title"),
296 String(localized: "Share Subtree…", comment: "Command title"),
296 String(localized: "Shift Timer Values in Region…", comment: "Command title"), 297 String(localized: "Shift Timer Values in Region…", comment: "Command title"),
297 String(localized: "Show Agenda or Files in Sidebar", comment: "Command title"), 298 String(localized: "Show Agenda or Files in Sidebar", comment: "Command title"),
298 String(localized: "Show Attachment Folder", comment: "Command title"), 299 String(localized: "Show Attachment Folder", comment: "Command title"),
@@ -328,6 +329,7 @@ enum CommandTitles {
328 String(localized: "Strike-Through", comment: "Command title"), 329 String(localized: "Strike-Through", comment: "Command title"),
329 String(localized: "Switch to Buffer…", comment: "Command title"), 330 String(localized: "Switch to Buffer…", comment: "Command title"),
330 String(localized: "Sync Attachments", comment: "Command title"), 331 String(localized: "Sync Attachments", comment: "Command title"),
332 String(localized: "Sync with Working Copy", comment: "Command title"),
331 String(localized: "Take Photo…", comment: "Command title"), 333 String(localized: "Take Photo…", comment: "Command title"),
332 String(localized: "Tangle Block", comment: "Command title"), 334 String(localized: "Tangle Block", comment: "Command title"),
333 String(localized: "Tangle Block's Target", comment: "Command title"), 335 String(localized: "Tangle Block's Target", comment: "Command title"),
Sources/OrgApp/Handoff.swift added +251 · view
@@ -0,0 +1,251 @@
1import Foundation
2import OrgCore
3
4/// The open file and the caret's place in it, as Handoff passes them between orgstar on a Mac,
5/// iPhone and iPad. Only where the file is and where the caret is go in the activity, never the
6/// file's text.
7///
8/// A folder is found on the other device by its path in iCloud Drive (or another iCloud
9/// container) when it is in iCloud, since that path is the same on every device; otherwise by
10/// the added folder's name, since other providers (Dropbox, Working Copy, a local folder) put
11/// the same folder at a different path on each device.
12public struct HandoffPlace: Equatable, Sendable {
13 /// The activity type, listed under `NSUserActivityTypes` in both apps' Info.plist.
14 public static let activityType = "sh.krz.orgstar.editing"
15
16 /// The added folder's name.
17 public var folder: String
18 /// The file's path inside iCloud's containers (`com~apple~CloudDocs/org/todo.org`), when it
19 /// is in iCloud.
20 public var cloudPath: String?
21 /// The file's path relative to the added folder.
22 public var file: String
23 /// The titles of the caret's heading and the headings above it, outermost first.
24 public var outline: [String]
25 /// The caret's heading's `ID`.
26 public var id: String?
27 /// The caret's line, from 1.
28 public var line: Int
29 /// The caret's heading's line, from 1; 0 before the first heading.
30 public var headingLine: Int
31
32 public init(folder: String, cloudPath: String?, file: String, outline: [String], id: String?, line: Int, headingLine: Int) {
33 self.folder = folder
34 self.cloudPath = cloudPath
35 self.file = file
36 self.outline = outline
37 self.id = id
38 self.line = line
39 self.headingLine = headingLine
40 }
41
42 // MARK: - userInfo
43
44 public var userInfo: [String: Any] {
45 var info: [String: Any] = ["folder": folder, "file": file, "outline": outline, "line": line, "headingLine": headingLine]
46 if let cloudPath { info["cloudPath"] = cloudPath }
47 if let id { info["id"] = id }
48 return info
49 }
50
51 public init?(userInfo: [AnyHashable: Any]?) {
52 guard let info = userInfo, let folder = info["folder"] as? String, let file = info["file"] as? String,
53 !file.isEmpty, !file.hasPrefix("/"), !file.split(separator: "/").contains("..") else { return nil }
54 self.init(folder: folder, cloudPath: info["cloudPath"] as? String, file: file, outline: info["outline"] as? [String] ?? [],
55 id: info["id"] as? String, line: max(1, info["line"] as? Int ?? 1), headingLine: max(0, info["headingLine"] as? Int ?? 0))
56 }
57
58 // MARK: - Advertising
59
60 /// Whether a file may be advertised: not an encrypted one.
61 public static func advertises(_ path: String) -> Bool {
62 !path.hasSuffix(".gpg")
63 }
64
65 /// The place of `caret` in `text`, the file at `path` inside one of `roots`; nil when the
66 /// file is in none of them or is encrypted.
67 public static func make(path: String, text: String, caret: Int, roots: [String], settings: OrgSettings = .default) -> HandoffPlace? {
68 guard advertises(path), let root = roots.filter({ inside(path, $0) }).max(by: { $0.count < $1.count }) else { return nil }
69 let file = String(path.dropFirst(root.hasSuffix("/") ? root.count : root.count + 1))
70 guard !file.isEmpty else { return nil }
71 let model = DocumentModel(tree: OrgParser.parse(text, defaults: settings))
72 let ns = text as NSString
73 let caret = max(0, min(caret, ns.length))
74 var outline: [String] = []
75 var id: String?
76 var headingLine = 0
77 if let index = model.headings.lastIndex(where: { $0.headingRange.lowerBound <= caret }) {
78 id = model.headings[index].id
79 headingLine = line(of: model.headings[index].headingRange.lowerBound, in: ns)
80 var next: Int? = index
81 while let i = next {
82 outline.insert(model.headings[i].title, at: 0)
83 next = model.headings[i].parent
84 }
85 }
86 return HandoffPlace(folder: (root as NSString).lastPathComponent, cloudPath: cloudPath(of: path), file: file,
87 outline: outline, id: id, line: line(of: caret, in: ns), headingLine: headingLine)
88 }
89
90 /// `path` inside iCloud's containers: what follows `Mobile Documents/`, which is the same on
91 /// a Mac (`~/Library/Mobile Documents`) and on iOS (`/var/mobile/Library/Mobile Documents`).
92 public static func cloudPath(of path: String) -> String? {
93 guard let range = path.range(of: "/Mobile Documents/") else { return nil }
94 let rest = String(path[range.upperBound...])
95 return rest.isEmpty ? nil : rest
96 }
97
98 static func inside(_ path: String, _ root: String) -> Bool {
99 path.hasPrefix(root.hasSuffix("/") ? root : root + "/")
100 }
101
102 /// The 1-based line of `offset`.
103 static func line(of offset: Int, in text: NSString) -> Int {
104 var line = 1
105 var index = 0
106 let end = min(offset, text.length)
107 while index < end {
108 let found = text.range(of: "\n", options: [], range: NSRange(location: index, length: end - index))
109 guard found.location != NSNotFound else { break }
110 line += 1
111 index = found.location + 1
112 }
113 return line
114 }
115
116 /// The offset where 1-based `line` starts, or the end of the text.
117 static func offset(ofLine line: Int, in text: NSString) -> Int {
118 var index = 0
119 var current = 1
120 while current < line {
121 let found = text.range(of: "\n", options: [], range: NSRange(location: index, length: text.length - index))
122 guard found.location != NSNotFound else { return text.length }
123 index = found.location + 1
124 current += 1
125 }
126 return index
127 }
128
129 // MARK: - Continuing
130
131 public enum Match: Equatable, Sendable {
132 /// The file on this device.
133 case file(String)
134 /// No added folder is the advertised one.
135 case noFolder
136 /// The folder is here, without the file (not synced yet, or since moved).
137 case noFile
138 }
139
140 /// The file on this device: in a root that has the same iCloud path, or else in a root with
141 /// the folder's name.
142 public func resolve(roots: [String], exists: (String) -> Bool = { FileManager.default.fileExists(atPath: $0) }) -> Match {
143 var candidates: [String] = []
144 if let cloudPath {
145 for root in roots {
146 guard let cloudRoot = Self.cloudPath(of: root), cloudPath.hasPrefix(cloudRoot + "/") else { continue }
147 candidates.append((root as NSString).appendingPathComponent(String(cloudPath.dropFirst(cloudRoot.count + 1))))
148 }
149 }
150 if candidates.isEmpty {
151 candidates = roots.filter { ($0 as NSString).lastPathComponent == folder }.map { ($0 as NSString).appendingPathComponent(file) }
152 }
153 guard !candidates.isEmpty else { return .noFolder }
154 return candidates.first(where: exists).map(Match.file) ?? .noFile
155 }
156
157 /// Where the caret goes in `text`, this device's copy of the file: the heading with the
158 /// `ID`, else the one at the outline path, at the same line within it; else the same line.
159 public func offset(in text: String, settings: OrgSettings = .default) -> Int {
160 let ns = text as NSString
161 let model = DocumentModel(tree: OrgParser.parse(text, defaults: settings))
162 var found: Int?
163 if let id { found = model.headings.firstIndex { $0.id == id } }
164 if found == nil, !outline.isEmpty {
165 var parent: Int?
166 for title in outline {
167 guard let next = model.headings.indices.first(where: { model.headings[$0].parent == parent && model.headings[$0].title == title }) else {
168 parent = nil
169 break
170 }
171 parent = next
172 }
173 found = parent
174 }
175 guard let found, headingLine > 0 else { return Self.offset(ofLine: line, in: ns) }
176 let start = model.headings[found].headingRange.lowerBound
177 // The caret was in the heading's own text, before the next heading.
178 let limit = found + 1 < model.headings.count ? max(start, model.headings[found + 1].headingRange.lowerBound - 1) : ns.length
179 let target = Self.line(of: start, in: ns) + max(0, line - headingLine)
180 return min(Self.offset(ofLine: target, in: ns), limit)
181 }
182}
183
184/// The activity that advertises the focused file to the other devices. `place` gives what to
185/// advertise when the file or the caret changes; the activity is current only while it gives
186/// one.
187@MainActor
188public final class HandoffAdvertiser {
189 public var place: () -> HandoffPlace? = { nil }
190 private var activity: NSUserActivity?
191 private var pending: Task<Void, Never>?
192
193 public init() {}
194
195 /// The file or caret changed: the activity follows a moment later, so typing and moving
196 /// the caret don't parse the file on every key.
197 public func changed() {
198 pending?.cancel()
199 pending = Task { [weak self] in
200 try? await Task.sleep(for: .milliseconds(700))
201 guard !Task.isCancelled else { return }
202 self?.update()
203 }
204 }
205
206 /// Advertises the place now, or stops advertising when there is none.
207 public func update() {
208 guard let place = place() else {
209 activity?.invalidate()
210 activity = nil
211 return
212 }
213 let activity = activity ?? NSUserActivity(activityType: HandoffPlace.activityType)
214 activity.title = (place.file as NSString).lastPathComponent
215 activity.isEligibleForHandoff = true
216 activity.isEligibleForSearch = false
217 activity.isEligibleForPublicIndexing = false
218 activity.userInfo = place.userInfo
219 activity.needsSave = true
220 self.activity = activity
221 activity.becomeCurrent()
222 }
223
224 /// Stops advertising.
225 public func stop() {
226 pending?.cancel()
227 activity?.invalidate()
228 activity = nil
229 }
230}
231
232extension HandoffPlace {
233 /// What to say when the file can't be continued here; nil when it can.
234 public func problem(_ match: Match) -> String? {
235 let name = (file as NSString).lastPathComponent
236 switch match {
237 case .file: return nil
238 case .noFolder: return String(localized: "Can't continue \(name): no folder named “\(folder)” is added on this device.", comment: "Handoff from another device")
239 case .noFile: return String(localized: "Can't continue \(name): it isn't in “\(folder)” on this device yet.", comment: "Handoff from another device")
240 }
241 }
242}
243
244extension DocumentSession {
245 /// The open file at `path`, or the focused one, and its caret, for Handoff; nil for a file
246 /// in none of `roots` or an encrypted one.
247 public func handoffPlace(_ path: String? = nil, roots: [String]) -> HandoffPlace? {
248 guard let path = path ?? self.path, let text = document(of: path)?.text else { return nil }
249 return HandoffPlace.make(path: path, text: text, caret: caret(of: path) ?? 0, roots: roots, settings: defaults)
250 }
251}
Sources/OrgApp/SubtreeShare.swift added +70 · view
@@ -0,0 +1,70 @@
1import Foundation
2import OrgCore
3
4/// Share Subtree…: the entry at the caret as an org file of its own or as text, with the files
5/// attached to it and to the entries under it. The entry is taken as the file holds it, so an
6/// encrypted entry is shared encrypted.
7public struct SubtreeShare: Sendable, Identifiable {
8 public let id = UUID()
9 /// The entry with the file's keyword lines, as `ExportScope.entry` gives it.
10 public let text: String
11 /// The `.org` file's name: the heading's title.
12 public let fileName: String
13 /// Files in the attachment folders of the entry and the entries under it.
14 public let attachments: [URL]
15
16 /// The entry at `offset` in `text`, the file at `path`; nil before the first heading.
17 /// `idDir` and `inherit` are `org-attach-id-dir` and `org-attach-use-inheritance`.
18 public init?(text: String, at offset: Int, path: String, settings: OrgSettings = .default,
19 idDir: String = OrgPreferences.attachIDDir(), inherit: Bool? = OrgPreferences.attachUseInheritance()) {
20 guard let entry = ExportScope.entry(text, at: offset, settings: settings) else { return nil }
21 self.text = entry.text
22 let tree = OrgParser.parse(text, defaults: settings)
23 let headings = DocumentModel(tree: tree).headings.filter { entry.range.contains($0.headingRange.lowerBound) }
24 fileName = Self.fileName(entry.title)
25 var folders: [String] = []
26 for heading in headings {
27 guard let dir = OrgAttach.directory(tree: tree, at: heading.headingRange.lowerBound, path: path, idDir: idDir, inherit: inherit, isDirectory: Attachments.isDirectory),
28 !folders.contains(dir) else { continue }
29 folders.append(dir)
30 }
31 // Files only: hidden files and folders inside stay behind.
32 attachments = folders.flatMap { dir in
33 Attachments.files(in: dir).filter { !$0.hasPrefix(".") }.map { URL(fileURLWithPath: dir).appendingPathComponent($0) }
34 .filter { !Attachments.isDirectory($0.path) }
35 }
36 }
37
38 /// `title` as a file name: characters other systems refuse replaced, at most 80 long, with
39 /// `.org`.
40 static func fileName(_ title: String) -> String {
41 var name = title.components(separatedBy: CharacterSet(charactersIn: "/\\:*?\"<>|").union(.newlines).union(.controlCharacters))
42 .joined(separator: "-").trimmingCharacters(in: .whitespaces)
43 while name.hasPrefix(".") { name.removeFirst() }
44 if name.count > 80 { name = String(name.prefix(80)).trimmingCharacters(in: .whitespaces) }
45 return (name.isEmpty ? "Subtree" : name) + ".org"
46 }
47
48 /// Writes the entry as `fileName` in a new temporary folder; its URL.
49 public func writeFile() throws -> URL {
50 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("share-" + id.uuidString)
51 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
52 let url = folder.appendingPathComponent(fileName)
53 try Data(text.utf8).write(to: url, options: .atomic)
54 return url
55 }
56
57 /// What the share sheet sends: the written file and, when asked, the attachments, each as
58 /// an item of its own.
59 public func files(file: URL, withAttachments: Bool) -> [URL] {
60 [file] + (withAttachments ? attachments : [])
61 }
62}
63
64extension DocumentSession {
65 /// Share Subtree… for the entry at `offset` in the open file at `path`.
66 public func subtreeShare(_ path: String, at offset: Int) -> SubtreeShare? {
67 guard let text = document(of: path)?.text else { return nil }
68 return SubtreeShare(text: text, at: offset, path: path, settings: defaults)
69 }
70}
Sources/OrgApp/WorkingCopy.swift added +147 · view
@@ -0,0 +1,147 @@
1import Foundation
2import Security
3
4/// Syncing a folder that is a git repository in Working Copy, through its x-callback-url
5/// commands (https://workingcopyapp.com/url-schemes.html): commit everything changed, pull,
6/// then push, with the answer coming back to `orgstar://working-copy/…`.
7public enum WorkingCopy {
8 public static let scheme = "working-copy"
9 /// The host of the callbacks in orgstar's own scheme.
10 public static let callbackHost = "working-copy"
11
12 /// The commit message.
13 public static let message = "Update from orgstar"
14
15 /// The `chain` command that commits every changed file in `repo`, pulls and pushes, with
16 /// `key` (Working Copy's URL key) and callbacks naming `repo`.
17 public static func syncURL(repo: String, key: String, message: String = message) -> URL {
18 let back = { (result: String) in
19 "\(AppLink.scheme)://\(callbackHost)/\(result)?repo=\(encode(repo))"
20 }
21 // Parameters before the first `command` apply to every command; `x-success` is used by
22 // the last one.
23 let query = [
24 ("repo", repo), ("key", key), ("x-success", back("success")), ("x-error", back("error")),
25 ("command", "commit"), ("message", message), ("limit", "999"),
26 ("command", "pull"),
27 ("command", "push"),
28 ]
29 var components = URLComponents()
30 components.scheme = scheme
31 components.host = "x-callback-url"
32 components.path = "/chain"
33 components.percentEncodedQuery = query.map { "\($0)=\(encode($1))" }.joined(separator: "&")
34 return components.url!
35 }
36
37 /// Spaces as `%20`, not `+`, and every reserved character encoded, as Working Copy asks.
38 static func encode(_ value: String) -> String {
39 var allowed = CharacterSet.alphanumerics
40 allowed.insert(charactersIn: "-._~")
41 return value.addingPercentEncoding(withAllowedCharacters: allowed) ?? value
42 }
43
44 /// Working Copy's answer to a sync.
45 public enum Callback: Equatable, Sendable {
46 case success(repo: String)
47 /// With Working Copy's `errorMessage`, when it gave one.
48 case failure(repo: String, message: String?)
49 }
50
51 /// The callback `url` is, or nil for another URL.
52 public static func callback(_ url: URL) -> Callback? {
53 guard url.scheme == AppLink.scheme, url.host == callbackHost,
54 let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
55 let repo = components.queryItems?.first(where: { $0.name == "repo" })?.value else { return nil }
56 switch url.lastPathComponent {
57 case "success": return .success(repo: repo)
58 case "error":
59 let message = components.queryItems?.first { $0.name == "errorMessage" }?.value
60 return .failure(repo: repo, message: message.flatMap { $0.isEmpty ? nil : $0 })
61 default: return nil
62 }
63 }
64
65 /// Whether `root` holds a git repository: a `.git` folder or file (a worktree's) at its top.
66 /// Working Copy's own File Provider may leave `.git` out, so a folder can be set up without it.
67 public static func isRepository(_ root: String) -> Bool {
68 FileManager.default.fileExists(atPath: (root as NSString).appendingPathComponent(".git"))
69 }
70
71 // MARK: - Settings
72
73 /// How a folder syncs: the repository's name in Working Copy, and whether it syncs each time
74 /// the app opens. A folder without settings doesn't sync.
75 public struct Folder: Codable, Equatable, Sendable {
76 public var repository: String
77 public var syncOnOpen: Bool
78
79 public init(repository: String, syncOnOpen: Bool = false) {
80 self.repository = repository
81 self.syncOnOpen = syncOnOpen
82 }
83 }
84
85 /// The folders set up on this device, by root path. Kept on the device: roots are at
86 /// different paths on each.
87 public struct Folders {
88 static let key = "workingCopyFolders"
89 let defaults: UserDefaults
90
91 public init(defaults: UserDefaults = .standard) {
92 self.defaults = defaults
93 }
94
95 public var all: [String: Folder] {
96 guard let data = defaults.data(forKey: Self.key) else { return [:] }
97 return (try? JSONDecoder().decode([String: Folder].self, from: data)) ?? [:]
98 }
99
100 public func folder(_ root: String) -> Folder? { all[root] }
101
102 /// Sets up `root`, or with nil stops syncing it.
103 public func set(_ folder: Folder?, for root: String) {
104 var all = all
105 all[root] = folder
106 defaults.set(try? JSONEncoder().encode(all), forKey: Self.key)
107 }
108
109 /// The root set up with `repository`.
110 public func root(of repository: String) -> String? {
111 all.filter { $0.value.repository == repository }.map(\.key).sorted().first
112 }
113 }
114
115 // MARK: - The key
116
117 /// Working Copy's URL key, which every command needs. Kept in the Keychain on this device
118 /// only, never in settings or logs.
119 public enum Key {
120 static let service = "sh.krz.orgstar.working-copy"
121
122 static var query: [String: Any] {
123 [kSecClass as String: kSecClassGenericPassword, kSecAttrService as String: service, kSecAttrAccount as String: "url-key"]
124 }
125
126 public static func stored() -> String? {
127 var q = query
128 q[kSecReturnData as String] = true
129 var result: AnyObject?
130 guard SecItemCopyMatching(q as CFDictionary, &result) == errSecSuccess, let data = result as? Data else { return nil }
131 let key = String(decoding: data, as: UTF8.self)
132 return key.isEmpty ? nil : key
133 }
134
135 /// Stores `key`, or removes it when it is nil or empty. False when the Keychain refused.
136 @discardableResult
137 public static func store(_ key: String?) -> Bool {
138 SecItemDelete(query as CFDictionary)
139 guard let key, !key.isEmpty else { return true }
140 var item = query
141 item[kSecValueData as String] = Data(key.utf8)
142 item[kSecAttrLabel as String] = "orgstar: Working Copy URL key"
143 item[kSecAttrAccessible as String] = kSecAttrAccessibleWhenUnlockedThisDeviceOnly
144 return SecItemAdd(item as CFDictionary, nil) == errSecSuccess
145 }
146 }
147}
Sources/OrgCore/Export/ExportScope.swift +24 · view
@@ -56,6 +56,30 @@ public enum ExportScope {
56 return lines.joined(separator: "\n") + "\n" + body 56 return lines.joined(separator: "\n") + "\n" + body
57 } 57 }
58 58
59 /// Keywords of the file that name it or its export, left out of a shared entry.
60 static let fileOnlyKeywords: Set<String> = ["TITLE", "SUBTITLE", "EXPORT_FILE_NAME"]
61
62 /// The subtree containing `offset` as it is in the file, to share as an org file of its own:
63 /// the file's keyword lines (but its title and export name), then the heading and
64 /// everything under it, promoted so the heading is level 1. Its range in `text` and the
65 /// heading's title, links as their descriptions, come with it. Nil before the first heading.
66 public static func entry(_ text: String, at offset: Int, settings: OrgSettings = .default) -> (text: String, range: Range<Int>, title: String)? {
67 let tree = OrgParser.parse(text, defaults: settings)
68 let model = DocumentModel(tree: tree)
69 guard let index = model.headings.lastIndex(where: { $0.headingRange.lowerBound <= offset }) else { return nil }
70 let heading = model.headings[index]
71 let ns = text as NSString
72 let start = heading.headingRange.lowerBound
73 let end = model.headings[(index + 1)...].first { $0.level <= heading.level }?.headingRange.lowerBound ?? ns.length
74 let subtree = ExportPreprocess.shift(ns.substring(with: NSRange(location: start, length: end - start)), to: 1)
75 let lines = preamble(tree).filter { line in
76 guard let m = line.firstMatch(of: #/^#\+([^:\s]+):/#) else { return true }
77 return !fileOnlyKeywords.contains(m.1.uppercased())
78 }
79 let body = subtree.replacing(#/\s+$/#, with: "") + "\n"
80 return ((lines.isEmpty ? "" : lines.joined(separator: "\n") + "\n\n") + body, start..<end, Links.displayFormat(heading.title).trimmingCharacters(in: .whitespaces))
81 }
82
59 /// The export's name: the subtree's `EXPORT_FILE_NAME` property when exporting the subtree 83 /// The export's name: the subtree's `EXPORT_FILE_NAME` property when exporting the subtree
60 /// at `offset`, else the file's last `#+EXPORT_FILE_NAME`; nil when neither is set. 84 /// at `offset`, else the file's last `#+EXPORT_FILE_NAME`; nil when neither is set.
61 public static func fileName(_ text: String, subtreeAt offset: Int? = nil, settings: OrgSettings = .default) -> String? { 85 public static func fileName(_ text: String, subtreeAt offset: Int? = nil, settings: OrgSettings = .default) -> String? {
Sources/OrgEditorAppKit/EditorCommands.swift +1 · view
@@ -185,6 +185,7 @@ public enum EditorCommands {
185 EditorCommand(id: "app.export-dialog", title: "Export…", action: .app), 185 EditorCommand(id: "app.export-dialog", title: "Export…", action: .app),
186 EditorCommand(id: "app.export-subtree", title: "Turn Subtree Export On or Off", action: .app), 186 EditorCommand(id: "app.export-subtree", title: "Turn Subtree Export On or Off", action: .app),
187 EditorCommand(id: "app.export-body-only", title: "Turn Body-Only Export On or Off", action: .app), 187 EditorCommand(id: "app.export-body-only", title: "Turn Body-Only Export On or Off", action: .app),
188 EditorCommand(id: "app.share-subtree", title: "Share Subtree…", action: .app),
188 EditorCommand(id: "app.sync-conflicts", title: "Resolve Sync Conflicts…", action: .app), 189 EditorCommand(id: "app.sync-conflicts", title: "Resolve Sync Conflicts…", action: .app),
189 EditorCommand(id: "app.revert", title: "Revert to File on Disk", action: .app), 190 EditorCommand(id: "app.revert", title: "Revert to File on Disk", action: .app),
190 EditorCommand(id: "app.recovery", title: "History…", action: .app), 191 EditorCommand(id: "app.recovery", title: "History…", action: .app),
Sources/Orgstar/ContentView.swift +23 −1 · view
@@ -372,6 +372,8 @@ struct ContentView: View {
372 clock.remindAtEffort(session) 372 clock.remindAtEffort(session)
373 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] } 373 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] }
374 commands.completionIndex = workspace.index 374 commands.completionIndex = workspace.index
375 commands.handoff.place = { [weak session, weak workspace] in workspace.flatMap { session?.handoffPlace(roots: $0.rootPaths) } }
376 commands.continueHandoff = continueHandoff
375 commands.mainWindowOpen = true 377 commands.mainWindowOpen = true
376 commands.whatsNew = WhatsNew.pending(firstLaunch: noFolders && !welcomeShown) 378 commands.whatsNew = WhatsNew.pending(firstLaunch: noFolders && !welcomeShown)
377 if noFolders, !welcomeShown { 379 if noFolders, !welcomeShown {
@@ -512,6 +514,10 @@ struct ContentView: View {
512 } 514 }
513 session.reveal(request.offset) 515 session.reveal(request.offset)
514 } 516 }
517 // Handoff follows the focused file and its caret, and takes over again when the app does.
518 .onChange(of: session.path, initial: true) { commands.handoff.changed() }
519 .onChange(of: commands.selection) { commands.handoff.changed() }
520 .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in commands.handoff.update() }
515 .onChange(of: commands.focusSearch) { _, focus in 521 .onChange(of: commands.focusSearch) { _, focus in
516 if focus { 522 if focus {
517 searchFocused = true 523 searchFocused = true
@@ -580,6 +586,8 @@ struct ContentView: View {
580 // Files handed over at launch open after the restored buffers, and show. 586 // Files handed over at launch open after the restored buffers, and show.
581 for path in AppDelegate.pendingOpens { session.open(path) } 587 for path in AppDelegate.pendingOpens { session.open(path) }
582 AppDelegate.pendingOpens = [] 588 AppDelegate.pendingOpens = []
589 for place in AppDelegate.pendingHandoffs { continueHandoff(place) }
590 AppDelegate.pendingHandoffs = []
583 #if APPSTORE 591 #if APPSTORE
584 for link in AppDelegate.pendingLinks { commands.handle(protocolURL: link) } 592 for link in AppDelegate.pendingLinks { commands.handle(protocolURL: link) }
585 AppDelegate.pendingLinks = [] 593 AppDelegate.pendingLinks = []
@@ -985,6 +993,8 @@ struct ContentView: View {
985 PlotSheet(content: .chart(plot)) 993 PlotSheet(content: .chart(plot))
986 case .plotImage(_, let url): 994 case .plotImage(_, let url):
987 PlotSheet(content: .image(url)) 995 PlotSheet(content: .image(url))
996 case .shareSubtree(_, let share):
997 ShareSubtreeSheet(share: share) { commands.show($0) }
988 case .crypt(_, let request): 998 case .crypt(_, let request):
989 CryptSheet(request: request, text: { session.document?.text ?? "" }, apply: { applyText($0) }) { message in 999 CryptSheet(request: request, text: { session.document?.text ?? "" }, apply: { applyText($0) }) { message in
990 self.panel = nil 1000 self.panel = nil
@@ -1296,6 +1306,14 @@ struct ContentView: View {
1296 } 1306 }
1297 } 1307 }
1298 1308
1309 /// A file continued from another device, at the caret's heading or line there.
1310 private func continueHandoff(_ place: HandoffPlace) {
1311 let match = place.resolve(roots: workspace.rootPaths)
1312 guard case .file(let path) = match else { return commands.show(place.problem(match) ?? "") }
1313 let offset = session.text(of: path).map { place.offset(in: $0, settings: session.defaults) } ?? 0
1314 commands.jump(path: path, offset: offset)
1315 }
1316
1299 /// Runs a command from a key, the palette or the Org menu. 1317 /// Runs a command from a key, the palette or the Org menu.
1300 private func perform(_ id: String) { 1318 private func perform(_ id: String) {
1301 if hiddenCommandIDs.contains(id) { 1319 if hiddenCommandIDs.contains(id) {
@@ -1303,7 +1321,7 @@ struct ContentView: View {
1303 return commands.show(Self.unavailable(EditorCommands.all.first { $0.id == id }?.title ?? id)) 1321 return commands.show(Self.unavailable(EditorCommands.all.first { $0.id == id }?.title ?? id))
1304 } 1322 }
1305 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return } 1323 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return }
1306 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"].contains(id) || (id.hasPrefix("app.export.") && !id.hasPrefix("app.export.icalendar-")) || id.hasPrefix("org.") 1324 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.")
1307 if orgOnly, !session.isOrg { 1325 if orgOnly, !session.isOrg {
1308 commands.show(String(localized: "Not an org file")) 1326 commands.show(String(localized: "Not an org file"))
1309 return 1327 return
@@ -1504,6 +1522,10 @@ struct ContentView: View {
1504 lintRun += 1 1522 lintRun += 1
1505 case "app.copy-rich-text": 1523 case "app.copy-rich-text":
1506 copyRichText() 1524 copyRichText()
1525 case "app.share-subtree":
1526 guard let path = session.path else { return commands.show(String(localized: "No file is open")) }
1527 guard let share = session.subtreeShare(path, at: session.caret) else { return commands.show(String(localized: "Not in a subtree")) }
1528 panel = .shareSubtree(UUID(), share)
1507 case "app.export-dialog": 1529 case "app.export-dialog":
1508 guard let path = session.path else { return commands.show(String(localized: "No file is open")) } 1530 guard let path = session.path else { return commands.show(String(localized: "No file is open")) }
1509 panel = .export(UUID(), URL(fileURLWithPath: path)) 1531 panel = .export(UUID(), URL(fileURLWithPath: path))
Sources/Orgstar/OrgstarApp.swift +26 · view
@@ -77,6 +77,10 @@ final class AppCommands {
77 77
78 /// The editor's selection, for the modeline. 78 /// The editor's selection, for the modeline.
79 var selection = NSRange(location: 0, length: 0) 79 var selection = NSRange(location: 0, length: 0)
80 /// The focused file and caret, advertised for Handoff.
81 @ObservationIgnored let handoff = HandoffAdvertiser()
82 /// Opens a file continued from another device; the main window sets it.
83 @ObservationIgnored var continueHandoff: ((HandoffPlace) -> Void)?
80 var keyHints: [KeyHint] = [] 84 var keyHints: [KeyHint] = []
81 /// A question a command asked, answered in the echo area. 85 /// A question a command asked, answered in the echo area.
82 private(set) var prompt: PromptRequest? 86 private(set) var prompt: PromptRequest?
@@ -270,6 +274,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
270 /// org-protocol and orgstar:// links that arrive before the window is ready. 274 /// org-protocol and orgstar:// links that arrive before the window is ready.
271 static var pendingLinks: [String] = [] 275 static var pendingLinks: [String] = []
272 276
277 /// Files continued from another device before the window is ready.
278 static var pendingHandoffs: [HandoffPlace] = []
279
280 func application(_ application: NSApplication, willContinueUserActivityWithType userActivityType: String) -> Bool {
281 userActivityType == HandoffPlace.activityType
282 }
283
284 /// Handoff from an iPhone, iPad or another Mac.
285 func application(_ application: NSApplication, continue userActivity: NSUserActivity,
286 restorationHandler: @escaping ([any NSUserActivityRestoring]) -> Void) -> Bool {
287 guard userActivity.activityType == HandoffPlace.activityType, let place = HandoffPlace(userInfo: userActivity.userInfo) else { return false }
288 if let handler = commands?.continueHandoff {
289 NSApp.activate()
290 handler(place)
291 } else {
292 Self.pendingHandoffs.append(place)
293 }
294 return true
295 }
296
273 func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true } 297 func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
274 298
275 func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { 299 func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
@@ -517,6 +541,8 @@ struct OrgstarApp: App {
517 } 541 }
518 } 542 }
519 .disabled(session.path == nil) 543 .disabled(session.path == nil)
544 Button("Share Subtree…") { commands.run("app.share-subtree") }
545 .disabled(!session.isOrg)
520 Menu("Publish") { 546 Menu("Publish") {
521 ForEach(EditorCommands.all.filter { $0.id.hasPrefix("app.publish") }, id: \.id) { command in 547 ForEach(EditorCommands.all.filter { $0.id.hasPrefix("app.publish") }, id: \.id) { command in
522 Button(command.localizedTitle) { commands.run(command.id) } 548 Button(command.localizedTitle) { commands.run(command.id) }
Sources/Orgstar/Panels.swift +2 −1 · view
@@ -12,10 +12,11 @@ enum Panel: Identifiable {
12 case plot(UUID, TablePlot.Plot) 12 case plot(UUID, TablePlot.Plot)
13 case plotImage(UUID, URL) 13 case plotImage(UUID, URL)
14 case crypt(UUID, CryptRequest) 14 case crypt(UUID, CryptRequest)
15 case shareSubtree(UUID, SubtreeShare)
15 16
16 var id: UUID { 17 var id: UUID {
17 switch self { 18 switch self {
18 case .columns(let id, _), .export(let id, _), .conflict(let id), .syncCopies(let id), .recovery(let id), .plot(let id, _), .plotImage(let id, _), .crypt(let id, _): id 19 case .columns(let id, _), .export(let id, _), .conflict(let id), .syncCopies(let id), .recovery(let id), .plot(let id, _), .plotImage(let id, _), .crypt(let id, _), .shareSubtree(let id, _): id
19 } 20 }
20 } 21 }
21} 22}
Sources/Orgstar/ShareSubtreeSheet.swift added +94 · view
@@ -0,0 +1,94 @@
1import AppKit
2import OrgApp
3import SwiftUI
4
5/// Share Subtree…: the entry at the caret as an org file, with its attachments if chosen, or as
6/// text, through the sharing services (AirDrop, Mail, Messages).
7struct ShareSubtreeSheet: View {
8 let share: SubtreeShare
9 let report: (String) -> Void
10 @State private var asFile = true
11 @State private var withAttachments = false
12 @Environment(\.dismiss) private var dismiss
13
14 var body: some View {
15 VStack(alignment: .leading, spacing: 12) {
16 Text("Share Subtree").font(.headline)
17 Picker("Share as", selection: $asFile) {
18 Text("Org file (\(share.fileName))").tag(true)
19 Text("Text").tag(false)
20 }
21 .pickerStyle(.radioGroup)
22 if asFile, !share.attachments.isEmpty {
23 Toggle("Include \(share.attachments.count) attachments", isOn: $withAttachments)
24 }
25 HStack {
26 Spacer()
27 Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction)
28 SharingButton(title: String(localized: "Share…"), items: items) { dismiss() }
29 .fixedSize()
30 }
31 }
32 .padding(20)
33 .frame(width: 380)
34 }
35
36 /// The text, or the written file and the attachments chosen.
37 private func items() -> [Any] {
38 guard asFile else { return [share.text] }
39 do {
40 return share.files(file: try share.writeFile(), withAttachments: withAttachments)
41 } catch {
42 report(String(localized: "Can't share \(share.fileName): \(error.localizedDescription)"))
43 return []
44 }
45 }
46}
47
48/// A button that opens the sharing services picker under itself with `items`; `chose` runs once
49/// a service is chosen.
50struct SharingButton: NSViewRepresentable {
51 let title: String
52 let items: () -> [Any]
53 let chose: () -> Void
54
55 func makeCoordinator() -> Coordinator { Coordinator(self) }
56
57 func makeNSView(context: Context) -> NSButton {
58 let button = NSButton(title: title, target: context.coordinator, action: #selector(Coordinator.click(_:)))
59 button.bezelStyle = .push
60 button.keyEquivalent = "\r"
61 return button
62 }
63
64 func updateNSView(_ button: NSButton, context: Context) {
65 context.coordinator.parent = self
66 button.title = title
67 }
68
69 @MainActor
70 final class Coordinator: NSObject, NSSharingServicePickerDelegate, NSSharingServiceDelegate {
71 var parent: SharingButton
72
73 init(_ parent: SharingButton) {
74 self.parent = parent
75 }
76
77 @objc func click(_ sender: NSButton) {
78 let items = parent.items()
79 guard !items.isEmpty else { return }
80 let picker = NSSharingServicePicker(items: items)
81 picker.delegate = self
82 picker.show(relativeTo: sender.bounds, of: sender, preferredEdge: .minY)
83 }
84
85 /// The sheet stays while a service such as AirDrop shows its own sheet on it.
86 nonisolated func sharingServicePicker(_ picker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> (any NSSharingServiceDelegate)? {
87 self
88 }
89
90 nonisolated func sharingService(_ sharingService: NSSharingService, didShareItems items: [Any]) {
91 MainActor.assumeIsolated { parent.chose() }
92 }
93 }
94}
Sources/OrgstarMobile/EditorScreen.swift +23 −1 · view
@@ -95,6 +95,7 @@ struct EditorScreen: View {
95 /// Rename Tag or Rename TODO Keyword, starting from this name. 95 /// Rename Tag or Rename TODO Keyword, starting from this name.
96 case rename(ReplaceKind, String) 96 case rename(ReplaceKind, String)
97 case lint 97 case lint
98 case shareSubtree(SubtreeShare)
98 /// The subtree at this offset, to export. 99 /// The subtree at this offset, to export.
99 case exportSubtree(Int) 100 case exportSubtree(Int)
100 101
@@ -114,6 +115,7 @@ struct EditorScreen: View {
114 case .graph: "graph" 115 case .graph: "graph"
115 case .rename(let kind, _): kind.rawValue 116 case .rename(let kind, _): kind.rawValue
116 case .lint: "lint" 117 case .lint: "lint"
118 case .shareSubtree(let share): share.id.uuidString
117 case .exportSubtree: "exportSubtree" 119 case .exportSubtree: "exportSubtree"
118 } 120 }
119 } 121 }
@@ -247,6 +249,8 @@ struct EditorScreen: View {
247 RenameScreen(kind: kind, workspace: workspace, session: session, initial: initial) { message = $0 } 249 RenameScreen(kind: kind, workspace: workspace, session: session, initial: initial) { message = $0 }
248 case .lint: 250 case .lint:
249 LintScreen(workspace: workspace, session: session, path: path) { offset in editor?.reveal(offset) } 251 LintScreen(workspace: workspace, session: session, path: path) { offset in editor?.reveal(offset) }
252 case .shareSubtree(let share):
253 SubtreeShareScreen(share: share) { message = $0 }
250 } 254 }
251 } 255 }
252 .fileImporter(isPresented: $importingTable, allowedContentTypes: [.commaSeparatedText, .tabSeparatedText, .plainText]) { result in 256 .fileImporter(isPresented: $importingTable, allowedContentTypes: [.commaSeparatedText, .tabSeparatedText, .plainText]) { result in
@@ -316,6 +320,7 @@ struct EditorScreen: View {
316 // A pane command moved focus here. 320 // A pane command moved focus here.
317 .onChange(of: isFocused) { 321 .onChange(of: isFocused) {
318 countVersions() 322 countVersions()
323 if isFocused { model.handoffPath = path }
319 guard isFocused, let textView, !textView.isFirstResponder else { return } 324 guard isFocused, let textView, !textView.isFirstResponder else { return }
320 editor?.focus(textView) 325 editor?.focus(textView)
321 textView.becomeFirstResponder() 326 textView.becomeFirstResponder()
@@ -334,6 +339,7 @@ struct EditorScreen: View {
334 .onDisappear { 339 .onDisappear {
335 // Typing the reader shows next, and a save, don't wait for the autosave delay. 340 // Typing the reader shows next, and a save, don't wait for the autosave delay.
336 if session.dirtyPaths.contains(path) { _ = session.save(path) } 341 if session.dirtyPaths.contains(path) { _ = session.save(path) }
342 if model.handoffPath == path { model.handoffPath = nil }
337 } 343 }
338 } 344 }
339 345
@@ -401,6 +407,7 @@ struct EditorScreen: View {
401 session.focused = pane 407 session.focused = pane
402 bind(editor) 408 bind(editor)
403 editor.focus(view) 409 editor.focus(view)
410 model.handoffPath = path
404 } 411 }
405 // A kept editor missed settings changed while it was off screen. 412 // A kept editor missed settings changed while it was off screen.
406 editor.options = editorOptions 413 editor.options = editorOptions
@@ -442,6 +449,7 @@ struct EditorScreen: View {
442 editor.createID = { [weak session] item in session.flatMap { CompletionSources.createID(item, session: $0) } } 449 editor.createID = { [weak session] item in session.flatMap { CompletionSources.createID(item, session: $0) } }
443 editor.otherBuffers = { [weak session, path] in session.map { CompletionSources.otherBuffers($0, excluding: path) } ?? [] } 450 editor.otherBuffers = { [weak session, path] in session.map { CompletionSources.otherBuffers($0, excluding: path) } ?? [] }
444 editor.onChange = { [weak session] in session?.bufferChanged(path) } 451 editor.onChange = { [weak session] in session?.bufferChanged(path) }
452 editor.onSelect = { [weak model] in model?.handoff.changed() }
445 editor.onMessage = { message = $0 } 453 editor.onMessage = { message = $0 }
446 editor.onPrompt = { prompt, reply in self.prompt = PromptRequest(prompt: prompt, reply: reply) } 454 editor.onPrompt = { prompt, reply in self.prompt = PromptRequest(prompt: prompt, reply: reply) }
447 editor.onLink = { link in follow(link) } 455 editor.onLink = { link in follow(link) }
@@ -470,6 +478,12 @@ struct EditorScreen: View {
470 sheet = .export 478 sheet = .export
471 } else if id == EditorScreen.exportSubtreeCommand { 479 } else if id == EditorScreen.exportSubtreeCommand {
472 exportSubtree() 480 exportSubtree()
481 } else if id == "app.share-subtree" {
482 if let caret = self.editor?.editContext().caret, let share = session.subtreeShare(path, at: caret) {
483 sheet = .shareSubtree(share)
484 } else {
485 message = String(localized: "Not in a subtree")
486 }
473 } else if id == "app.export.html-open" { 487 } else if id == "app.export.html-open" {
474 exportHTMLAndOpen() 488 exportHTMLAndOpen()
475 } else if id == "app.export-body-only" { 489 } else if id == "app.export-body-only" {
@@ -517,6 +531,12 @@ struct EditorScreen: View {
517 sheet = .rename(kind, context.map { kind.initial(text: $0.text, caret: $0.caret, keywords: $0.tree.settings.todoKeywordNames) } ?? "") 531 sheet = .rename(kind, context.map { kind.initial(text: $0.text, caret: $0.caret, keywords: $0.tree.settings.todoKeywordNames) } ?? "")
518 } else if id == "app.lint" { 532 } else if id == "app.lint" {
519 if FileLint.applies(to: path) { sheet = .lint } else { message = String(localized: "Lint File works on Org files", comment: "Lint File in a file that isn't Org") } 533 if FileLint.applies(to: path) { sheet = .lint } else { message = String(localized: "Lint File works on Org files", comment: "Lint File in a file that isn't Org") }
534 } else if id == "app.working-copy.sync" {
535 if let root = model.workingCopy.root(containing: path, roots: workspace.rootPaths) {
536 model.workingCopy.sync(root, session: session)
537 } else {
538 message = String(localized: "This folder doesn't sync with Working Copy; turn it on in Settings ▸ Working Copy.", comment: "Sync with Working Copy in a folder that isn't set up")
539 }
520 } else if id == "app.toggle-markup" { 540 } else if id == "app.toggle-markup" {
521 model.showMarkup.toggle() 541 model.showMarkup.toggle()
522 } else if MobileEditor.linkCommands.contains(id) { 542 } else if MobileEditor.linkCommands.contains(id) {
@@ -1047,6 +1067,7 @@ struct CommandPalette: View {
1047 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), 1067 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"),
1048 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"), 1068 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"),
1049 ("app.archive", "Archive Subtree"), ("app.export-dialog", "Export…"), ("app.export-subtree-dialog", "Export Subtree…"), 1069 ("app.archive", "Archive Subtree"), ("app.export-dialog", "Export…"), ("app.export-subtree-dialog", "Export Subtree…"),
1070 ("app.share-subtree", "Share Subtree…"),
1050 ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"), 1071 ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"),
1051 ("app.export-body-only", "Turn Body-Only Export On or Off"), 1072 ("app.export-body-only", "Turn Body-Only Export On or Off"),
1052 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"), 1073 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"),
@@ -1055,6 +1076,7 @@ struct CommandPalette: View {
1055 ("app.toggle-markup", "Show or Hide Markup"), ("app.word-count", "Word Count"), 1076 ("app.toggle-markup", "Show or Hide Markup"), ("app.word-count", "Word Count"),
1056 ("org.snippet.next-field", "Next Snippet Field"), ("org.snippet.previous-field", "Previous Snippet Field"), 1077 ("org.snippet.next-field", "Next Snippet Field"), ("org.snippet.previous-field", "Previous Snippet Field"),
1057 ("app.recovery", "Recovery Versions…"), ("app.sync-conflicts", "Resolve Sync Conflicts…"), ("app.lint", "Lint File"), 1078 ("app.recovery", "Recovery Versions…"), ("app.sync-conflicts", "Resolve Sync Conflicts…"), ("app.lint", "Lint File"),
1079 ("app.working-copy.sync", "Sync with Working Copy"),
1058 ("org.toggle-inline-images", "Show or Hide Inline Images"), ("org.toggle-inline-images-linked", "Show or Hide Inline Images, Including Described Links"), ("org.latex-preview", "Show or Hide LaTeX Previews"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), ("editor.toggle-auto-fill", "Turn Auto Fill On or Off"), 1080 ("org.toggle-inline-images", "Show or Hide Inline Images"), ("org.toggle-inline-images-linked", "Show or Hide Inline Images, Including Described Links"), ("org.latex-preview", "Show or Hide LaTeX Previews"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), ("editor.toggle-auto-fill", "Turn Auto Fill On or Off"),
1059 ("editor.complete", "Complete at Point"), ("editor.dabbrev-expand", "Expand Word"), ("editor.dabbrev-completion", "Complete Word"), 1081 ("editor.complete", "Complete at Point"), ("editor.dabbrev-expand", "Expand Word"), ("editor.dabbrev-completion", "Complete Word"),
1060 ("edit.isearch-forward", "Incremental Search"), ("edit.isearch-backward", "Incremental Search Backward"), 1082 ("edit.isearch-forward", "Incremental Search"), ("edit.isearch-backward", "Incremental Search Backward"),
@@ -1140,7 +1162,7 @@ struct CommandPalette: View {
1140 switch id { 1162 switch id {
1141 case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions") 1163 case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions")
1142 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") 1164 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")
1143 case EditorScreen.exportSubtreeCommand: 1165 case EditorScreen.exportSubtreeCommand, "app.share-subtree":
1144 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") 1166 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")
1145 default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context) 1167 default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context)
1146 } 1168 }
Sources/OrgstarMobile/ExportMenu.swift +45 · view
@@ -338,4 +338,49 @@ struct SubtreeExportScreen: View {
338 } 338 }
339 } 339 }
340} 340}
341
342/// Share Subtree…: the entry at the caret as an org file, with its attachments as separate items
343/// if chosen, or as text.
344struct SubtreeShareScreen: View {
345 let share: SubtreeShare
346 var report: (String) -> Void = { _ in }
347 @State private var file: URL?
348 @State private var withAttachments = false
349 @Environment(\.dismiss) private var dismiss
350
351 var body: some View {
352 NavigationStack {
353 List {
354 Section {
355 if let file {
356 ShareLink(items: share.files(file: file, withAttachments: withAttachments)) {
357 Label("Share as Org File", systemImage: "doc")
358 }
359 }
360 if !share.attachments.isEmpty {
361 Toggle("Include \(share.attachments.count) attachments", isOn: $withAttachments)
362 }
363 } footer: {
364 Text(verbatim: share.fileName)
365 }
366 Section {
367 ShareLink(item: share.text, preview: SharePreview(share.fileName)) {
368 Label("Share as Text", systemImage: "text.alignleft")
369 }
370 }
371 }
372 .navigationTitle("Share Subtree")
373 .navigationBarTitleDisplayMode(.inline)
374 .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } }
375 .onAppear {
376 guard file == nil else { return }
377 do {
378 file = try share.writeFile()
379 } catch {
380 report(String(localized: "Can't share \(share.fileName): \(error.localizedDescription)"))
381 }
382 }
383 }
384 }
385}
341#endif 386#endif
Sources/OrgstarMobile/FoldersScreen.swift +23 −1 · view
@@ -17,6 +17,8 @@ struct FoldersScreen: View {
17 @State private var deletingRoot: String? 17 @State private var deletingRoot: String?
18 /// The added folder whose removal from orgstar is being confirmed. 18 /// The added folder whose removal from orgstar is being confirmed.
19 @State private var removingRoot: String? 19 @State private var removingRoot: String?
20 /// The added folder whose Working Copy settings are showing.
21 @State private var workingCopyRoot: String?
20 @Environment(MobileModel.self) private var model 22 @Environment(MobileModel.self) private var model
21 23
22 var body: some View { 24 var body: some View {
@@ -33,13 +35,17 @@ struct FoldersScreen: View {
33 Text((root as NSString).lastPathComponent) 35 Text((root as NSString).lastPathComponent)
34 Spacer() 36 Spacer()
35 Menu { 37 Menu {
38 workingCopyButtons(root)
36 removeButton(root) 39 removeButton(root)
37 } label: { 40 } label: {
38 Label("Folder Actions", systemImage: "ellipsis.circle").labelStyle(.iconOnly) 41 Label("Folder Actions", systemImage: "ellipsis.circle").labelStyle(.iconOnly)
39 } 42 }
40 .textCase(nil) 43 .textCase(nil)
41 } 44 }
42 .contextMenu { removeButton(root) } 45 .contextMenu {
46 workingCopyButtons(root)
47 removeButton(root)
48 }
43 } 49 }
44 } 50 }
45 if let error = workspace.lastError { 51 if let error = workspace.lastError {
@@ -78,6 +84,9 @@ struct FoldersScreen: View {
78 .navigationDestination(for: FolderRoute.self) { route in 84 .navigationDestination(for: FolderRoute.self) { route in
79 FolderPage(workspace: workspace, session: session, route: route) 85 FolderPage(workspace: workspace, session: session, route: route)
80 } 86 }
87 .sheet(isPresented: Binding { workingCopyRoot != nil } set: { if !$0 { workingCopyRoot = nil } }) {
88 if let root = workingCopyRoot { WorkingCopyFolderScreen(root: root) }
89 }
81 .confirmDeletion($deleting, workspace: workspace, session: session) { changes += 1 } 90 .confirmDeletion($deleting, workspace: workspace, session: session) { changes += 1 }
82 .createItem($creating, workspace: workspace) { changes += 1 } 91 .createItem($creating, workspace: workspace) { changes += 1 }
83 .newFromTemplate($templating, workspace: workspace, session: session) 92 .newFromTemplate($templating, workspace: workspace, session: session)
@@ -133,6 +142,19 @@ struct FoldersScreen: View {
133 } 142 }
134} 143}
135extension FoldersScreen { 144extension FoldersScreen {
145 /// Sync for a folder set up with Working Copy, and its settings for one that is set up or
146 /// a git repository; others are set up in Settings ▸ Working Copy.
147 @ViewBuilder
148 private func workingCopyButtons(_ root: String) -> some View {
149 let setUp = model.workingCopy.folders.folder(root) != nil
150 if setUp {
151 Button("Sync with Working Copy", systemImage: "arrow.triangle.2.circlepath") { model.workingCopy.sync(root, session: session) }
152 }
153 if setUp || WorkingCopy.isRepository(root) {
154 Button("Working Copy…", systemImage: "arrow.triangle.branch") { workingCopyRoot = root }
155 }
156 }
157
136 private func removeButton(_ root: String) -> some View { 158 private func removeButton(_ root: String) -> some View {
137 Button("Remove from orgstar…", systemImage: "folder.badge.minus", role: .destructive) { removingRoot = root } 159 Button("Remove from orgstar…", systemImage: "folder.badge.minus", role: .destructive) { removingRoot = root }
138 } 160 }
Sources/OrgstarMobile/MobileEditor.swift +5 −1 · view
@@ -110,6 +110,8 @@ final class MobileEditor: NSObject, DocumentBuffer {
110 var onColumnView: ((ColumnView.View) -> Void)? 110 var onColumnView: ((ColumnView.View) -> Void)?
111 /// Commands the app runs, as `app.clock.in`. 111 /// Commands the app runs, as `app.clock.in`.
112 var onAppCommand: ((String) -> Void)? 112 var onAppCommand: ((String) -> Void)?
113 /// The caret or selection moved.
114 var onSelect: (() -> Void)?
113 /// Where paste looks for an image; scripts checking the app set another. 115 /// Where paste looks for an image; scripts checking the app set another.
114 static var pasteboard = UIPasteboard.general 116 static var pasteboard = UIPasteboard.general
115 /// Files dropped at the caret; nil leaves them to the text view. 117 /// Files dropped at the caret; nil leaves them to the text view.
@@ -509,8 +511,9 @@ final class MobileEditor: NSObject, DocumentBuffer {
509 "app.rename-tag", "app.rename-todo-keyword": return onAppCommand != nil 511 "app.rename-tag", "app.rename-todo-keyword": return onAppCommand != nil
510 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true 512 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true
511 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil 513 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
512 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 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
513 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil 515 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil
516 case "app.working-copy.sync": return onAppCommand != nil
514 case _ where Self.linkCommands.contains(id): return onAppCommand != nil 517 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
515 case "org.link.open": return OpenLinkAtPoint().applies(in: context) 518 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
516 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand": 519 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand":
@@ -734,6 +737,7 @@ extension MobileEditor: UITextViewDelegate {
734 if textView.isFirstResponder { focus(textView) } 737 if textView.isFirstResponder { focus(textView) }
735 guard textView === self.textView else { return } 738 guard textView === self.textView else { return }
736 selectionChanged() 739 selectionChanged()
740 onSelect?()
737 if let open = completionList, textView.selectedRange.location != open.completion.range.upperBound { refreshCompletion() } 741 if let open = completionList, textView.selectedRange.location != open.completion.range.upperBound { refreshCompletion() }
738 } 742 }
739 743
Sources/OrgstarMobile/MobileModel.swift +12 · view
@@ -47,6 +47,14 @@ final class MobileModel {
47 var watchCaptures = 0 47 var watchCaptures = 0
48 /// Reminders for the agenda, with `agenda-reminders`. 48 /// Reminders for the agenda, with `agenda-reminders`.
49 let reminderLists = ReminderLists() 49 let reminderLists = ReminderLists()
50 /// The file and caret of the editor on screen, advertised for Handoff.
51 @ObservationIgnored let handoff = HandoffAdvertiser()
52 /// Folders synced through Working Copy.
53 let workingCopy = WorkingCopySync()
54 /// The file of the editor on screen; nil when none is.
55 @ObservationIgnored var handoffPath: String? {
56 didSet { if handoffPath != oldValue { handoff.changed() } }
57 }
50 58
51 struct AgendaDays: Equatable { 59 struct AgendaDays: Equatable {
52 let start: Int 60 let start: Int
@@ -99,6 +107,10 @@ final class MobileModel {
99 watchConfig() 107 watchConfig()
100 // `org-clock-out-when-done`, and the reminder when the Effort runs out. 108 // `org-clock-out-when-done`, and the reminder when the Effort runs out.
101 clock.notifications = SystemReminderCenter() 109 clock.notifications = SystemReminderCenter()
110 handoff.place = { [weak self] in
111 guard let self, let path = self.handoffPath, let workspace = self.workspace else { return nil }
112 return self.session.handoffPlace(path, roots: workspace.rootPaths)
113 }
102 session.textChanged = { [weak self] path in 114 session.textChanged = { [weak self] path in
103 guard let self else { return } 115 guard let self else { return }
104 _ = self.clock.textChanged(path, self.session) 116 _ = self.clock.textChanged(path, self.session)
Sources/OrgstarMobile/OrgstarMobileApp.swift +35 −1 · view
@@ -73,6 +73,25 @@ final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCent
73 } 73 }
74} 74}
75 75
76/// Files continued from another device, and what Working Copy's syncs come to.
77private struct HandoffAndSync: ViewModifier {
78 let model: MobileModel
79 let open: (HandoffPlace) -> Void
80 @Binding var message: String?
81
82 func body(content: Content) -> some View {
83 content
84 .onContinueUserActivity(HandoffPlace.activityType) { activity in
85 if let place = HandoffPlace(userInfo: activity.userInfo) { open(place) }
86 }
87 .onChange(of: model.workingCopy.message) {
88 guard let text = model.workingCopy.message else { return }
89 model.workingCopy.message = nil
90 message = text
91 }
92 }
93}
94
76/// A tab on iPhone, or a row of the sidebar on a regular-width iPad, which also lists search 95/// A tab on iPhone, or a row of the sidebar on a regular-width iPad, which also lists search
77/// and each added folder. 96/// and each added folder.
78enum AppTab: Hashable { case agenda, search, folders, folder(String), settings } 97enum AppTab: Hashable { case agenda, search, folders, folder(String), settings }
@@ -398,6 +417,7 @@ struct RootView: View {
398 } 417 }
399 workspace.startWatching() 418 workspace.startWatching()
400 await workspace.refresh() 419 await workspace.refresh()
420 model.workingCopy.appOpened(roots: workspace.rootPaths, session: session)
401 } 421 }
402 .task { 422 .task {
403 while !Task.isCancelled { 423 while !Task.isCancelled {
@@ -422,9 +442,12 @@ struct RootView: View {
422 } 442 }
423 takeShared() 443 takeShared()
424 model.reloadConfig() 444 model.reloadConfig()
445 model.handoff.update()
446 model.workingCopy.appOpened(roots: workspace.rootPaths, session: session)
425 Task { await workspace.refresh() } 447 Task { await workspace.refresh() }
426 } 448 }
427 .onOpenURL(perform: handle) 449 .onOpenURL(perform: handle)
450 .modifier(HandoffAndSync(model: model, open: continueHandoff, message: $message))
428 // The Live Activity follows the clock, wherever it starts or stops. 451 // The Live Activity follows the clock, wherever it starts or stops.
429 .task { 452 .task {
430 LiveClock.publish(model.clock) 453 LiveClock.publish(model.clock)
@@ -468,7 +491,9 @@ struct RootView: View {
468 491
469 /// A widget's or the Live Activity's link, or an org-protocol URL. 492 /// A widget's or the Live Activity's link, or an org-protocol URL.
470 private func handle(_ url: URL) { 493 private func handle(_ url: URL) {
471 if let link = AppLink(url: url) { 494 if let callback = WorkingCopy.callback(url) {
495 model.workingCopy.finished(callback, workspace: workspace, session: session)
496 } else if let link = AppLink(url: url) {
472 open(link) 497 open(link)
473 } else if let request = CaptureRequest(link: url.absoluteString) { 498 } else if let request = CaptureRequest(link: url.absoluteString) {
474 capture = request 499 capture = request
@@ -480,6 +505,15 @@ struct RootView: View {
480 } 505 }
481 } 506 }
482 507
508 /// A file continued from another device, in the editor at the caret's heading or line there.
509 private func continueHandoff(_ place: HandoffPlace) {
510 let match = place.resolve(roots: workspace.rootPaths)
511 guard case .file(let path) = match else { return message = place.problem(match) }
512 let offset = session.text(of: path).map { place.offset(in: $0, settings: session.defaults) } ?? 0
513 tab = .agenda
514 agendaPath.append(EditorRoute(path: path, offset: offset))
515 }
516
483 /// A tab or sidebar row; on iPhone, search is pushed on the agenda. 517 /// A tab or sidebar row; on iPhone, search is pushed on the agenda.
484 private func show(_ destination: AppTab) { 518 private func show(_ destination: AppTab) {
485 if destination == .search, sizeClass != .regular { 519 if destination == .search, sizeClass != .regular {
Sources/OrgstarMobile/SettingsScreen.swift +7 · view
@@ -78,6 +78,13 @@ struct SettingsScreen: View {
78 } footer: { 78 } footer: {
79 Text("The buttons above the on-screen keyboard.") 79 Text("The buttons above the on-screen keyboard.")
80 } 80 }
81 if let workspace = model.workspace {
82 Section {
83 NavigationLink("Working Copy") { WorkingCopyScreen(workspace: workspace) }
84 } footer: {
85 Text("Sync folders that are git repositories in Working Copy.")
86 }
87 }
81 Section { 88 Section {
82 let _ = model.settingsVersion 89 let _ = model.settingsVersion
83 Toggle("Show days without entries", isOn: Binding { 90 Toggle("Show days without entries", isOn: Binding {
Sources/OrgstarMobile/WorkingCopySync.swift added +187 · view
@@ -0,0 +1,187 @@
1#if os(iOS)
2import OrgApp
3import SwiftUI
4import UIKit
5
6/// Syncing folders through Working Copy: saves every file, opens Working Copy's commit, pull
7/// and push chain, and takes its answer from `orgstar://working-copy/…`.
8@MainActor
9@Observable
10final class WorkingCopySync {
11 /// What the last sync, or its start, came to, for the app's message line.
12 var message: String?
13 /// Folders waiting for the one being synced, by root.
14 @ObservationIgnored private var queue: [String] = []
15 @ObservationIgnored private var running: String?
16 /// When a sync last started: coming back from Working Copy makes the app active again,
17 /// which mustn't start another.
18 @ObservationIgnored private var started: Date?
19 @ObservationIgnored let folders = WorkingCopy.Folders()
20
21 /// The folder `path` is in, when it is set up.
22 func root(containing path: String, roots: [String]) -> String? {
23 let set = folders.all
24 return roots.filter { set[$0] != nil && (path == $0 || path.hasPrefix($0 + "/")) }.max { $0.count < $1.count }
25 }
26
27 /// Syncs `root`, after the folders already waiting.
28 func sync(_ root: String, session: DocumentSession) {
29 guard running != root, !queue.contains(root) else { return }
30 queue.append(root)
31 if running == nil { next(session: session) }
32 }
33
34 /// The app became active: the folders that sync on opening, unless a sync started a moment
35 /// ago and this is the return from Working Copy.
36 func appOpened(roots: [String], session: DocumentSession) {
37 if let started, Date().timeIntervalSince(started) < 120 { return }
38 let set = folders.all
39 for root in roots where set[root]?.syncOnOpen == true { sync(root, session: session) }
40 }
41
42 private func next(session: DocumentSession) {
43 guard running == nil, !queue.isEmpty else { return }
44 let root = queue.removeFirst()
45 let name = (root as NSString).lastPathComponent
46 guard let folder = folders.folder(root) else { return next(session: session) }
47 // Working Copy commits what is on disk.
48 let unsaved = session.dirtyPaths.filter { !session.save($0) }.sorted()
49 if let failed = unsaved.first {
50 message = String(localized: "\(name) wasn't synced: \((failed as NSString).lastPathComponent) couldn't be saved.", comment: "Working Copy sync")
51 queue.removeAll()
52 return
53 }
54 guard let key = WorkingCopy.Key.stored() else {
55 message = String(localized: "\(name) wasn't synced: set Working Copy's URL key in Settings ▸ Working Copy.", comment: "Working Copy sync")
56 queue.removeAll()
57 return
58 }
59 running = root
60 started = Date()
61 UIApplication.shared.open(WorkingCopy.syncURL(repo: folder.repository, key: key)) { [weak self] opened in
62 guard let self, !opened else { return }
63 self.running = nil
64 self.queue.removeAll()
65 self.message = String(localized: "\(name) wasn't synced: Working Copy isn't installed or couldn't be opened.", comment: "Working Copy sync")
66 }
67 }
68
69 /// Working Copy's answer.
70 func finished(_ callback: WorkingCopy.Callback, workspace: WorkspaceModel, session: DocumentSession) {
71 running = nil
72 switch callback {
73 case .success(let repo):
74 let name = folders.root(of: repo).map { ($0 as NSString).lastPathComponent } ?? repo
75 message = String(localized: "Synced \(name) with Working Copy", comment: "Working Copy sync")
76 Task { await workspace.refresh() }
77 next(session: session)
78 case .failure(let repo, let reason):
79 let name = folders.root(of: repo).map { ($0 as NSString).lastPathComponent } ?? repo
80 message = reason.map { String(localized: "\(name) wasn't synced: \($0)", comment: "Working Copy sync; Working Copy's error follows") }
81 ?? String(localized: "\(name) wasn't synced: Working Copy reported an error.", comment: "Working Copy sync")
82 queue.removeAll()
83 }
84 }
85}
86
87/// Settings ▸ Working Copy: the URL key, and for each folder whether it syncs.
88struct WorkingCopyScreen: View {
89 let workspace: WorkspaceModel
90 @State private var key = WorkingCopy.Key.stored() ?? ""
91 @State private var keyStored = WorkingCopy.Key.stored() != nil
92
93 var body: some View {
94 Form {
95 Section {
96 SecureField("URL key", text: $key)
97 .textInputAutocapitalization(.never)
98 .autocorrectionDisabled()
99 .onSubmit(storeKey)
100 Button(keyStored ? "Replace Key" : "Save Key", action: storeKey).disabled(key.isEmpty)
101 if keyStored {
102 Button("Remove Key", role: .destructive) {
103 WorkingCopy.Key.store(nil)
104 key = ""
105 keyStored = false
106 }
107 }
108 } footer: {
109 Text("Working Copy runs orgstar's sync only with the URL key from Working Copy's settings. orgstar keeps it in the Keychain on this device.")
110 }
111 ForEach(workspace.rootPaths, id: \.self) { root in
112 WorkingCopyFolderSection(root: root)
113 }
114 }
115 .navigationTitle("Working Copy")
116 }
117
118 private func storeKey() {
119 guard !key.isEmpty else { return }
120 keyStored = WorkingCopy.Key.store(key)
121 }
122}
123
124/// Whether a folder syncs with Working Copy, the repository's name there, and whether it syncs
125/// when orgstar opens.
126struct WorkingCopyFolderSection: View {
127 let root: String
128 @State private var folder: WorkingCopy.Folder?
129
130 init(root: String) {
131 self.root = root
132 _folder = State(initialValue: WorkingCopy.Folders().folder(root))
133 }
134
135 var body: some View {
136 let name = (root as NSString).lastPathComponent
137 Section {
138 Toggle("Sync with Working Copy", isOn: Binding {
139 folder != nil
140 } set: { on in
141 save(on ? WorkingCopy.Folder(repository: name) : nil)
142 })
143 if let folder {
144 LabeledContent("Repository") {
145 TextField(name, text: Binding { folder.repository } set: { value in
146 save(WorkingCopy.Folder(repository: value.isEmpty ? name : value, syncOnOpen: folder.syncOnOpen))
147 })
148 .multilineTextAlignment(.trailing)
149 .textInputAutocapitalization(.never)
150 .autocorrectionDisabled()
151 }
152 Toggle("Sync when orgstar opens", isOn: Binding { folder.syncOnOpen } set: { on in
153 save(WorkingCopy.Folder(repository: folder.repository, syncOnOpen: on))
154 })
155 }
156 } header: {
157 Text(verbatim: name)
158 } footer: {
159 if folder != nil {
160 Text("Sync saves every file, then Working Copy commits every changed file in the repository, pulls and pushes. The repository is its name in Working Copy's list.")
161 } else if WorkingCopy.isRepository(root) {
162 Text("This folder is a git repository.")
163 }
164 }
165 }
166
167 private func save(_ new: WorkingCopy.Folder?) {
168 folder = new
169 WorkingCopy.Folders().set(new, for: root)
170 }
171}
172
173/// A folder's Working Copy settings on their own, from its menu in Folders.
174struct WorkingCopyFolderScreen: View {
175 let root: String
176 @Environment(\.dismiss) private var dismiss
177
178 var body: some View {
179 NavigationStack {
180 Form { WorkingCopyFolderSection(root: root) }
181 .navigationTitle("Working Copy")
182 .navigationBarTitleDisplayMode(.inline)
183 .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } }
184 }
185 }
186}
187#endif
Tests/OrgAppTests/HandoffTests.swift added +99 · view
@@ -0,0 +1,99 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5struct HandoffTests {
6 static let text = """
7 #+TITLE: Notes
8 * Work
9 ** Project
10 :PROPERTIES:
11 :ID: project-1
12 :END:
13 first line
14 second line
15 ** Other
16 * Home
17
18 """
19
20 @Test func placeRoundTripsThroughUserInfo() throws {
21 let path = "/Users/a/Library/Mobile Documents/com~apple~CloudDocs/org/notes/todo.org"
22 let caret = (Self.text as NSString).range(of: "second").location + 3
23 let place = try #require(HandoffPlace.make(path: path, text: Self.text, caret: caret, roots: ["/Users/a/Library/Mobile Documents/com~apple~CloudDocs/org"]))
24 #expect(place.folder == "org")
25 #expect(place.file == "notes/todo.org")
26 #expect(place.cloudPath == "com~apple~CloudDocs/org/notes/todo.org")
27 #expect(place.outline == ["Work", "Project"])
28 #expect(place.id == "project-1")
29 #expect(place.line == 8)
30 #expect(place.headingLine == 3)
31 // Through a property list, as Handoff sends it.
32 let data = try PropertyListSerialization.data(fromPropertyList: place.userInfo, format: .binary, options: 0)
33 let info = try #require(try PropertyListSerialization.propertyList(from: data, format: nil) as? [AnyHashable: Any])
34 #expect(HandoffPlace(userInfo: info) == place)
35 #expect(!place.userInfo.values.contains { ($0 as? String)?.contains("second line") == true })
36 }
37
38 @Test func nothingIsAdvertisedOutsideTheFoldersOrForEncryptedFiles() {
39 #expect(HandoffPlace.make(path: "/elsewhere/a.org", text: "", caret: 0, roots: ["/org"]) == nil)
40 #expect(HandoffPlace.make(path: "/org/secret.org.gpg", text: "", caret: 0, roots: ["/org"]) == nil)
41 #expect(HandoffPlace.make(path: "/org/a.org", text: "", caret: 0, roots: ["/org"])?.file == "a.org")
42 // The innermost of nested roots.
43 #expect(HandoffPlace.make(path: "/org/work/a.org", text: "", caret: 0, roots: ["/org", "/org/work"])?.folder == "work")
44 }
45
46 @Test func userInfoMustNameAFileInsideTheFolder() {
47 #expect(HandoffPlace(userInfo: ["folder": "org", "file": "../etc/passwd"]) == nil)
48 #expect(HandoffPlace(userInfo: ["folder": "org", "file": "/etc/passwd"]) == nil)
49 #expect(HandoffPlace(userInfo: ["folder": "org"]) == nil)
50 #expect(HandoffPlace(userInfo: nil) == nil)
51 #expect(HandoffPlace(userInfo: ["folder": "org", "file": "a.org"])?.line == 1)
52 }
53
54 @Test func iCloudFoldersMatchByTheirPathInICloud() {
55 let place = HandoffPlace(folder: "org", cloudPath: "com~apple~CloudDocs/org/notes/todo.org", file: "notes/todo.org",
56 outline: [], id: nil, line: 1, headingLine: 0)
57 let phone = "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/org"
58 #expect(place.resolve(roots: [phone], exists: { _ in true }) == .file(phone + "/notes/todo.org"))
59 // A root higher up in iCloud Drive holds the file too.
60 let drive = "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs"
61 #expect(place.resolve(roots: [drive], exists: { _ in true }) == .file(drive + "/org/notes/todo.org"))
62 // Another iCloud folder named org is not this one, so the name decides only without a match.
63 let other = "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/archive/org"
64 #expect(place.resolve(roots: [other, phone], exists: { _ in true }) == .file(phone + "/notes/todo.org"))
65 }
66
67 @Test func otherFoldersMatchByName() {
68 let place = HandoffPlace(folder: "notes", cloudPath: nil, file: "a/b.org", outline: [], id: nil, line: 1, headingLine: 0)
69 let root = "/private/var/mobile/Containers/Shared/AppGroup/1234/File Provider Storage/notes"
70 #expect(place.resolve(roots: ["/x/org", root], exists: { _ in true }) == .file(root + "/a/b.org"))
71 #expect(place.resolve(roots: ["/x/org"], exists: { _ in true }) == .noFolder)
72 #expect(place.resolve(roots: [root], exists: { _ in false }) == .noFile)
73 // Two folders of that name: the one with the file.
74 #expect(place.resolve(roots: ["/y/notes", root], exists: { $0.hasPrefix(root) }) == .file(root + "/a/b.org"))
75 // An iCloud file on a device without that iCloud folder still matches by name.
76 let cloud = HandoffPlace(folder: "notes", cloudPath: "com~apple~CloudDocs/notes/a/b.org", file: "a/b.org", outline: [], id: nil, line: 1, headingLine: 0)
77 #expect(cloud.resolve(roots: [root], exists: { _ in true }) == .file(root + "/a/b.org"))
78 }
79
80 @Test func caretGoesToTheHeadingByIDThenOutlineThenLine() {
81 let place = HandoffPlace(folder: "org", cloudPath: nil, file: "a.org", outline: ["Work", "Project"], id: "project-1", line: 8, headingLine: 3)
82 let ns = Self.text as NSString
83 let second = ns.range(of: "second line").location
84 #expect(place.offset(in: Self.text) == second)
85 // Lines added above the heading on this device: the heading is found by ID.
86 let moved = "* New\nnew text\n" + Self.text
87 #expect(place.offset(in: moved) == (moved as NSString).range(of: "second line").location)
88 // Without the ID, by the outline path.
89 var byOutline = place
90 byOutline.id = "gone"
91 #expect(byOutline.offset(in: moved) == (moved as NSString).range(of: "second line").location)
92 // Neither: the same line.
93 let unrelated = HandoffPlace(folder: "org", cloudPath: nil, file: "a.org", outline: ["Nope"], id: nil, line: 3, headingLine: 2)
94 #expect(unrelated.offset(in: Self.text) == ns.range(of: "** Project").location)
95 // A line past the heading's text stays in it.
96 let long = HandoffPlace(folder: "org", cloudPath: nil, file: "a.org", outline: ["Work", "Project"], id: nil, line: 40, headingLine: 3)
97 #expect(long.offset(in: Self.text) == ns.range(of: "** Other").location - 1)
98 }
99}
Tests/OrgAppTests/SubtreeShareTests.swift added +92 · view
@@ -0,0 +1,92 @@
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgApp
5
6struct SubtreeShareTests {
7 static let text = """
8 #+TITLE: Notes
9 #+TODO: TODO WAIT | DONE
10 #+STARTUP: overview
11
12 * Other
13 ** TODO Trip to [[https://example.com][Lisbon]]: plans :travel:
14 SCHEDULED: <2026-12-01 Tue>
15 :PROPERTIES:
16 :DIR: trip
17 :END:
18 Flights.
19 *** Hotel
20 :PROPERTIES:
21 :DIR: hotel
22 :END:
23 Booked.
24 *** Secret :crypt:
25 -----BEGIN PGP MESSAGE-----
26
27 jA0ECQMC
28 -----END PGP MESSAGE-----
29
30
31 ** Next
32 """
33
34 @Test func theEntryIsSharedAsTheFileHoldsItPromoted() throws {
35 let caret = (Self.text as NSString).range(of: "Flights").location
36 let share = try #require(SubtreeShare(text: Self.text, at: caret, path: "/nowhere/notes.org", idDir: "data/", inherit: nil))
37 #expect(share.text == """
38 #+TODO: TODO WAIT | DONE
39 #+STARTUP: overview
40
41 * TODO Trip to [[https://example.com][Lisbon]]: plans :travel:
42 SCHEDULED: <2026-12-01 Tue>
43 :PROPERTIES:
44 :DIR: trip
45 :END:
46 Flights.
47 ** Hotel
48 :PROPERTIES:
49 :DIR: hotel
50 :END:
51 Booked.
52 ** Secret :crypt:
53 -----BEGIN PGP MESSAGE-----
54
55 jA0ECQMC
56 -----END PGP MESSAGE-----
57
58 """)
59 #expect(share.fileName == "Trip to Lisbon- plans.org")
60 #expect(share.attachments.isEmpty)
61 #expect(SubtreeShare(text: Self.text, at: 3, path: "/nowhere/notes.org") == nil)
62 }
63
64 @Test func attachmentsOfTheEntryAndItsChildrenComeAsFiles() throws {
65 let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
66 defer { try? FileManager.default.removeItem(at: folder) }
67 let files = FileManager.default
68 for dir in ["trip", "hotel", "trip/inside", "elsewhere"] { try files.createDirectory(at: folder.appendingPathComponent(dir), withIntermediateDirectories: true) }
69 for file in ["trip/ticket.pdf", "trip/.DS_Store", "hotel/booking.png", "elsewhere/no.txt"] { try Data("x".utf8).write(to: folder.appendingPathComponent(file)) }
70 let path = folder.appendingPathComponent("notes.org").path
71 let caret = (Self.text as NSString).range(of: "Flights").location
72 let share = try #require(SubtreeShare(text: Self.text, at: caret, path: path, idDir: "data/", inherit: nil))
73 #expect(share.attachments.map(\.lastPathComponent) == ["ticket.pdf", "booking.png"])
74 // Only the child's own folder for the child.
75 let child = try #require(SubtreeShare(text: Self.text, at: (Self.text as NSString).range(of: "Booked").location, path: path, idDir: "data/", inherit: nil))
76 #expect(child.attachments.map(\.lastPathComponent) == ["booking.png"])
77
78 let file = try share.writeFile()
79 defer { try? files.removeItem(at: file.deletingLastPathComponent()) }
80 #expect(file.lastPathComponent == "Trip to Lisbon- plans.org")
81 #expect(try String(contentsOf: file, encoding: .utf8) == share.text)
82 #expect(share.files(file: file, withAttachments: false) == [file])
83 #expect(share.files(file: file, withAttachments: true).map(\.lastPathComponent) == ["Trip to Lisbon- plans.org", "ticket.pdf", "booking.png"])
84 }
85
86 @Test func fileNamesAreSafe() {
87 #expect(SubtreeShare.fileName("a/b: c?") == "a-b- c-.org")
88 #expect(SubtreeShare.fileName(" ") == "Subtree.org")
89 #expect(SubtreeShare.fileName("..hidden") == "hidden.org")
90 #expect(SubtreeShare.fileName(String(repeating: "x", count: 100)).count == 84)
91 }
92}
Tests/OrgAppTests/WorkingCopyTests.swift added +64 · view
@@ -0,0 +1,64 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5struct WorkingCopyTests {
6 @Test func syncChainsCommitPullAndPush() throws {
7 let url = WorkingCopy.syncURL(repo: "my notes", key: "k3y+/&=", message: "Update from orgstar")
8 #expect(url.scheme == "working-copy")
9 #expect(url.host == "x-callback-url")
10 #expect(url.path == "/chain")
11 let query = try #require(url.query(percentEncoded: true))
12 // Spaces as %20, never +, and reserved characters encoded.
13 #expect(!query.contains("+"))
14 #expect(query.hasPrefix("repo=my%20notes&key=k3y%2B%2F%26%3D&x-success="))
15 #expect(query.hasSuffix("&command=commit&message=Update%20from%20orgstar&limit=999&command=pull&command=push"))
16 let items = try #require(URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems)
17 #expect(items.map(\.name) == ["repo", "key", "x-success", "x-error", "command", "message", "limit", "command", "command"])
18 #expect(items.filter { $0.name == "command" }.map(\.value) == ["commit", "pull", "push"])
19 #expect(items.first { $0.name == "key" }?.value == "k3y+/&=")
20 #expect(items.first { $0.name == "x-success" }?.value == "orgstar://working-copy/success?repo=my%20notes")
21 #expect(items.first { $0.name == "x-error" }?.value == "orgstar://working-copy/error?repo=my%20notes")
22 }
23
24 @Test func callbacksComeBackParsed() throws {
25 let success = try #require(URL(string: "orgstar://working-copy/success?repo=my%20notes"))
26 #expect(WorkingCopy.callback(success) == .success(repo: "my notes"))
27 // Working Copy adds x-callback-url's errorCode and errorMessage.
28 let error = try #require(URL(string: "orgstar://working-copy/error?repo=my%20notes&errorCode=1&errorMessage=Merge%20conflict%20in%20a.org"))
29 #expect(WorkingCopy.callback(error) == .failure(repo: "my notes", message: "Merge conflict in a.org"))
30 let bare = try #require(URL(string: "orgstar://working-copy/error?repo=notes"))
31 #expect(WorkingCopy.callback(bare) == .failure(repo: "notes", message: nil))
32 // The callback the sync asks for, as Working Copy would open it.
33 let built = WorkingCopy.syncURL(repo: "a&b", key: "k")
34 let back = try #require(URLComponents(url: built, resolvingAgainstBaseURL: false)?.queryItems?.first { $0.name == "x-success" }?.value)
35 #expect(WorkingCopy.callback(try #require(URL(string: back))) == .success(repo: "a&b"))
36 // Other links aren't callbacks.
37 #expect(WorkingCopy.callback(try #require(URL(string: "orgstar://agenda"))) == nil)
38 #expect(WorkingCopy.callback(try #require(URL(string: "orgstar://working-copy/other?repo=a"))) == nil)
39 #expect(WorkingCopy.callback(try #require(URL(string: "orgstar://working-copy/success"))) == nil)
40 #expect(AppLink(url: success) == nil)
41 }
42
43 @Test func foldersAreKeptByRootAndFoundByRepository() {
44 let defaults = TestDefaults("WorkingCopyTests")
45 let folders = WorkingCopy.Folders(defaults: defaults)
46 #expect(folders.folder("/notes") == nil)
47 folders.set(WorkingCopy.Folder(repository: "notes"), for: "/notes")
48 folders.set(WorkingCopy.Folder(repository: "work", syncOnOpen: true), for: "/w")
49 #expect(WorkingCopy.Folders(defaults: defaults).folder("/notes") == WorkingCopy.Folder(repository: "notes", syncOnOpen: false))
50 #expect(folders.root(of: "work") == "/w")
51 #expect(folders.root(of: "nope") == nil)
52 folders.set(nil, for: "/notes")
53 #expect(folders.all.keys.sorted() == ["/w"])
54 }
55
56 @Test func aGitFolderIsARepository() throws {
57 let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
58 defer { try? FileManager.default.removeItem(at: root) }
59 try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
60 #expect(!WorkingCopy.isRepository(root.path))
61 try FileManager.default.createDirectory(at: root.appendingPathComponent(".git"), withIntermediateDirectories: true)
62 #expect(WorkingCopy.isRepository(root.path))
63 }
64}
docs/manual/guide/01-files-and-folders.org +25 −1 · view
@@ -332,6 +332,30 @@ The Mac App Store version can't run git and has no Git pane.
332 332
333Files in iCloud Drive that aren't downloaded to the Mac show in the sidebar with a cloud icon and grey text, with the tooltip "Downloading from iCloud". orgstar asks iCloud to download them, and indexes them and lets you open them when they arrive. Files iCloud removes from the Mac to save space keep their index entries until they are back, so search and the agenda still find them. 333Files in iCloud Drive that aren't downloaded to the Mac show in the sidebar with a cloud icon and grey text, with the tooltip "Downloading from iCloud". orgstar asks iCloud to download them, and indexes them and lets you open them when they arrive. Files iCloud removes from the Mac to save space keep their index entries until they are back, so search and the agenda still find them.
334 334
335* Handoff
336
337A file open in the editor can be continued on another Mac, iPhone or iPad signed in to the same Apple Account, with Handoff turned on in each device's settings. The other device shows orgstar's icon in the Dock or the app switcher; choosing it opens the same file in its editor, at the same place.
338
339What is passed is where the file is and where the caret is, never the file's text:
340
341- the name of the added folder the file is in, the file's path inside iCloud when it is in iCloud Drive, and its path inside the folder;
342- the caret's heading (its =ID= when it has one, and the titles of it and the headings above it) and line.
343
344The other device looks for the file in its own added folders. A folder in iCloud Drive is matched by its path in iCloud Drive, which is the same on every device, so it is found even when another folder has the same name; an added folder higher up in iCloud Drive holds the file too. Any other folder, such as one kept by Dropbox, Syncthing or Working Copy, is at a different path on each device and is matched by its name: add it with the same name on both. The caret goes to the heading with that =ID=, or else the heading at that outline path, on the same line within it as on the other device; when neither is found, to the same line of the file. When the device has no folder of that name, or the folder doesn't have the file yet, orgstar says so and opens nothing.
345
346Only files in an added folder are offered, and never an encrypted =.org.gpg= file. On iPhone and iPad, the editor offers its file; the reader and the agenda don't.
347
348* Sharing a subtree
349
350File ▸ Share Subtree… (also in the command palette, and in Commands on iPhone and iPad, under Export) sends the entry at the caret through AirDrop, Mail, Messages or another app:
351
352- Org file :: the entry as an =.org= file named after its heading. The file holds the keyword lines at the top of your file (such as =#+TODO= and =#+STARTUP=, but not =#+TITLE=) and the entry with everything under it, as it is in the file, promoted so the entry is a level-1 heading.
353- Text :: the same text, for an app that takes text.
354
355When the entry or an entry under it has attachments, Include attachments sends each attached file as an item of its own beside the =.org= file. =attachment:= links in the shared file don't reach them on the other side, since the attachment folder isn't sent.
356
357An encrypted entry (=:crypt:=) is shared as the file holds it, still encrypted.
358
335* Encodings and line endings 359* Encodings and line endings
336 360
337orgstar edits UTF-8 files, with or without a byte order mark. 361orgstar edits UTF-8 files, with or without a byte order mark.
@@ -345,4 +369,4 @@ orgstar does not convert between encodings or line endings.
345 369
346* On iOS 370* On iOS
347 371
348The iOS app adds folders from its Folders screen and lists only org files there. Conflicts, Syncthing copies and recovery versions are in the editor's menu; the iOS app doesn't list git commits or commit to git. Files are watched through file presenters rather than FSEvents. See [[file:14-ios.org][iOS]]. 372The iOS app adds folders from its Folders screen and lists only org files there. Conflicts, Syncthing copies and recovery versions are in the editor's menu; the iOS app doesn't list git commits, and commits, pulls and pushes a git folder through the Working Copy app. Files are watched through file presenters rather than FSEvents. See [[file:14-ios.org][iOS]].
docs/manual/guide/03-keys.org +1 · view
@@ -1200,6 +1200,7 @@ No preset binds these. Run them from the palette or a menu, or bind them in =key
1200| History… (=app.recovery=) | Shows the file's recovery versions and, in the download version, its git commits. Recovery Versions… on iOS. | 1200| History… (=app.recovery=) | Shows the file's recovery versions and, in the download version, its git commits. Recovery Versions… on iOS. |
1201| Lint File (=app.lint=) | Lists the problems in the file in a panel under the editor (=org-lint=). File ▸ Lint File. See [[file:02-the-editor.org][The editor]]. | 1201| Lint File (=app.lint=) | Lists the problems in the file in a panel under the editor (=org-lint=). File ▸ Lint File. See [[file:02-the-editor.org][The editor]]. |
1202| Resolve Sync Conflicts… (=app.sync-conflicts=) | Shows the file's sync conflict copies to resolve them. | 1202| Resolve Sync Conflicts… (=app.sync-conflicts=) | Shows the file's sync conflict copies to resolve them. |
1203| Share Subtree… (=app.share-subtree=) | Shares the entry at the caret as an org file, with its attachments if chosen, or as text. File ▸ Share Subtree…. See [[file:01-files-and-folders.org][Files and folders]]. |
1203| Import Table from File… (=app.table-import=) | Asks for a CSV, TSV or space-separated file and inserts it as a table (=org-table-import=). | 1204| Import Table from File… (=app.table-import=) | Asks for a CSV, TSV or space-separated file and inserts it as a table (=org-table-import=). |
1204| Export Table to File… (=app.table-export=) | Writes the table at point to a CSV or TSV file (=org-table-export=). | 1205| Export Table to File… (=app.table-export=) | Writes the table at point to a CSV or TSV file (=org-table-export=). |
1205| Plot Table (=app.plot=) | Plots the table at point as its =#+PLOT:= lines say (=org-plot/gnuplot=, =C-c " g= in the Emacs and Doom presets). | 1206| Plot Table (=app.plot=) | Plots the table at point as its =#+PLOT:= lines say (=org-plot/gnuplot=, =C-c " g= in the Emacs and Doom presets). |
docs/manual/guide/13-configuration.org +11 · view
@@ -176,6 +176,17 @@ Download version only. One row for each folder in the sidebar; a folder that isn
176 176
177The choice is kept on this Mac for the folder's path, not in =config.toml=, since another Mac has other folders. Removing a folder from the sidebar and adding it again keeps it. See [[file:01-files-and-folders.org::*Committing to git][Committing to git]]. 177The choice is kept on this Mac for the folder's path, not in =config.toml=, since another Mac has other folders. Removing a folder from the sidebar and adding it again keeps it. See [[file:01-files-and-folders.org::*Committing to git][Committing to git]].
178 178
179On iPhone and iPad, Settings ▸ Working Copy syncs folders through the Working Copy app instead:
180
181| Control | Choices | Default |
182|--------------------------+-----------------------+--------------------|
183| URL key | Working Copy's key | None |
184| Sync with Working Copy | On or off, per folder | Off |
185| Repository | A name, per folder | The folder's name |
186| Sync when orgstar opens | On or off, per folder | Off |
187
188These are kept on the device, not in =config.toml=: the folders are at other paths on each device, and the key is kept in the Keychain. See [[file:14-ios.org::*Git folders through Working Copy][Git folders through Working Copy]].
189
179** Settings only in config.toml 190** Settings only in config.toml
180 191
181These settings have no control in the Settings window. Some are in the View menu. 192These settings have no control in the Settings window. Some are in the View menu.
docs/manual/guide/14-ios.org +30 · view
@@ -200,6 +200,8 @@ Commands has the org-attach commands, and Attach Photo or Video…, Take Photo
200 200
201Lint File, under File in Commands, lists the problems in the open file with their lines, as the Mac's Lint File panel does; tap one to close the list and move the caret to its line. The checks are the Mac's; see [[file:02-the-editor.org][The editor]]. Run it again after editing to check again. 201Lint File, under File in Commands, lists the problems in the open file with their lines, as the Mac's Lint File panel does; tap one to close the list and move the caret to its line. The checks are the Mac's; see [[file:02-the-editor.org][The editor]]. Run it again after editing to check again.
202 202
203Sync with Working Copy, under File in Commands, syncs the folder of the open file through Working Copy; see Git folders through Working Copy below.
204
203Archive Subtree in Commands (or =C-c C-x C-s= with a hardware keyboard) archives the entry at the caret where =org-archive-location= says, as on the Mac. 205Archive Subtree in Commands (or =C-c C-x C-s= with a hardware keyboard) archives the entry at the caret where =org-archive-location= says, as on the Mac.
204 206
205Commands has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode. 207Commands has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode.
@@ -409,6 +411,8 @@ PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.to
409 411
410Body 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. 412Body 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.
411 413
414Share 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.
415
412The 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. 416The 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.
413 417
414Publishing works from Commands as on the Mac, with the =[[publish]]= projects in =config.toml=. A project that publishes outside your folders asks for a folder the first time, and uses it from then on. See [[file:12-export.org][Export]]. 418Publishing works from Commands as on the Mac, with the =[[publish]]= projects in =config.toml=. A project that publishes outside your folders asks for a folder the first time, and uses it from then on. See [[file:12-export.org][Export]].
@@ -448,6 +452,28 @@ Recovery Versions… (in Commands, and in the editor's toolbar on iPad while the
448 452
449See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work. 453See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work.
450 454
455* Git folders through Working Copy
456
457A folder that is a git repository in [[https://workingcopyapp.com][Working Copy]], added to orgstar from Working Copy's place in the folder picker, works like any other folder. orgstar can also ask Working Copy to commit, pull and push it, so you don't have to switch to Working Copy to sync.
458
459Setting it up, once:
460
4611. In Working Copy's settings, find the URL key it uses for x-callback-url commands. Working Copy runs a command from another app only with this key.
4622. In orgstar, open Settings ▸ Working Copy, enter the key in URL key and tap Save Key. orgstar keeps it in the Keychain on this device only, never in =config.toml= or the app's settings.
4633. In the same screen, turn on Sync with Working Copy for the folder. Repository is the repository's name in Working Copy's list; it starts as the folder's name. Sync when orgstar opens is off; turn it on to sync each time you open orgstar.
464
465For a folder with a =.git= folder at its top, the ⋯ button beside its name in Folders also has Working Copy…, with the same settings. Working Copy's own folders may not show =.git=, so set those up in Settings ▸ Working Copy.
466
467To sync, choose Sync with Working Copy from the folder's ⋯ menu in Folders, or from Commands in the editor of a file in the folder. orgstar saves every open file, then opens Working Copy, which commits every changed file in the repository with the message =Update from orgstar=, pulls, pushes and comes back to orgstar. orgstar says =Synced notes with Working Copy= and reads the folder again, or says why the sync didn't happen: a file couldn't be saved, there is no URL key, Working Copy isn't installed, or Working Copy's error, such as a merge conflict. Conflicts are resolved in Working Copy. Pushing needs Working Copy's push feature.
468
469With Sync when orgstar opens, the folders that have it sync, one after another, when you open orgstar or come back to it, except when you come back from Working Copy within two minutes of a sync.
470
471orgstar doesn't sync when you leave it: iOS doesn't let an app open another app as it goes to the background. Use a Shortcuts automation for that, or in place of orgstar's own sync:
472
4731. In Shortcuts, open Automation and add a personal automation with the App trigger. Choose orgstar, and Is Closed (or Is Opened, to pull when you start).
4742. Choose Run Immediately.
4753. Add Working Copy's actions for the repository: commit (with a message), then pull, then push; or only pull for Is Opened.
476
451* Settings 477* Settings
452 478
453The iOS app reads its settings from a configuration folder: a folder holding =config.toml= and =capture.toml=, such as a copy of the Mac's =~/.config/orgstar= synced through iCloud Drive or another app. 479The iOS app reads its settings from a configuration folder: a folder holding =config.toml= and =capture.toml=, such as a copy of the Mac's =~/.config/orgstar= synced through iCloud Drive or another app.
@@ -512,6 +538,10 @@ These settings from =config.toml= apply on iOS:
512 538
513=capture.toml= and =views.toml= in the folder apply too. =keymap= and =keymap.toml= apply with a hardware keyboard. Other settings, including =save=, don't apply on iOS. See [[file:13-configuration.org][Configuration]]. 539=capture.toml= and =views.toml= in the folder apply too. =keymap= and =keymap.toml= apply with a hardware keyboard. Other settings, including =save=, don't apply on iOS. See [[file:13-configuration.org][Configuration]].
514 540
541* Handoff
542
543The file open in the editor is offered to your other devices through Handoff, and a file offered by a Mac, iPhone or iPad opens here in the editor at the same heading or line, when an added folder holds it. See [[file:01-files-and-folders.org][Files and folders]], Handoff, for how folders are matched.
544
515* Spotlight and Quick Look 545* Spotlight and Quick Look
516 546
517orgstar adds the org files in your folders to Spotlight with their title (=#+TITLE=, else the file name), author, description, tags, headings and text. A file is indexed again when it changes. Tap a Spotlight result to open the file in orgstar's reader. 547orgstar adds the org files in your folders to Spotlight with their title (=#+TITLE=, else the file name), author, description, tags, headings and text. A file is indexed again when it changes. Tap a Spotlight result to open the file in orgstar's reader.
ios/Orgstar/Info.plist +4 · view
@@ -60,6 +60,10 @@
60 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string> 60 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
61 <key>NSSupportsLiveActivities</key> 61 <key>NSSupportsLiveActivities</key>
62 <true/> 62 <true/>
63 <key>NSUserActivityTypes</key>
64 <array>
65 <string>sh.krz.orgstar.editing</string>
66 </array>
63 <key>UIApplicationSceneManifest</key> 67 <key>UIApplicationSceneManifest</key>
64 <dict> 68 <dict>
65 <key>UIApplicationSupportsMultipleScenes</key> 69 <key>UIApplicationSupportsMultipleScenes</key>
ios/OrgstarMac/Info.plist +4 · view
@@ -82,6 +82,10 @@
82 <string>NSApplication</string> 82 <string>NSApplication</string>
83 <key>NSRemindersFullAccessUsageDescription</key> 83 <key>NSRemindersFullAccessUsageDescription</key>
84 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string> 84 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
85 <key>NSUserActivityTypes</key>
86 <array>
87 <string>sh.krz.orgstar.editing</string>
88 </array>
85 <key>UTImportedTypeDeclarations</key> 89 <key>UTImportedTypeDeclarations</key>
86 <array> 90 <array>
87 <dict> 91 <dict>
l10n/Localizable.xcstrings +1131 · view
@@ -886,6 +886,181 @@
886 } 886 }
887 } 887 }
888 }, 888 },
889 "%@ wasn't synced: %@": {
890 "comment": "Working Copy sync; Working Copy's error follows",
891 "localizations": {
892 "de": {
893 "stringUnit": {
894 "state": "translated",
895 "value": "%1$@ wurde nicht synchronisiert: %2$@"
896 }
897 },
898 "es": {
899 "stringUnit": {
900 "state": "translated",
901 "value": "%1$@ no se sincronizó: %2$@"
902 }
903 },
904 "fr": {
905 "stringUnit": {
906 "state": "translated",
907 "value": "%1$@ n’a pas été synchronisé : %2$@"
908 }
909 },
910 "ja": {
911 "stringUnit": {
912 "state": "translated",
913 "value": "%1$@は同期されませんでした:%2$@"
914 }
915 },
916 "pt-BR": {
917 "stringUnit": {
918 "state": "translated",
919 "value": "%1$@ não foi sincronizado: %2$@"
920 }
921 }
922 }
923 },
924 "%@ wasn't synced: %@ couldn't be saved.": {
925 "comment": "Working Copy sync",
926 "localizations": {
927 "de": {
928 "stringUnit": {
929 "state": "translated",
930 "value": "%1$@ wurde nicht synchronisiert: %2$@ konnte nicht gesichert werden."
931 }
932 },
933 "es": {
934 "stringUnit": {
935 "state": "translated",
936 "value": "%1$@ no se sincronizó: no se pudo guardar %2$@."
937 }
938 },
939 "fr": {
940 "stringUnit": {
941 "state": "translated",
942 "value": "%1$@ n’a pas été synchronisé : %2$@ n’a pas pu être enregistré."
943 }
944 },
945 "ja": {
946 "stringUnit": {
947 "state": "translated",
948 "value": "%1$@は同期されませんでした:%2$@を保存できませんでした。"
949 }
950 },
951 "pt-BR": {
952 "stringUnit": {
953 "state": "translated",
954 "value": "%1$@ não foi sincronizado: não foi possível salvar %2$@."
955 }
956 }
957 }
958 },
959 "%@ wasn't synced: Working Copy isn't installed or couldn't be opened.": {
960 "comment": "Working Copy sync",
961 "localizations": {
962 "de": {
963 "stringUnit": {
964 "state": "translated",
965 "value": "%@ wurde nicht synchronisiert: Working Copy ist nicht installiert oder konnte nicht geöffnet werden."
966 }
967 },
968 "es": {
969 "stringUnit": {
970 "state": "translated",
971 "value": "%@ no se sincronizó: Working Copy no está instalada o no se pudo abrir."
972 }
973 },
974 "fr": {
975 "stringUnit": {
976 "state": "translated",
977 "value": "%@ n’a pas été synchronisé : Working Copy n’est pas installée ou n’a pas pu être ouverte."
978 }
979 },
980 "ja": {
981 "stringUnit": {
982 "state": "translated",
983 "value": "%@は同期されませんでした:Working Copyがインストールされていないか、開けませんでした。"
984 }
985 },
986 "pt-BR": {
987 "stringUnit": {
988 "state": "translated",
989 "value": "%@ não foi sincronizado: o Working Copy não está instalado ou não pôde ser aberto."
990 }
991 }
992 }
993 },
994 "%@ wasn't synced: Working Copy reported an error.": {
995 "comment": "Working Copy sync",
996 "localizations": {
997 "de": {
998 "stringUnit": {
999 "state": "translated",
1000 "value": "%@ wurde nicht synchronisiert: Working Copy hat einen Fehler gemeldet."
1001 }
1002 },
1003 "es": {
1004 "stringUnit": {
1005 "state": "translated",
1006 "value": "%@ no se sincronizó: Working Copy informó de un error."
1007 }
1008 },
1009 "fr": {
1010 "stringUnit": {
1011 "state": "translated",
1012 "value": "%@ n’a pas été synchronisé : Working Copy a signalé une erreur."
1013 }
1014 },
1015 "ja": {
1016 "stringUnit": {
1017 "state": "translated",
1018 "value": "%@は同期されませんでした:Working Copyがエラーを報告しました。"
1019 }
1020 },
1021 "pt-BR": {
1022 "stringUnit": {
1023 "state": "translated",
1024 "value": "%@ não foi sincronizado: o Working Copy relatou um erro."
1025 }
1026 }
1027 }
1028 },
1029 "%@ wasn't synced: set Working Copy's URL key in Settings ▸ Working Copy.": {
1030 "comment": "Working Copy sync",
1031 "localizations": {
1032 "de": {
1033 "stringUnit": {
1034 "state": "translated",
1035 "value": "%@ wurde nicht synchronisiert: Lege den URL-Schlüssel von Working Copy unter Einstellungen ▸ Working Copy fest."
1036 }
1037 },
1038 "es": {
1039 "stringUnit": {
1040 "state": "translated",
1041 "value": "%@ no se sincronizó: introduce la clave URL de Working Copy en Ajustes ▸ Working Copy."
1042 }
1043 },
1044 "fr": {
1045 "stringUnit": {
1046 "state": "translated",
1047 "value": "%@ n’a pas été synchronisé : saisissez la clé URL de Working Copy dans Réglages ▸ Working Copy."
1048 }
1049 },
1050 "ja": {
1051 "stringUnit": {
1052 "state": "translated",
1053 "value": "%@は同期されませんでした:設定 ▸ Working CopyでWorking CopyのURLキーを設定してください。"
1054 }
1055 },
1056 "pt-BR": {
1057 "stringUnit": {
1058 "state": "translated",
1059 "value": "%@ não foi sincronizado: defina a chave de URL do Working Copy em Ajustes ▸ Working Copy."
1060 }
1061 }
1062 }
1063 },
889 "%@ with %@": { 1064 "%@ with %@": {
890 "localizations": { 1065 "localizations": {
891 "de": { 1066 "de": {
@@ -7390,6 +7565,76 @@
7390 } 7565 }
7391 } 7566 }
7392 }, 7567 },
7568 "Can't continue %@: it isn't in “%@” on this device yet.": {
7569 "comment": "Handoff from another device",
7570 "localizations": {
7571 "de": {
7572 "stringUnit": {
7573 "state": "translated",
7574 "value": "%1$@ kann nicht fortgesetzt werden: Die Datei ist auf diesem Gerät noch nicht in „%2$@“."
7575 }
7576 },
7577 "es": {
7578 "stringUnit": {
7579 "state": "translated",
7580 "value": "No se puede continuar %1$@: todavía no está en «%2$@» en este dispositivo."
7581 }
7582 },
7583 "fr": {
7584 "stringUnit": {
7585 "state": "translated",
7586 "value": "Impossible de continuer %1$@ : le fichier n’est pas encore dans « %2$@ » sur cet appareil."
7587 }
7588 },
7589 "ja": {
7590 "stringUnit": {
7591 "state": "translated",
7592 "value": "%1$@を続けられません:このデバイスの「%2$@」にはまだありません。"
7593 }
7594 },
7595 "pt-BR": {
7596 "stringUnit": {
7597 "state": "translated",
7598 "value": "Não é possível continuar %1$@: ele ainda não está em “%2$@” neste dispositivo."
7599 }
7600 }
7601 }
7602 },
7603 "Can't continue %@: no folder named “%@” is added on this device.": {
7604 "comment": "Handoff from another device",
7605 "localizations": {
7606 "de": {
7607 "stringUnit": {
7608 "state": "translated",
7609 "value": "%1$@ kann nicht fortgesetzt werden: Auf diesem Gerät ist kein Ordner namens „%2$@“ hinzugefügt."
7610 }
7611 },
7612 "es": {
7613 "stringUnit": {
7614 "state": "translated",
7615 "value": "No se puede continuar %1$@: no hay ninguna carpeta llamada «%2$@» añadida en este dispositivo."
7616 }
7617 },
7618 "fr": {
7619 "stringUnit": {
7620 "state": "translated",
7621 "value": "Impossible de continuer %1$@ : aucun dossier nommé « %2$@ » n’est ajouté sur cet appareil."
7622 }
7623 },
7624 "ja": {
7625 "stringUnit": {
7626 "state": "translated",
7627 "value": "%1$@を続けられません:このデバイスには「%2$@」という名前のフォルダが追加されていません。"
7628 }
7629 },
7630 "pt-BR": {
7631 "stringUnit": {
7632 "state": "translated",
7633 "value": "Não é possível continuar %1$@: nenhuma pasta chamada “%2$@” foi adicionada neste dispositivo."
7634 }
7635 }
7636 }
7637 },
7393 "Can't export %@: %@": { 7638 "Can't export %@: %@": {
7394 "comment": "Echo area: file name, then the reason", 7639 "comment": "Echo area: file name, then the reason",
7395 "localizations": { 7640 "localizations": {
@@ -7633,6 +7878,40 @@
7633 } 7878 }
7634 } 7879 }
7635 }, 7880 },
7881 "Can't share %@: %@": {
7882 "localizations": {
7883 "de": {
7884 "stringUnit": {
7885 "state": "translated",
7886 "value": "%1$@ kann nicht geteilt werden: %2$@"
7887 }
7888 },
7889 "es": {
7890 "stringUnit": {
7891 "state": "translated",
7892 "value": "No se puede compartir %1$@: %2$@"
7893 }
7894 },
7895 "fr": {
7896 "stringUnit": {
7897 "state": "translated",
7898 "value": "Impossible de partager %1$@ : %2$@"
7899 }
7900 },
7901 "ja": {
7902 "stringUnit": {
7903 "state": "translated",
7904 "value": "%1$@を共有できません:%2$@"
7905 }
7906 },
7907 "pt-BR": {
7908 "stringUnit": {
7909 "state": "translated",
7910 "value": "Não é possível compartilhar %1$@: %2$@"
7911 }
7912 }
7913 }
7914 },
7636 "Can't write %@: %@": { 7915 "Can't write %@: %@": {
7637 "comment": "Echo area: file name, then the reason", 7916 "comment": "Echo area: file name, then the reason",
7638 "localizations": { 7917 "localizations": {
@@ -20111,6 +20390,106 @@
20111 } 20390 }
20112 } 20391 }
20113 }, 20392 },
20393 "Include %lld attachments": {
20394 "localizations": {
20395 "de": {
20396 "variations": {
20397 "plural": {
20398 "one": {
20399 "stringUnit": {
20400 "state": "translated",
20401 "value": "%lld Anhang mitsenden"
20402 }
20403 },
20404 "other": {
20405 "stringUnit": {
20406 "state": "translated",
20407 "value": "%lld Anhänge mitsenden"
20408 }
20409 }
20410 }
20411 }
20412 },
20413 "en": {
20414 "variations": {
20415 "plural": {
20416 "one": {
20417 "stringUnit": {
20418 "state": "translated",
20419 "value": "Include %lld attachment"
20420 }
20421 },
20422 "other": {
20423 "stringUnit": {
20424 "state": "translated",
20425 "value": "Include %lld attachments"
20426 }
20427 }
20428 }
20429 }
20430 },
20431 "es": {
20432 "variations": {
20433 "plural": {
20434 "one": {
20435 "stringUnit": {
20436 "state": "translated",
20437 "value": "Incluir %lld adjunto"
20438 }
20439 },
20440 "other": {
20441 "stringUnit": {
20442 "state": "translated",
20443 "value": "Incluir %lld adjuntos"
20444 }
20445 }
20446 }
20447 }
20448 },
20449 "fr": {
20450 "variations": {
20451 "plural": {
20452 "one": {
20453 "stringUnit": {
20454 "state": "translated",
20455 "value": "Inclure %lld pièce jointe"
20456 }
20457 },
20458 "other": {
20459 "stringUnit": {
20460 "state": "translated",
20461 "value": "Inclure %lld pièces jointes"
20462 }
20463 }
20464 }
20465 }
20466 },
20467 "ja": {
20468 "stringUnit": {
20469 "state": "translated",
20470 "value": "添付ファイル%lld個を含める"
20471 }
20472 },
20473 "pt-BR": {
20474 "variations": {
20475 "plural": {
20476 "one": {
20477 "stringUnit": {
20478 "state": "translated",
20479 "value": "Incluir %lld anexo"
20480 }
20481 },
20482 "other": {
20483 "stringUnit": {
20484 "state": "translated",
20485 "value": "Incluir %lld anexos"
20486 }
20487 }
20488 }
20489 }
20490 }
20491 }
20492 },
20114 "Include files in subfolders": { 20493 "Include files in subfolders": {
20115 "localizations": { 20494 "localizations": {
20116 "de": { 20495 "de": {
@@ -30208,6 +30587,40 @@
30208 } 30587 }
30209 } 30588 }
30210 }, 30589 },
30590 "Org file (%@)": {
30591 "localizations": {
30592 "de": {
30593 "stringUnit": {
30594 "state": "translated",
30595 "value": "Org-Datei (%@)"
30596 }
30597 },
30598 "es": {
30599 "stringUnit": {
30600 "state": "translated",
30601 "value": "Archivo Org (%@)"
30602 }
30603 },
30604 "fr": {
30605 "stringUnit": {
30606 "state": "translated",
30607 "value": "Fichier Org (%@)"
30608 }
30609 },
30610 "ja": {
30611 "stringUnit": {
30612 "state": "translated",
30613 "value": "Orgファイル(%@)"
30614 }
30615 },
30616 "pt-BR": {
30617 "stringUnit": {
30618 "state": "translated",
30619 "value": "Arquivo Org (%@)"
30620 }
30621 }
30622 }
30623 },
30211 "Org's date syntax works too: +2d, fri, 14:00": { 30624 "Org's date syntax works too: +2d, fri, 14:00": {
30212 "localizations": { 30625 "localizations": {
30213 "de": { 30626 "de": {
@@ -33993,6 +34406,40 @@
33993 } 34406 }
33994 } 34407 }
33995 }, 34408 },
34409 "Remove Key": {
34410 "localizations": {
34411 "de": {
34412 "stringUnit": {
34413 "state": "translated",
34414 "value": "Schlüssel entfernen"
34415 }
34416 },
34417 "es": {
34418 "stringUnit": {
34419 "state": "translated",
34420 "value": "Eliminar clave"
34421 }
34422 },
34423 "fr": {
34424 "stringUnit": {
34425 "state": "translated",
34426 "value": "Supprimer la clé"
34427 }
34428 },
34429 "ja": {
34430 "stringUnit": {
34431 "state": "translated",
34432 "value": "キーを削除"
34433 }
34434 },
34435 "pt-BR": {
34436 "stringUnit": {
34437 "state": "translated",
34438 "value": "Remover Chave"
34439 }
34440 }
34441 }
34442 },
33996 "Remove Priority": { 34443 "Remove Priority": {
33997 "comment": "Command title", 34444 "comment": "Command title",
33998 "localizations": { 34445 "localizations": {
@@ -34822,6 +35269,40 @@
34822 } 35269 }
34823 } 35270 }
34824 }, 35271 },
35272 "Replace Key": {
35273 "localizations": {
35274 "de": {
35275 "stringUnit": {
35276 "state": "translated",
35277 "value": "Schlüssel ersetzen"
35278 }
35279 },
35280 "es": {
35281 "stringUnit": {
35282 "state": "translated",
35283 "value": "Sustituir clave"
35284 }
35285 },
35286 "fr": {
35287 "stringUnit": {
35288 "state": "translated",
35289 "value": "Remplacer la clé"
35290 }
35291 },
35292 "ja": {
35293 "stringUnit": {
35294 "state": "translated",
35295 "value": "キーを置き換え"
35296 }
35297 },
35298 "pt-BR": {
35299 "stringUnit": {
35300 "state": "translated",
35301 "value": "Substituir Chave"
35302 }
35303 }
35304 }
35305 },
34825 "Replace in Files": { 35306 "Replace in Files": {
34826 "comment": "Window title", 35307 "comment": "Window title",
34827 "localizations": { 35308 "localizations": {
@@ -35029,6 +35510,40 @@
35029 } 35510 }
35030 } 35511 }
35031 }, 35512 },
35513 "Repository": {
35514 "localizations": {
35515 "de": {
35516 "stringUnit": {
35517 "state": "translated",
35518 "value": "Repository"
35519 }
35520 },
35521 "es": {
35522 "stringUnit": {
35523 "state": "translated",
35524 "value": "Repositorio"
35525 }
35526 },
35527 "fr": {
35528 "stringUnit": {
35529 "state": "translated",
35530 "value": "Dépôt"
35531 }
35532 },
35533 "ja": {
35534 "stringUnit": {
35535 "state": "translated",
35536 "value": "リポジトリ"
35537 }
35538 },
35539 "pt-BR": {
35540 "stringUnit": {
35541 "state": "translated",
35542 "value": "Repositório"
35543 }
35544 }
35545 }
35546 },
35032 "Reschedule": { 35547 "Reschedule": {
35033 "localizations": { 35548 "localizations": {
35034 "de": { 35549 "de": {
@@ -35924,6 +36439,40 @@
35924 } 36439 }
35925 } 36440 }
35926 }, 36441 },
36442 "Save Key": {
36443 "localizations": {
36444 "de": {
36445 "stringUnit": {
36446 "state": "translated",
36447 "value": "Schlüssel sichern"
36448 }
36449 },
36450 "es": {
36451 "stringUnit": {
36452 "state": "translated",
36453 "value": "Guardar clave"
36454 }
36455 },
36456 "fr": {
36457 "stringUnit": {
36458 "state": "translated",
36459 "value": "Enregistrer la clé"
36460 }
36461 },
36462 "ja": {
36463 "stringUnit": {
36464 "state": "translated",
36465 "value": "キーを保存"
36466 }
36467 },
36468 "pt-BR": {
36469 "stringUnit": {
36470 "state": "translated",
36471 "value": "Salvar Chave"
36472 }
36473 }
36474 }
36475 },
35927 "Save as View…": { 36476 "Save as View…": {
35928 "localizations": { 36477 "localizations": {
35929 "de": { 36478 "de": {
@@ -37645,6 +38194,211 @@
37645 } 38194 }
37646 } 38195 }
37647 }, 38196 },
38197 "Share Subtree": {
38198 "localizations": {
38199 "de": {
38200 "stringUnit": {
38201 "state": "translated",
38202 "value": "Teilbaum teilen"
38203 }
38204 },
38205 "es": {
38206 "stringUnit": {
38207 "state": "translated",
38208 "value": "Compartir subárbol"
38209 }
38210 },
38211 "fr": {
38212 "stringUnit": {
38213 "state": "translated",
38214 "value": "Partager le sous-arbre"
38215 }
38216 },
38217 "ja": {
38218 "stringUnit": {
38219 "state": "translated",
38220 "value": "サブツリーを共有"
38221 }
38222 },
38223 "pt-BR": {
38224 "stringUnit": {
38225 "state": "translated",
38226 "value": "Compartilhar Subárvore"
38227 }
38228 }
38229 }
38230 },
38231 "Share Subtree…": {
38232 "comment": "Command title",
38233 "localizations": {
38234 "de": {
38235 "stringUnit": {
38236 "state": "translated",
38237 "value": "Teilbaum teilen …"
38238 }
38239 },
38240 "es": {
38241 "stringUnit": {
38242 "state": "translated",
38243 "value": "Compartir subárbol…"
38244 }
38245 },
38246 "fr": {
38247 "stringUnit": {
38248 "state": "translated",
38249 "value": "Partager le sous-arbre…"
38250 }
38251 },
38252 "ja": {
38253 "stringUnit": {
38254 "state": "translated",
38255 "value": "サブツリーを共有…"
38256 }
38257 },
38258 "pt-BR": {
38259 "stringUnit": {
38260 "state": "translated",
38261 "value": "Compartilhar Subárvore…"
38262 }
38263 }
38264 }
38265 },
38266 "Share as": {
38267 "localizations": {
38268 "de": {
38269 "stringUnit": {
38270 "state": "translated",
38271 "value": "Teilen als"
38272 }
38273 },
38274 "es": {
38275 "stringUnit": {
38276 "state": "translated",
38277 "value": "Compartir como"
38278 }
38279 },
38280 "fr": {
38281 "stringUnit": {
38282 "state": "translated",
38283 "value": "Partager en tant que"
38284 }
38285 },
38286 "ja": {
38287 "stringUnit": {
38288 "state": "translated",
38289 "value": "共有形式"
38290 }
38291 },
38292 "pt-BR": {
38293 "stringUnit": {
38294 "state": "translated",
38295 "value": "Compartilhar como"
38296 }
38297 }
38298 }
38299 },
38300 "Share as Org File": {
38301 "localizations": {
38302 "de": {
38303 "stringUnit": {
38304 "state": "translated",
38305 "value": "Als Org-Datei teilen"
38306 }
38307 },
38308 "es": {
38309 "stringUnit": {
38310 "state": "translated",
38311 "value": "Compartir como archivo Org"
38312 }
38313 },
38314 "fr": {
38315 "stringUnit": {
38316 "state": "translated",
38317 "value": "Partager en fichier Org"
38318 }
38319 },
38320 "ja": {
38321 "stringUnit": {
38322 "state": "translated",
38323 "value": "Orgファイルとして共有"
38324 }
38325 },
38326 "pt-BR": {
38327 "stringUnit": {
38328 "state": "translated",
38329 "value": "Compartilhar como Arquivo Org"
38330 }
38331 }
38332 }
38333 },
38334 "Share as Text": {
38335 "localizations": {
38336 "de": {
38337 "stringUnit": {
38338 "state": "translated",
38339 "value": "Als Text teilen"
38340 }
38341 },
38342 "es": {
38343 "stringUnit": {
38344 "state": "translated",
38345 "value": "Compartir como texto"
38346 }
38347 },
38348 "fr": {
38349 "stringUnit": {
38350 "state": "translated",
38351 "value": "Partager en texte"
38352 }
38353 },
38354 "ja": {
38355 "stringUnit": {
38356 "state": "translated",
38357 "value": "テキストとして共有"
38358 }
38359 },
38360 "pt-BR": {
38361 "stringUnit": {
38362 "state": "translated",
38363 "value": "Compartilhar como Texto"
38364 }
38365 }
38366 }
38367 },
38368 "Share…": {
38369 "localizations": {
38370 "de": {
38371 "stringUnit": {
38372 "state": "translated",
38373 "value": "Teilen …"
38374 }
38375 },
38376 "es": {
38377 "stringUnit": {
38378 "state": "translated",
38379 "value": "Compartir…"
38380 }
38381 },
38382 "fr": {
38383 "stringUnit": {
38384 "state": "translated",
38385 "value": "Partager…"
38386 }
38387 },
38388 "ja": {
38389 "stringUnit": {
38390 "state": "translated",
38391 "value": "共有…"
38392 }
38393 },
38394 "pt-BR": {
38395 "stringUnit": {
38396 "state": "translated",
38397 "value": "Compartilhar…"
38398 }
38399 }
38400 }
38401 },
37648 "Shift Timer Values in Region…": { 38402 "Shift Timer Values in Region…": {
37649 "comment": "Command title", 38403 "comment": "Command title",
37650 "localizations": { 38404 "localizations": {
@@ -40853,6 +41607,178 @@
40853 } 41607 }
40854 } 41608 }
40855 }, 41609 },
41610 "Sync folders that are git repositories in Working Copy.": {
41611 "localizations": {
41612 "de": {
41613 "stringUnit": {
41614 "state": "translated",
41615 "value": "Ordner synchronisieren, die Git-Repositorys in Working Copy sind."
41616 }
41617 },
41618 "es": {
41619 "stringUnit": {
41620 "state": "translated",
41621 "value": "Sincroniza carpetas que son repositorios git en Working Copy."
41622 }
41623 },
41624 "fr": {
41625 "stringUnit": {
41626 "state": "translated",
41627 "value": "Synchroniser les dossiers qui sont des dépôts git dans Working Copy."
41628 }
41629 },
41630 "ja": {
41631 "stringUnit": {
41632 "state": "translated",
41633 "value": "Working Copyのgitリポジトリであるフォルダを同期します。"
41634 }
41635 },
41636 "pt-BR": {
41637 "stringUnit": {
41638 "state": "translated",
41639 "value": "Sincronize pastas que são repositórios git no Working Copy."
41640 }
41641 }
41642 }
41643 },
41644 "Sync saves every file, then Working Copy commits every changed file in the repository, pulls and pushes. The repository is its name in Working Copy's list.": {
41645 "localizations": {
41646 "de": {
41647 "stringUnit": {
41648 "state": "translated",
41649 "value": "Beim Synchronisieren werden alle Dateien gesichert; dann committet Working Copy jede geänderte Datei im Repository, führt Pull und dann Push aus. Als Repository gilt sein Name in der Liste von Working Copy."
41650 }
41651 },
41652 "es": {
41653 "stringUnit": {
41654 "state": "translated",
41655 "value": "Al sincronizar se guardan todos los archivos; luego Working Copy hace commit de cada archivo cambiado del repositorio, pull y push. El repositorio es su nombre en la lista de Working Copy."
41656 }
41657 },
41658 "fr": {
41659 "stringUnit": {
41660 "state": "translated",
41661 "value": "La synchronisation enregistre tous les fichiers, puis Working Copy fait un commit de chaque fichier modifié du dépôt, un pull et un push. Le dépôt est son nom dans la liste de Working Copy."
41662 }
41663 },
41664 "ja": {
41665 "stringUnit": {
41666 "state": "translated",
41667 "value": "同期するとすべてのファイルが保存され、Working Copyがリポジトリ内の変更されたファイルをすべてコミットし、プルしてからプッシュします。リポジトリにはWorking Copyの一覧に表示される名前を指定します。"
41668 }
41669 },
41670 "pt-BR": {
41671 "stringUnit": {
41672 "state": "translated",
41673 "value": "Sincronizar salva todos os arquivos; depois o Working Copy faz commit de cada arquivo alterado no repositório, pull e push. O repositório é o nome dele na lista do Working Copy."
41674 }
41675 }
41676 }
41677 },
41678 "Sync when orgstar opens": {
41679 "localizations": {
41680 "de": {
41681 "stringUnit": {
41682 "state": "translated",
41683 "value": "Beim Öffnen von orgstar synchronisieren"
41684 }
41685 },
41686 "es": {
41687 "stringUnit": {
41688 "state": "translated",
41689 "value": "Sincronizar al abrir orgstar"
41690 }
41691 },
41692 "fr": {
41693 "stringUnit": {
41694 "state": "translated",
41695 "value": "Synchroniser à l’ouverture d’orgstar"
41696 }
41697 },
41698 "ja": {
41699 "stringUnit": {
41700 "state": "translated",
41701 "value": "orgstarを開いたときに同期"
41702 }
41703 },
41704 "pt-BR": {
41705 "stringUnit": {
41706 "state": "translated",
41707 "value": "Sincronizar ao abrir o orgstar"
41708 }
41709 }
41710 }
41711 },
41712 "Sync with Working Copy": {
41713 "comment": "Command title",
41714 "localizations": {
41715 "de": {
41716 "stringUnit": {
41717 "state": "translated",
41718 "value": "Mit Working Copy synchronisieren"
41719 }
41720 },
41721 "es": {
41722 "stringUnit": {
41723 "state": "translated",
41724 "value": "Sincronizar con Working Copy"
41725 }
41726 },
41727 "fr": {
41728 "stringUnit": {
41729 "state": "translated",
41730 "value": "Synchroniser avec Working Copy"
41731 }
41732 },
41733 "ja": {
41734 "stringUnit": {
41735 "state": "translated",
41736 "value": "Working Copyと同期"
41737 }
41738 },
41739 "pt-BR": {
41740 "stringUnit": {
41741 "state": "translated",
41742 "value": "Sincronizar com Working Copy"
41743 }
41744 }
41745 }
41746 },
41747 "Synced %@ with Working Copy": {
41748 "comment": "Working Copy sync",
41749 "localizations": {
41750 "de": {
41751 "stringUnit": {
41752 "state": "translated",
41753 "value": "%@ mit Working Copy synchronisiert"
41754 }
41755 },
41756 "es": {
41757 "stringUnit": {
41758 "state": "translated",
41759 "value": "%@ sincronizada con Working Copy"
41760 }
41761 },
41762 "fr": {
41763 "stringUnit": {
41764 "state": "translated",
41765 "value": "%@ synchronisé avec Working Copy"
41766 }
41767 },
41768 "ja": {
41769 "stringUnit": {
41770 "state": "translated",
41771 "value": "%@をWorking Copyと同期しました"
41772 }
41773 },
41774 "pt-BR": {
41775 "stringUnit": {
41776 "state": "translated",
41777 "value": "%@ sincronizado com o Working Copy"
41778 }
41779 }
41780 }
41781 },
40856 "System": { 41782 "System": {
40857 "localizations": { 41783 "localizations": {
40858 "de": { 41784 "de": {
@@ -43216,6 +44142,75 @@
43216 } 44142 }
43217 } 44143 }
43218 }, 44144 },
44145 "This folder doesn't sync with Working Copy; turn it on in Settings ▸ Working Copy.": {
44146 "comment": "Sync with Working Copy in a folder that isn't set up",
44147 "localizations": {
44148 "de": {
44149 "stringUnit": {
44150 "state": "translated",
44151 "value": "Dieser Ordner wird nicht mit Working Copy synchronisiert; schalte es unter Einstellungen ▸ Working Copy ein."
44152 }
44153 },
44154 "es": {
44155 "stringUnit": {
44156 "state": "translated",
44157 "value": "Esta carpeta no se sincroniza con Working Copy; actívalo en Ajustes ▸ Working Copy."
44158 }
44159 },
44160 "fr": {
44161 "stringUnit": {
44162 "state": "translated",
44163 "value": "Ce dossier ne se synchronise pas avec Working Copy ; activez-le dans Réglages ▸ Working Copy."
44164 }
44165 },
44166 "ja": {
44167 "stringUnit": {
44168 "state": "translated",
44169 "value": "このフォルダはWorking Copyと同期していません。設定 ▸ Working Copyでオンにしてください。"
44170 }
44171 },
44172 "pt-BR": {
44173 "stringUnit": {
44174 "state": "translated",
44175 "value": "Esta pasta não sincroniza com o Working Copy; ative em Ajustes ▸ Working Copy."
44176 }
44177 }
44178 }
44179 },
44180 "This folder is a git repository.": {
44181 "localizations": {
44182 "de": {
44183 "stringUnit": {
44184 "state": "translated",
44185 "value": "Dieser Ordner ist ein Git-Repository."
44186 }
44187 },
44188 "es": {
44189 "stringUnit": {
44190 "state": "translated",
44191 "value": "Esta carpeta es un repositorio git."
44192 }
44193 },
44194 "fr": {
44195 "stringUnit": {
44196 "state": "translated",
44197 "value": "Ce dossier est un dépôt git."
44198 }
44199 },
44200 "ja": {
44201 "stringUnit": {
44202 "state": "translated",
44203 "value": "このフォルダはgitリポジトリです。"
44204 }
44205 },
44206 "pt-BR": {
44207 "stringUnit": {
44208 "state": "translated",
44209 "value": "Esta pasta é um repositório git."
44210 }
44211 }
44212 }
44213 },
43219 "This is the only pane.": { 44214 "This is the only pane.": {
43220 "comment": "Close Pane with one pane", 44215 "comment": "Close Pane with one pane",
43221 "localizations": { 44216 "localizations": {
@@ -44361,6 +45356,40 @@
44361 } 45356 }
44362 } 45357 }
44363 }, 45358 },
45359 "URL key": {
45360 "localizations": {
45361 "de": {
45362 "stringUnit": {
45363 "state": "translated",
45364 "value": "URL-Schlüssel"
45365 }
45366 },
45367 "es": {
45368 "stringUnit": {
45369 "state": "translated",
45370 "value": "Clave URL"
45371 }
45372 },
45373 "fr": {
45374 "stringUnit": {
45375 "state": "translated",
45376 "value": "Clé URL"
45377 }
45378 },
45379 "ja": {
45380 "stringUnit": {
45381 "state": "translated",
45382 "value": "URLキー"
45383 }
45384 },
45385 "pt-BR": {
45386 "stringUnit": {
45387 "state": "translated",
45388 "value": "Chave de URL"
45389 }
45390 }
45391 }
45392 },
44364 "Under a parent with the ORDERED property (Org ▸ Properties and Columns ▸ Toggle ORDERED Property), TODO children are also done in order.": { 45393 "Under a parent with the ORDERED property (Org ▸ Properties and Columns ▸ Toggle ORDERED Property), TODO children are also done in order.": {
44365 "localizations": { 45394 "localizations": {
44366 "de": { 45395 "de": {
@@ -46079,6 +47108,108 @@
46079 } 47108 }
46080 } 47109 }
46081 }, 47110 },
47111 "Working Copy": {
47112 "localizations": {
47113 "de": {
47114 "stringUnit": {
47115 "state": "translated",
47116 "value": "Working Copy"
47117 }
47118 },
47119 "es": {
47120 "stringUnit": {
47121 "state": "translated",
47122 "value": "Working Copy"
47123 }
47124 },
47125 "fr": {
47126 "stringUnit": {
47127 "state": "translated",
47128 "value": "Working Copy"
47129 }
47130 },
47131 "ja": {
47132 "stringUnit": {
47133 "state": "translated",
47134 "value": "Working Copy"
47135 }
47136 },
47137 "pt-BR": {
47138 "stringUnit": {
47139 "state": "translated",
47140 "value": "Working Copy"
47141 }
47142 }
47143 }
47144 },
47145 "Working Copy runs orgstar's sync only with the URL key from Working Copy's settings. orgstar keeps it in the Keychain on this device.": {
47146 "localizations": {
47147 "de": {
47148 "stringUnit": {
47149 "state": "translated",
47150 "value": "Working Copy führt die Synchronisierung von orgstar nur mit dem URL-Schlüssel aus den Einstellungen von Working Copy aus. orgstar bewahrt ihn im Schlüsselbund auf diesem Gerät auf."
47151 }
47152 },
47153 "es": {
47154 "stringUnit": {
47155 "state": "translated",
47156 "value": "Working Copy solo ejecuta la sincronización de orgstar con la clave URL de los ajustes de Working Copy. orgstar la guarda en el llavero de este dispositivo."
47157 }
47158 },
47159 "fr": {
47160 "stringUnit": {
47161 "state": "translated",
47162 "value": "Working Copy n’exécute la synchronisation d’orgstar qu’avec la clé URL des réglages de Working Copy. orgstar la conserve dans le trousseau de cet appareil."
47163 }
47164 },
47165 "ja": {
47166 "stringUnit": {
47167 "state": "translated",
47168 "value": "Working CopyはWorking Copyの設定にあるURLキーがある場合にのみorgstarの同期を実行します。orgstarはこのキーをこのデバイスのキーチェーンに保管します。"
47169 }
47170 },
47171 "pt-BR": {
47172 "stringUnit": {
47173 "state": "translated",
47174 "value": "O Working Copy só executa a sincronização do orgstar com a chave de URL dos ajustes do Working Copy. O orgstar a guarda nas Chaves deste dispositivo."
47175 }
47176 }
47177 }
47178 },
47179 "Working Copy…": {
47180 "localizations": {
47181 "de": {
47182 "stringUnit": {
47183 "state": "translated",
47184 "value": "Working Copy …"
47185 }
47186 },
47187 "es": {
47188 "stringUnit": {
47189 "state": "translated",
47190 "value": "Working Copy…"
47191 }
47192 },
47193 "fr": {
47194 "stringUnit": {
47195 "state": "translated",
47196 "value": "Working Copy…"
47197 }
47198 },
47199 "ja": {
47200 "stringUnit": {
47201 "state": "translated",
47202 "value": "Working Copy…"
47203 }
47204 },
47205 "pt-BR": {
47206 "stringUnit": {
47207 "state": "translated",
47208 "value": "Working Copy…"
47209 }
47210 }
47211 }
47212 },
46082 "Yank": { 47213 "Yank": {
46083 "comment": "Command title", 47214 "comment": "Command title",
46084 "localizations": { 47215 "localizations": {
scripts/build-app.sh +2 · view
@@ -159,6 +159,8 @@ ${feed_keys}
159 <true/> 159 <true/>
160 <key>NSPrincipalClass</key> 160 <key>NSPrincipalClass</key>
161 <string>NSApplication</string> 161 <string>NSApplication</string>
162 <key>NSUserActivityTypes</key>
163 <array><string>sh.krz.orgstar.editing</string></array>
162</dict> 164</dict>
163</plist> 165</plist>
164EOF 166EOF
scripts/build-ios-app.sh +2 · view
@@ -110,6 +110,8 @@ cat > "$app/Info.plist" <<PLIST
110 <array><string>org-protocol</string></array> 110 <array><string>org-protocol</string></array>
111 </dict> 111 </dict>
112 </array> 112 </array>
113 <key>NSUserActivityTypes</key>
114 <array><string>sh.krz.orgstar.editing</string></array>
113</dict> 115</dict>
114</plist> 116</plist>
115PLIST 117PLIST
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form