iOS feedback: capture fields, folders, refile, tabs, start day !202
18 files changed, +325 −37
Layout: unified · split
Sources/OrgApp/AgendaModel.swift +2 −2
| @@ -27,8 +27,8 @@ public final class AgendaModel { | ||
| 27 | 27 | /// The first day shown, as `Days` numbers it; nil follows today. |
| 28 | 28 | public var start: Int? |
| 29 | 29 | public var span = 10 |
| 30 | /// Where the view starts relative to today, as Doom's `org-agenda-start-day "-3d"`. | |
| 31 | public var startOffset = -3 | |
| 30 | /// Where the view starts relative to today, as `org-agenda-start-day` (`"-3d"` is -3). | |
| 31 | public var startOffset = 0 | |
| 32 | 32 | /// Files below the top level of each folder are agenda files too. |
| 33 | 33 | public var includeSubfolders = false |
| 34 | 34 | public var options = AgendaOptions() |
Sources/OrgApp/OrgPreferences.swift +1 −1
| @@ -96,7 +96,7 @@ public enum OrgPreferences { | ||
| 96 | 96 | defaults.string(forKey: key) ?? fallback(key)?.string ?? "" |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | /// Integers, and day offsets stored as integers with `"-3d"` as the fallback. | |
| 99 | /// Integers, and day offsets stored as integers with a string such as `"+0d"` as the fallback. | |
| 100 | 100 | private static func integer(_ key: String, _ defaults: UserDefaults) -> Int { |
| 101 | 101 | if let value = defaults.object(forKey: key) as? Int { return value } |
| 102 | 102 | switch fallback(key) { |
Sources/OrgApp/UserConfig.swift +1 −1
| @@ -143,7 +143,7 @@ public enum UserConfig { | ||
| 143 | 143 | comment: "line numbers (View ▸ Show Line Numbers)", legacy: "editor.line-numbers"), |
| 144 | 144 | Setting(section: "", key: "org-agenda-span", defaultsKey: "agendaSpan", kind: .integer, fallback: .integer(10), |
| 145 | 145 | comment: "days the agenda shows", legacy: "agenda.span"), |
| 146 | Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("-3d"), | |
| 146 | Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("+0d"), | |
| 147 | 147 | comment: "the agenda's first day: \"-3d\", \"+0d\"", legacy: "agenda.start-offset"), |
| 148 | 148 | Setting(section: "", key: "org-agenda-show-all-dates", defaultsKey: "agendaShowAllDates", kind: .bool, fallback: .bool(false), |
| 149 | 149 | comment: "show days with no entries (Emacs's default is t; Orgstar hides them); today always shows", legacy: ""), |
Sources/OrgDocument/CaptureEntry.swift added +49
| @@ -0,0 +1,49 @@ | ||
| 1 | import Foundation | |
| 2 | import OrgCore | |
| 3 | ||
| 4 | /// The first heading of a capture's text, as the capture sheet shows and changes it: its | |
| 5 | /// keyword, priority, tags and planning, set by running the editor's own commands on the text. | |
| 6 | public struct CaptureEntry: Sendable, Equatable { | |
| 7 | public var todo: String? | |
| 8 | public var priority: String? | |
| 9 | public var tags: [String] | |
| 10 | public var scheduled: Timestamp? | |
| 11 | public var deadline: Timestamp? | |
| 12 | /// The keywords of the text's settings, as sequences list them, active before done. | |
| 13 | public var keywords: [String] | |
| 14 | /// The priorities from highest to lowest: `A`, `B`, `C`, or numbers. | |
| 15 | public var priorities: [String] | |
| 16 | ||
| 17 | /// Nil when the text has no heading. | |
| 18 | public init?(text: String, defaults: OrgSettings = .default) { | |
| 19 | let tree = OrgParser.parse(text, defaults: defaults) | |
| 20 | guard let heading = DocumentModel(tree: tree).headings.first else { return nil } | |
| 21 | todo = heading.todo | |
| 22 | priority = heading.priority | |
| 23 | tags = heading.localTags | |
| 24 | scheduled = heading.scheduled | |
| 25 | deadline = heading.deadline | |
| 26 | keywords = tree.settings.todoSequences.flatMap { $0.active.map(\.name) + $0.done.map(\.name) } | |
| 27 | let range = tree.settings.priorities | |
| 28 | if let high = Int(range.highest), let low = Int(range.lowest), high <= low { | |
| 29 | priorities = (high...low).map(String.init) | |
| 30 | } else if let high = range.highest.unicodeScalars.first?.value, let low = range.lowest.unicodeScalars.first?.value, high <= low { | |
| 31 | priorities = (high...low).compactMap(Unicode.Scalar.init).map { String(Character($0)) } | |
| 32 | } else { | |
| 33 | priorities = [] | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | /// `text` after `command` runs on its first heading with `answers`, or nil when the command | |
| 38 | /// asks something else, fails, or changes nothing. | |
| 39 | public static func applying( | |
| 40 | _ command: any OrgCommand, answers: [String: String], to text: String, defaults: OrgSettings = .default, | |
| 41 | options: EditingOptions = .org, now: Date = Date() | |
| 42 | ) -> String? { | |
| 43 | var state = DocumentState(bytes: Array(text.utf8), defaults: defaults) | |
| 44 | guard let start = DocumentModel(tree: state.tree).headings.first?.headingRange.lowerBound, | |
| 45 | case .commit = try? state.run(command, selection: [start..<start], now: now, answers: answers, options: options), | |
| 46 | state.text != text else { return nil } | |
| 47 | return state.text | |
| 48 | } | |
| 49 | } | |
Sources/Orgstar/AgendaView.swift +1 −1
| @@ -68,7 +68,7 @@ struct AgendaView: View { | ||
| 68 | 68 | @State private var hovered: String? |
| 69 | 69 | @FocusState private var focused: Bool |
| 70 | 70 | @AppStorage("agendaSpan") private var span = 10 |
| 71 | @AppStorage("agendaStartOffset") private var startOffset = -3 | |
| 71 | @AppStorage("agendaStartOffset") private var startOffset = 0 | |
| 72 | 72 | @AppStorage("agendaSubfolders") private var includeSubfolders = false |
| 73 | 73 | @AppStorage("agendaShowAllDates") private var showAllDates = false |
| 74 | 74 | @AppStorage("calendarEvents") private var calendarEventsOn = false |
Sources/Orgstar/OrgstarApp.swift +1 −1
| @@ -522,7 +522,7 @@ struct SettingsView: View { | ||
| 522 | 522 | @AppStorage("enforceTodoDependencies") private var enforceTodoDependencies = false |
| 523 | 523 | @AppStorage("enforceTodoCheckboxDependencies") private var enforceTodoCheckboxDependencies = false |
| 524 | 524 | @AppStorage("agendaSpan") private var agendaSpan = 10 |
| 525 | @AppStorage("agendaStartOffset") private var agendaStartOffset = -3 | |
| 525 | @AppStorage("agendaStartOffset") private var agendaStartOffset = 0 | |
| 526 | 526 | @AppStorage("agendaSubfolders") private var agendaSubfolders = false |
| 527 | 527 | @AppStorage("agendaShowAllDates") private var agendaShowAllDates = false |
| 528 | 528 | @AppStorage("agendaDimBlockedTasks") private var agendaDimBlockedTasks = "t" |
Sources/OrgstarMobile/AgendaScreen.swift +5 −3
| @@ -347,6 +347,8 @@ struct AgendaScreen: View, Equatable { | ||
| 347 | 347 | |
| 348 | 348 | private var firstDay: Int { shown.first } |
| 349 | 349 | |
| 350 | private var todayShown: Bool { (shown.first..<(shown.first + shown.span)).contains(agenda.today) } | |
| 351 | ||
| 350 | 352 | /// The span: `Thu 8 Oct`, `Week of 5 Oct`, `October 2026`, or the days, `5 – 14 Oct`. |
| 351 | 353 | private var title: String { |
| 352 | 354 | guard case .agenda = agenda.mode else { return viewName } |
| @@ -423,7 +425,7 @@ struct AgendaScreen: View, Equatable { | ||
| 423 | 425 | barButton("Today", "smallcircle.filled.circle") { goToday() } |
| 424 | 426 | barButton("Go to Date", "calendar") { jumping = true } |
| 425 | 427 | Menu { |
| 426 | Picker("Span", selection: Binding { range } set: { show($0, around: $0 == nil ? agenda.today : firstDay) }) { | |
| 428 | Picker("Span", selection: Binding { range } set: { show($0, around: $0 == nil || todayShown ? agenda.today : firstDay) }) { | |
| 427 | 429 | ForEach(SpanRange.allCases) { Text($0.title).tag(Optional($0)) } |
| 428 | 430 | Text("\(agenda.span) Days").tag(SpanRange?.none) |
| 429 | 431 | } |
| @@ -900,7 +902,7 @@ struct FilterSheet: View { | ||
| 900 | 902 | } |
| 901 | 903 | } |
| 902 | 904 | |
| 903 | /// Where to refile: the targets `org-refile` offers, searchable. | |
| 905 | /// Files to refile an entry to, at their end, searchable. Headings within them aren't offered. | |
| 904 | 906 | struct RefileSheet: View { |
| 905 | 907 | let targets: [RefileTarget] |
| 906 | 908 | let choose: (RefileTarget?) -> Void |
| @@ -908,7 +910,7 @@ struct RefileSheet: View { | ||
| 908 | 910 | |
| 909 | 911 | var body: some View { |
| 910 | 912 | NavigationStack { |
| 911 | List(targets.filter { query.isEmpty || $0.label.localizedCaseInsensitiveContains(query) }, id: \.self) { target in | |
| 913 | List(targets.filter { $0.start == nil && (query.isEmpty || $0.label.localizedCaseInsensitiveContains(query)) }, id: \.self) { target in | |
| 912 | 914 | Button(target.label) { choose(target) }.foregroundStyle(.primary) |
| 913 | 915 | } |
| 914 | 916 | .searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always)) |
Sources/OrgstarMobile/CaptureScreen.swift +183 −1
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | #if os(iOS) |
| 2 | 2 | import OrgApp |
| 3 | 3 | import OrgCore |
| 4 | import OrgDocument | |
| 4 | 5 | import SwiftUI |
| 5 | 6 | |
| 6 | 7 | /// Capture with a template: its questions (`%^{…}`, `%^g`, `%^t`…), then its text to edit, |
| @@ -35,11 +36,14 @@ struct CaptureScreen: View { | ||
| 35 | 36 | Section { |
| 36 | 37 | TextEditor(text: $text, selection: $selection) |
| 37 | 38 | .font(.body.monospaced()) |
| 38 | .frame(minHeight: 200) | |
| 39 | .frame(minHeight: 120) | |
| 39 | 40 | .focused($focused) |
| 40 | 41 | } footer: { |
| 41 | 42 | if let problem { Text(problem).foregroundStyle(.red) } |
| 42 | 43 | } |
| 44 | if let entry = CaptureEntry(text: text, defaults: session.defaults) { | |
| 45 | EntryFields(entry: entry, tagChoices: Array(Set(context.allTags + context.fileTags)).sorted(), change: change) | |
| 46 | } | |
| 43 | 47 | } else { |
| 44 | 48 | ForEach(questions.indices, id: \.self) { index in |
| 45 | 49 | QuestionField(question: questions[index], answer: $answers[index], defaultDate: request.day.map(Self.date)) |
| @@ -110,6 +114,17 @@ struct CaptureScreen: View { | ||
| 110 | 114 | } |
| 111 | 115 | } |
| 112 | 116 | |
| 117 | /// The entry's text after `command`, as the editor runs it. Changing a date here isn't a | |
| 118 | /// reschedule, so it isn't logged as one. | |
| 119 | private func change(_ command: any OrgCommand, _ answers: [String: String]) { | |
| 120 | var options = session.options | |
| 121 | options.logReschedule = nil | |
| 122 | options.logRedeadline = nil | |
| 123 | if let changed = CaptureEntry.applying(command, answers: answers, to: text, defaults: session.defaults, options: options, now: context.now) { | |
| 124 | text = changed | |
| 125 | } | |
| 126 | } | |
| 127 | ||
| 113 | 128 | /// Now's time of day on `day` (a `Days` number): the default time of an agenda day's |
| 114 | 129 | /// capture, as `org-agenda-capture` sets `org-overriding-default-time`. |
| 115 | 130 | static func date(_ day: Int) -> Date { |
| @@ -205,4 +220,171 @@ struct QuestionField: View { | ||
| 205 | 220 | return formatter.string(from: date) |
| 206 | 221 | } |
| 207 | 222 | } |
| 223 | /// The captured entry's keyword, priority, dates and tags, set without editing its text. | |
| 224 | private struct EntryFields: View { | |
| 225 | let entry: CaptureEntry | |
| 226 | let tagChoices: [String] | |
| 227 | let change: (any OrgCommand, [String: String]) -> Void | |
| 228 | @State private var planning: Planning? | |
| 229 | @State private var choosingTags = false | |
| 230 | ||
| 231 | private enum Planning: String, Identifiable { | |
| 232 | case scheduled = "Scheduled", deadline = "Deadline" | |
| 233 | var id: Self { self } | |
| 234 | } | |
| 235 | ||
| 236 | var body: some View { | |
| 237 | Section { | |
| 238 | Picker("State", selection: Binding { entry.todo ?? "" } set: { change(SetTodo(keyword: $0.isEmpty ? nil : $0), [:]) }) { | |
| 239 | Text("None").tag("") | |
| 240 | ForEach(entry.keywords, id: \.self) { Text($0).tag($0) } | |
| 241 | } | |
| 242 | if !entry.priorities.isEmpty { | |
| 243 | Picker("Priority", selection: Binding { entry.priority ?? "" } set: { change(SetPriority(), ["priority": $0.isEmpty ? " " : $0]) }) { | |
| 244 | Text("None").tag("") | |
| 245 | ForEach(entry.priorities, id: \.self) { Text($0).tag($0) } | |
| 246 | } | |
| 247 | } | |
| 248 | date(.scheduled, entry.scheduled) | |
| 249 | date(.deadline, entry.deadline) | |
| 250 | Button { | |
| 251 | choosingTags = true | |
| 252 | } label: { | |
| 253 | LabeledContent("Tags", value: entry.tags.isEmpty ? "None" : entry.tags.joined(separator: " ")) | |
| 254 | } | |
| 255 | .tint(.primary) | |
| 256 | } | |
| 257 | .sheet(item: $planning) { which in | |
| 258 | DateTimeSheet(title: which.rawValue, initial: initial(which == .scheduled ? entry.scheduled : entry.deadline)) { answer in | |
| 259 | planning = nil | |
| 260 | if let answer { change(SetPlanning(deadline: which == .deadline), ["date": answer]) } | |
| 261 | } | |
| 262 | } | |
| 263 | .sheet(isPresented: $choosingTags) { | |
| 264 | TagsSheet(selected: entry.tags, choices: tagChoices) { tags in | |
| 265 | choosingTags = false | |
| 266 | if let tags { change(SetTags(), ["tags": tags.joined(separator: ":")]) } | |
| 267 | } | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | private func date(_ which: Planning, _ stamp: Timestamp?) -> some View { | |
| 272 | Menu { | |
| 273 | Button("Today") { set(which, 0) } | |
| 274 | Button("Tomorrow") { set(which, 1) } | |
| 275 | Button("In a Week") { set(which, 7) } | |
| 276 | Button("Pick Date…") { planning = which } | |
| 277 | if stamp != nil { | |
| 278 | Button("Remove", role: .destructive) { change(RemovePlanning(deadline: which == .deadline), [:]) } | |
| 279 | } | |
| 280 | } label: { | |
| 281 | LabeledContent(which.rawValue, value: stamp.map(Self.text) ?? "None") | |
| 282 | } | |
| 283 | .tint(.primary) | |
| 284 | } | |
| 285 | ||
| 286 | private func set(_ which: Planning, _ days: Int) { | |
| 287 | let day = Calendar.current.date(byAdding: .day, value: days, to: Date()) ?? Date() | |
| 288 | change(SetPlanning(deadline: which == .deadline), ["date": QuestionField.stamp(day, withTime: false)]) | |
| 289 | } | |
| 290 | ||
| 291 | private func initial(_ stamp: Timestamp?) -> Date { | |
| 292 | guard let stamp else { return Date() } | |
| 293 | let point = stamp.start | |
| 294 | return Calendar.current.date(from: DateComponents(year: point.year, month: point.month, day: point.day, hour: point.hour, minute: point.minute)) ?? Date() | |
| 295 | } | |
| 296 | ||
| 297 | /// `Sat 12 Oct`, with the time when it has one. | |
| 298 | private static func text(_ stamp: Timestamp) -> String { | |
| 299 | let point = stamp.start | |
| 300 | let date = Calendar.current.date(from: DateComponents(year: point.year, month: point.month, day: point.day)) ?? Date() | |
| 301 | let day = date.formatted(.dateTime.weekday(.abbreviated).day().month(.abbreviated)) | |
| 302 | guard let hour = point.hour else { return day } | |
| 303 | return day + String(format: " %02d:%02d", hour, point.minute ?? 0) | |
| 304 | } | |
| 305 | } | |
| 306 | ||
| 307 | /// A date and, when switched on, a time; the answer as a date prompt takes it. | |
| 308 | private struct DateTimeSheet: View { | |
| 309 | let title: String | |
| 310 | let initial: Date | |
| 311 | let done: (String?) -> Void | |
| 312 | @State private var date = Date() | |
| 313 | @State private var withTime = false | |
| 314 | ||
| 315 | var body: some View { | |
| 316 | NavigationStack { | |
| 317 | Form { | |
| 318 | DatePicker(title, selection: $date, displayedComponents: .date).datePickerStyle(.graphical) | |
| 319 | Toggle("Time", isOn: $withTime) | |
| 320 | if withTime { DatePicker("Time", selection: $date, displayedComponents: .hourAndMinute) } | |
| 321 | } | |
| 322 | .navigationTitle(title) | |
| 323 | .navigationBarTitleDisplayMode(.inline) | |
| 324 | .toolbar { | |
| 325 | ToolbarItem(placement: .cancellationAction) { Button("Cancel") { done(nil) } } | |
| 326 | ToolbarItem(placement: .confirmationAction) { Button("Set") { done(QuestionField.stamp(date, withTime: withTime)) } } | |
| 327 | } | |
| 328 | } | |
| 329 | .presentationDetents([.large]) | |
| 330 | .onAppear { date = initial } | |
| 331 | } | |
| 332 | } | |
| 333 | ||
| 334 | /// Tags to toggle, from the file and the workspace, and new ones typed in. | |
| 335 | private struct TagsSheet: View { | |
| 336 | let choices: [String] | |
| 337 | let done: ([String]?) -> Void | |
| 338 | @State private var selected: [String] | |
| 339 | @State private var typed = "" | |
| 340 | ||
| 341 | init(selected: [String], choices: [String], done: @escaping ([String]?) -> Void) { | |
| 342 | _selected = State(initialValue: selected) | |
| 343 | self.choices = choices | |
| 344 | self.done = done | |
| 345 | } | |
| 346 | ||
| 347 | var body: some View { | |
| 348 | NavigationStack { | |
| 349 | List { | |
| 350 | Section { | |
| 351 | TextField("New tag", text: $typed) | |
| 352 | .autocorrectionDisabled() | |
| 353 | .textInputAutocapitalization(.never) | |
| 354 | .onSubmit(add) | |
| 355 | } | |
| 356 | Section { | |
| 357 | ForEach(Array(Set(choices + selected)).sorted(), id: \.self) { tag in | |
| 358 | Button { | |
| 359 | if selected.contains(tag) { selected.removeAll { $0 == tag } } else { selected.append(tag) } | |
| 360 | } label: { | |
| 361 | HStack { | |
| 362 | Text(tag).foregroundStyle(.primary) | |
| 363 | Spacer() | |
| 364 | if selected.contains(tag) { Image(systemName: "checkmark").foregroundStyle(Color.accentColor) } | |
| 365 | } | |
| 366 | } | |
| 367 | } | |
| 368 | } | |
| 369 | } | |
| 370 | .navigationTitle("Tags") | |
| 371 | .navigationBarTitleDisplayMode(.inline) | |
| 372 | .toolbar { | |
| 373 | ToolbarItem(placement: .cancellationAction) { Button("Cancel") { done(nil) } } | |
| 374 | ToolbarItem(placement: .confirmationAction) { | |
| 375 | Button("Set") { | |
| 376 | add() | |
| 377 | done(selected) | |
| 378 | } | |
| 379 | } | |
| 380 | } | |
| 381 | } | |
| 382 | } | |
| 383 | ||
| 384 | /// The typed tags, `:` or spaces between several, added and checked. | |
| 385 | private func add() { | |
| 386 | for tag in typed.split(whereSeparator: { $0 == ":" || $0 == " " }).map(String.init) where !selected.contains(tag) { selected.append(tag) } | |
| 387 | typed = "" | |
| 388 | } | |
| 389 | } | |
| 208 | 390 | #endif |
Sources/OrgstarMobile/FoldersScreen.swift +39 −11
| @@ -12,17 +12,7 @@ struct FoldersScreen: View { | ||
| 12 | 12 | List { |
| 13 | 13 | ForEach(workspace.rootPaths, id: \.self) { root in |
| 14 | 14 | Section((root as NSString).lastPathComponent) { |
| 15 | let files = workspace.files.filter { $0.root == root && $0.kind == .org } | |
| 16 | ForEach(files) { file in | |
| 17 | NavigationLink(value: ReaderRoute.file(file.path)) { | |
| 18 | Label(file.relativePath, systemImage: "doc.text") | |
| 19 | } | |
| 20 | } | |
| 21 | let pending = workspace.downloading.filter { $0.hasPrefix(root + "/") }.sorted() | |
| 22 | ForEach(pending, id: \.self) { path in | |
| 23 | Label(String(path.dropFirst(root.count + 1)), systemImage: "icloud.and.arrow.down") | |
| 24 | .foregroundStyle(.secondary) | |
| 25 | } | |
| 15 | FolderContents(workspace: workspace, root: root, folder: "") | |
| 26 | 16 | Button("Remove Folder", role: .destructive) { try? workspace.removeRoot(path: root) } |
| 27 | 17 | } |
| 28 | 18 | } |
| @@ -61,4 +51,42 @@ struct FoldersScreen: View { | ||
| 61 | 51 | } |
| 62 | 52 | } |
| 63 | 53 | } |
| 54 | /// One folder's subfolders, which open their own contents, then its org files and the files | |
| 55 | /// still downloading into it. `folder` is relative to `root`, empty for the root itself. | |
| 56 | private struct FolderContents: View { | |
| 57 | let workspace: WorkspaceModel | |
| 58 | let root: String | |
| 59 | let folder: String | |
| 60 | ||
| 61 | private var prefix: String { folder.isEmpty ? "" : folder + "/" } | |
| 62 | ||
| 63 | /// Paths below this folder, relative to it. | |
| 64 | private func below(_ relativePaths: [String]) -> [String] { | |
| 65 | relativePaths.filter { $0.hasPrefix(prefix) }.map { String($0.dropFirst(prefix.count)) } | |
| 66 | } | |
| 67 | ||
| 68 | var body: some View { | |
| 69 | let files = workspace.files.filter { $0.root == root && $0.kind == .org && $0.relativePath.hasPrefix(prefix) } | |
| 70 | let pending = below(workspace.downloading.filter { $0.hasPrefix(root + "/") }.map { String($0.dropFirst(root.count + 1)) }) | |
| 71 | let subfolders = Set((below(files.map(\.relativePath)) + pending).compactMap { path in | |
| 72 | path.firstIndex(of: "/").map { String(path[..<$0]) } | |
| 73 | }).sorted { $0.localizedStandardCompare($1) == .orderedAscending } | |
| 74 | ForEach(subfolders, id: \.self) { name in | |
| 75 | NavigationLink { | |
| 76 | List { FolderContents(workspace: workspace, root: root, folder: prefix + name) } | |
| 77 | .navigationTitle(name) | |
| 78 | } label: { | |
| 79 | Label(name, systemImage: "folder") | |
| 80 | } | |
| 81 | } | |
| 82 | ForEach(files.filter { !$0.relativePath.dropFirst(prefix.count).contains("/") }) { file in | |
| 83 | NavigationLink(value: ReaderRoute.file(file.path)) { | |
| 84 | Label(file.name, systemImage: "doc.text") | |
| 85 | } | |
| 86 | } | |
| 87 | ForEach(pending.filter { !$0.contains("/") }, id: \.self) { name in | |
| 88 | Label(name, systemImage: "icloud.and.arrow.down").foregroundStyle(.secondary) | |
| 89 | } | |
| 90 | } | |
| 91 | } | |
| 64 | 92 | #endif |
Sources/OrgstarMobile/OrgstarMobileApp.swift +5 −4
| @@ -165,15 +165,16 @@ struct RootView: View { | ||
| 165 | 165 | .readerDestination(workspace: workspace, session: session) |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | Tab("Settings", systemImage: "gearshape", value: .settings) { | |
| 169 | NavigationStack { SettingsScreen(model: model) } | |
| 170 | } | |
| 171 | Tab(value: .search, role: .search) { | |
| 168 | // An ordinary tab, not the search role, which the tab bar always puts last. | |
| 169 | Tab("Search", systemImage: "magnifyingglass", value: .search) { | |
| 172 | 170 | NavigationStack { |
| 173 | 171 | SearchScreen(workspace: workspace, session: session) |
| 174 | 172 | .readerDestination(workspace: workspace, session: session) |
| 175 | 173 | } |
| 176 | 174 | } |
| 175 | Tab("Settings", systemImage: "gearshape", value: .settings) { | |
| 176 | NavigationStack { SettingsScreen(model: model) } | |
| 177 | } | |
| 177 | 178 | } |
| 178 | 179 | .clockAccessory(model.clock, perform: clock) |
| 179 | 180 | .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in |
Tests/OrgAppTests/AppTests.swift +1
| @@ -563,6 +563,7 @@ struct AgendaModelTests { | ||
| 563 | 563 | let model = try WorkspaceModel(directory: nil) |
| 564 | 564 | try await model.addRoot(notes.url) |
| 565 | 565 | let agenda = AgendaModel(workspace: model) |
| 566 | agenda.startOffset = -3 | |
| 566 | 567 | var utc = Calendar(identifier: .gregorian) |
| 567 | 568 | utc.timeZone = TimeZone(identifier: "UTC")! |
| 568 | 569 | let now = try #require(utc.date(from: DateComponents(year: 2026, month: 10, day: 5, hour: 9))) |
Tests/OrgAppTests/OrgPreferencesTests.swift +1 −1
| @@ -10,7 +10,7 @@ struct OrgPreferencesTests { | ||
| 10 | 10 | // Nothing set: the file's fallbacks, which match the Mac's. |
| 11 | 11 | #expect(OrgPreferences.orgSettings(defaults).todoSequences.first?.active.map(\.name) == ["TODO", "PROJ", "LOOP", "STRT", "WAIT", "HOLD", "IDEA"]) |
| 12 | 12 | #expect(OrgPreferences.options(defaults).logDone == nil && OrgPreferences.options(defaults).tagsColumn == -77) |
| 13 | #expect(OrgPreferences.agendaSpan(defaults) == 10 && OrgPreferences.agendaStartOffset(defaults) == -3) | |
| 13 | #expect(OrgPreferences.agendaSpan(defaults) == 10 && OrgPreferences.agendaStartOffset(defaults) == 0) | |
| 14 | 14 | #expect(OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 12) |
| 15 | 15 | let fallbacks = OrgPreferences.options(defaults) |
| 16 | 16 | #expect(!fallbacks.metaReturnMaySplitLine && fallbacks.hideEmphasisMarkers && fallbacks.prettyEntities && fallbacks.subSuperscriptsNeedBraces) |
Tests/OrgAppTests/UserConfigTests.swift +1 −1
| @@ -22,7 +22,7 @@ struct UserConfigTests { | ||
| 22 | 22 | let text = UserConfig.template(from: source) |
| 23 | 23 | #expect(text.contains("keymap = \"doom\"")) |
| 24 | 24 | #expect(text.contains("\nfill-column = 72")) |
| 25 | #expect(text.contains("org-agenda-start-day = \"-3d\"")) | |
| 25 | #expect(text.contains("org-agenda-start-day = \"+0d\"")) | |
| 26 | 26 | #expect(text.contains("option-as-meta = \"both\"")) |
| 27 | 27 | let target = defaults() |
| 28 | 28 | #expect(UserConfig.apply(text, to: target).isEmpty) |
Tests/OrgDocumentTests/CaptureEntryTests.swift added +25
| @@ -0,0 +1,25 @@ | ||
| 1 | import Foundation | |
| 2 | import OrgCore | |
| 3 | import Testing | |
| 4 | @testable import OrgDocument | |
| 5 | ||
| 6 | struct CaptureEntryTests { | |
| 7 | @Test func readsAndSetsTheFirstHeading() throws { | |
| 8 | var text = "* TODO Call the bank\nNotes here.\n" | |
| 9 | let calendar = Calendar(identifier: .gregorian) | |
| 10 | let now = try #require(calendar.date(from: DateComponents(year: 2026, month: 10, day: 10, hour: 9))) | |
| 11 | text = try #require(CaptureEntry.applying(SetPlanning(deadline: false), answers: ["date": "2026-10-12"], to: text, now: now)) | |
| 12 | text = try #require(CaptureEntry.applying(SetPlanning(deadline: true), answers: ["date": "2026-10-14 15:00"], to: text, now: now)) | |
| 13 | text = try #require(CaptureEntry.applying(SetTags(), answers: ["tags": "home:phone"], to: text, now: now)) | |
| 14 | text = try #require(CaptureEntry.applying(SetPriority(value: "A"), answers: [:], to: text, now: now)) | |
| 15 | text = try #require(CaptureEntry.applying(SetTodo(keyword: "DONE"), answers: [:], to: text, now: now)) | |
| 16 | let entry = try #require(CaptureEntry(text: text)) | |
| 17 | #expect(entry.todo == "DONE" && entry.priority == "A" && entry.tags == ["home", "phone"]) | |
| 18 | #expect(entry.scheduled?.start.day == 12 && entry.deadline?.start.day == 14 && entry.deadline?.start.hour == 15) | |
| 19 | #expect(entry.keywords == ["TODO", "DONE"] && entry.priorities == ["A", "B", "C"]) | |
| 20 | #expect(text.hasSuffix("Notes here.\n")) | |
| 21 | // Nothing to change, and no heading. | |
| 22 | #expect(CaptureEntry.applying(SetTodo(keyword: "DONE"), answers: [:], to: text, now: now) == nil) | |
| 23 | #expect(CaptureEntry(text: "Just a note\n") == nil) | |
| 24 | } | |
| 25 | } | |
docs/manual/guide/07-agenda.org +3 −3
| @@ -50,9 +50,9 @@ The default view is =org-agenda-list=: a run of days, each under a header with i | ||
| 50 | 50 | | Setting | Default | =config.toml= | Range in Settings | |
| 51 | 51 | |------------------------------+---------+-----------------------------------+-------------------| |
| 52 | 52 | | Days shown | 10 | =org-agenda-span = 10= | 1 to 366 | |
| 53 | | First day, relative to today | 3 days before | =org-agenda-start-day = "-3d"= | 0 to 14 days before | | |
| 53 | | First day, relative to today | today | =org-agenda-start-day = "+0d"= | 0 to 14 days before | | |
| 54 | 54 | |
| 55 | Both mirror the Emacs variables of the same name. The defaults are Doom's values, not plain Emacs's (a week starting today). =org-agenda-start-day= takes only day offsets such as ="-3d"= or ="+0d"=. | |
| 55 | Both mirror the Emacs variables of the same name. The span's default is Doom's (plain Emacs shows a week); the agenda starts today, as in plain Emacs. Doom starts it 3 days back, with ="-3d"=. =org-agenda-start-day= takes only day offsets such as ="-3d"= or ="+0d"=. | |
| 56 | 56 | |
| 57 | 57 | ** Day, week and month |
| 58 | 58 | |
| @@ -561,7 +561,7 @@ The board is not available on iOS. | ||
| 561 | 561 | The Agenda tab shows the same views from the same files, using the settings in the synced =config.toml= and the views in =views.toml= (see [[file:14-ios.org][iOS]]). Differences from the Mac: |
| 562 | 562 | |
| 563 | 563 | - The Views menu, at the top left, lists the built-in views, your saved views, Tags and Properties…, which asks for a match string, and Search…, which asks for a search string. There is no TODO-only match or search from the menu; use =/!= in the match, =!= at the start of the search string, or a =todo-match= or =todo-search= view. |
| 564 | - A bar floats at the bottom of the screen with Earlier, Filter, Today, Go to Date, the span and Later. The span menu switches between Day, Week, Month and the configured span (=10 Days= by default). Weeks start on Monday, as on the Mac. In the TODO list and match views the bar has Filter and Agenda, which returns to the day view. Messages show above the bar; tap one to dismiss it. | |
| 564 | - A bar floats at the bottom of the screen with Earlier, Filter, Today, Go to Date, the span and Later. The span menu switches between Day, Week, Month and the configured span (=10 Days= by default); Day, Week and Month are around today when today is shown, else around the first day shown. Weeks start on Monday, as on the Mac. In the TODO list and match views the bar has Filter and Agenda, which returns to the day view. Messages show above the bar; tap one to dismiss it. | |
| 565 | 565 | - The title names the days shown: =Thu 8 Oct=, =Week of 5 Oct=, =October 2026=, or =5 Oct – 14 Oct=. |
| 566 | 566 | - Day headers read =Today · Thu 8 Oct=, =Tomorrow · Fri 9 Oct= or =Mon 12 Oct=, with a + that captures onto that day. Days before today are grey. |
| 567 | 567 | - Pull down to refresh. |
docs/manual/guide/13-configuration.org +1 −1
| @@ -198,7 +198,7 @@ A key you remove from the file goes back to its default. A key that isn't in the | ||
| 198 | 198 | | =org-cycle-hide-block-startup= | boolean | =false= | Fold blocks when a file opens. =#+STARTUP: hideblocks= / =nohideblocks= override it. Mirrors =org-cycle-hide-block-startup=. | |
| 199 | 199 | | =display-line-numbers-type= | boolean | =true= | Line numbers in the editor's gutter. Orgstar numbers lines absolutely; there is no relative or visual mode. | |
| 200 | 200 | | =org-agenda-span= | integer | =10= | Days the agenda shows. Mirrors =org-agenda-span=. | |
| 201 | | =org-agenda-start-day= | string | ="-3d"= | The agenda's first day relative to today, as ="-3d"= or ="+0d"=. Only day offsets are accepted. Mirrors =org-agenda-start-day=. | | |
| 201 | | =org-agenda-start-day= | string | ="+0d"= | The agenda's first day relative to today, as ="-3d"= or ="+0d"=. Only day offsets are accepted. Mirrors =org-agenda-start-day=. | | |
| 202 | 202 | | =org-agenda-show-all-dates= | boolean | =false= | Show days without entries in the agenda; today always shows. Emacs's default is =t=. Mirrors =org-agenda-show-all-dates=. | |
| 203 | 203 | | =org-agenda-skip-scheduled-if-done= | boolean | =false= | Leave a done entry's scheduled date out of the agenda, even on its own day. Mirrors =org-agenda-skip-scheduled-if-done=. | |
| 204 | 204 | | =org-agenda-skip-deadline-if-done= | boolean | =false= | Leave a done entry's deadline out of the agenda, even on its own day. Mirrors =org-agenda-skip-deadline-if-done=. | |
docs/manual/guide/14-ios.org +5 −5
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | The app has four tabs: |
| 8 | 8 | |
| 9 | 9 | - Agenda :: the agenda over your folders, with capture. |
| 10 | - Folders :: the folders of org files you added, and their files. | |
| 11 | - Settings :: where the app's settings come from. | |
| 10 | - Folders :: the folders of org files you added. Each shows its subfolders and org files; tap a subfolder to open it. | |
| 12 | 11 | - Search :: file names and the words of headings. |
| 12 | - Settings :: where the app's settings come from. | |
| 13 | 13 | |
| 14 | 14 | Files open in a reader first. The Edit button in the reader opens the editor. Both use the same open file, so an edit in the editor shows in the reader when you go back. |
| 15 | 15 | |
| @@ -161,7 +161,7 @@ The Agenda tab shows the agenda over all your folders, with the span and start d | ||
| 161 | 161 | - Tap :: an entry to read it, at its heading. |
| 162 | 162 | - Swipe left :: on a TODO entry for Done, which sets the first done keyword of its sequence, or Next State. |
| 163 | 163 | - Swipe right :: for Tomorrow, Next Week (next Monday) or Pick Date, which move the entry's scheduled date, or its deadline on a deadline row. |
| 164 | - Touch and hold :: an entry for TODO State…, Reschedule, Schedule…, Deadline…, Tags…, Priority…, Clock In, Refile…, and Archive…. | |
| 164 | - Touch and hold :: an entry for TODO State…, Reschedule, Schedule…, Deadline…, Tags…, Priority…, Clock In, Refile…, and Archive…. Refile… lists files; the entry goes to the end of the one you choose. Refiling under a heading is Mac only. | |
| 165 | 165 | |
| 166 | 166 | Commands from the agenda change the file directly when it isn't open, and through the editor when it is. If the heading changed since the agenda was built, nothing runs. |
| 167 | 167 | |
| @@ -208,7 +208,7 @@ Tap Capture (the pencil icon) in the Agenda or Folders tab. | ||
| 208 | 208 | |
| 209 | 209 | 1. Choose a template. The first template is selected. |
| 210 | 210 | 2. Answer the template's questions (=%^{…}=, =%^g=, =%^t= and the like), then tap Continue. A template without questions skips this step. |
| 211 | 3. Edit the text. The caret is where =%?= was. | |
| 211 | 3. Edit the text. The caret is where =%?= was. When the text has a heading, the rows below it set the entry's State (its TODO keyword), Priority, Scheduled and Deadline dates (Today, Tomorrow, In a Week, or Pick Date…, with an optional time; Remove takes the date off) and Tags (the target file's and the workspace's, or new ones). They change the text as the editor's commands would, without logging a reschedule. | |
| 212 | 212 | 4. Tap File. |
| 213 | 213 | |
| 214 | 214 | Templates come from =capture.toml= in the configuration folder (see Settings below). Without one, the two default templates apply. A template with =immediate-finish= files as soon as its questions are answered, and one with =jump-to-captured= opens the captured entry. =%^g= offers the target file's tags as choices. |
| @@ -323,7 +323,7 @@ The Agenda, TODO Dependencies and Calendar sections are the only places the app | ||
| 323 | 323 | |
| 324 | 324 | These write =config.toml= in the configuration folder, as the Mac's Settings window does, so the Mac sees the change too. Without a configuration folder they are kept on the device. |
| 325 | 325 | |
| 326 | The In use section shows the TODO keywords, the agenda span and start (for example =10 days, starting 3 days before today=), the reminder lead time, the capture template keys, the theme (=Default=, or the theme file's name), and the font with its size. When =font= names a family that isn't installed on the device, Font shows the system's font with a note, as =System monospaced, 13 pt (JetBrains Mono isn't installed)=. | |
| 326 | The In use section shows the TODO keywords, the agenda span and start (for example =10 days, starting today=), the reminder lead time, the capture template keys, the theme (=Default=, or the theme file's name), and the font with its size. When =font= names a family that isn't installed on the device, Font shows the system's font with a note, as =System monospaced, 13 pt (JetBrains Mono isn't installed)=. | |
| 327 | 327 | |
| 328 | 328 | These settings from =config.toml= apply on iOS: |
| 329 | 329 | |
docs/manual/guide/15-alongside-emacs.org +1 −1
| @@ -191,7 +191,7 @@ Orgstar's defaults follow a common Doom Emacs setup rather than plain Emacs in s | ||
| 191 | 191 | | =org-startup-truncated= | =false= | =t= | |
| 192 | 192 | | =electric-pair-mode= | =true= | off | |
| 193 | 193 | | =org-agenda-span= | 10 days | a week | |
| 194 | | =org-agenda-start-day= | ="-3d"= | today | | |
| 194 | | =org-agenda-start-day= | ="+0d"= | today | | |
| 195 | 195 | | =org-agenda-show-all-dates= | =false= | =t= | |
| 196 | 196 | |
| 197 | 197 | =org-hide-emphasis-markers= and =org-pretty-entities= matter for files you also edit in Emacs: Orgstar aligns tags and tables, and fills paragraphs, by the width text has on screen in your Emacs. If they don't match your Emacs, tags and tables that Orgstar aligns look misaligned in Emacs. |