Commit 7e86cdaf6e
Verified · cmc
Changed files (6)
Sources/OrgApp/DiffView.swift +16 −5 · view
| @@ -5,9 +5,19 @@ import SwiftUI | ||
| 5 | 5 | public struct DiffView: View { |
| 6 | 6 | let lines: [DiffLine] |
| 7 | 7 | var context = 3 |
| 8 | let removedColor: Color | |
| 9 | let addedColor: Color | |
| 10 | let foreground: Color? | |
| 11 | let background: Color? | |
| 8 | 12 | |
| 9 | public init(old: String, new: String) { | |
| 13 | /// `removed` and `added` tint the changed lines; `foreground` and `background` default to | |
| 14 | /// the system's text colours. | |
| 15 | public init(old: String, new: String, removed: Color = .red, added: Color = .green, foreground: Color? = nil, background: Color? = nil) { | |
| 10 | 16 | lines = lineDiff(old: old, new: new) |
| 17 | removedColor = removed | |
| 18 | addedColor = added | |
| 19 | self.foreground = foreground | |
| 20 | self.background = background | |
| 11 | 21 | } |
| 12 | 22 | |
| 13 | 23 | /// Lines to show, nil standing for a run of unchanged lines left out. |
| @@ -50,14 +60,15 @@ public struct DiffView: View { | ||
| 50 | 60 | #else |
| 51 | 61 | .font(.system(.footnote, design: .monospaced)) |
| 52 | 62 | #endif |
| 63 | .foregroundStyle(foreground ?? .primary) | |
| 53 | 64 | .textSelection(.enabled) |
| 54 | 65 | .padding(8) |
| 55 | 66 | } |
| 56 | 67 | .defaultScrollAnchor(.topLeading) |
| 57 | 68 | #if os(macOS) |
| 58 | .background(Color(nsColor: .textBackgroundColor)) | |
| 69 | .background(background ?? Color(nsColor: .textBackgroundColor)) | |
| 59 | 70 | #else |
| 60 | .background(Color(uiColor: .secondarySystemBackground)) | |
| 71 | .background(background ?? Color(uiColor: .secondarySystemBackground)) | |
| 61 | 72 | #endif |
| 62 | 73 | } |
| 63 | 74 | |
| @@ -72,8 +83,8 @@ public struct DiffView: View { | ||
| 72 | 83 | private func background(_ kind: DiffLine.Kind) -> Color { |
| 73 | 84 | switch kind { |
| 74 | 85 | case .same: .clear |
| 75 | case .removed: .red.opacity(0.18) | |
| 76 | case .added: .green.opacity(0.18) | |
| 86 | case .removed: removedColor.opacity(0.18) | |
| 87 | case .added: addedColor.opacity(0.18) | |
| 77 | 88 | } |
| 78 | 89 | } |
| 79 | 90 | } |
Sources/Orgstar/BoardView.swift +15 −7 · view
| @@ -96,7 +96,7 @@ struct BoardView: View { | ||
| 96 | 96 | private var table: some View { |
| 97 | 97 | Table(rows, selection: $selection, sortOrder: $sortOrder) { |
| 98 | 98 | TableColumn("TODO", value: \.todoOrder) { row in |
| 99 | Text(row.entry.todo ?? "").foregroundStyle(theme.keywordColor(row.entry.todo ?? "", done: row.entry.isDone)).bold() | |
| 99 | Text(row.entry.todo ?? "").foregroundStyle(keywordColor(row.entry.todo ?? "", done: row.entry.isDone)).bold() | |
| 100 | 100 | } |
| 101 | 101 | .width(min: 50, ideal: 60, max: 90) |
| 102 | 102 | TableColumn("P", value: \.priority) { row in Text(row.priority) } |
| @@ -188,7 +188,7 @@ struct BoardView: View { | ||
| 188 | 188 | let cards = entries.filter { $0.todo == keyword } |
| 189 | 189 | return VStack(alignment: .leading, spacing: 8) { |
| 190 | 190 | HStack { |
| 191 | Text(keyword).font(.headline).foregroundStyle(theme.keywordColor(keyword, done: cards.first?.isDone ?? false)) | |
| 191 | Text(keyword).font(.headline).foregroundStyle(keywordColor(keyword, done: cards.first?.isDone ?? false)) | |
| 192 | 192 | Text("\(cards.count)").foregroundStyle(.secondary) |
| 193 | 193 | } |
| 194 | 194 | ScrollView { |
| @@ -231,26 +231,34 @@ struct BoardView: View { | ||
| 231 | 231 | let selected = current == entry.id |
| 232 | 232 | return VStack(alignment: .leading, spacing: 4) { |
| 233 | 233 | Text((entry.priority.map { "[#\($0)] " } ?? "") + entry.title).lineLimit(3) |
| 234 | .foregroundStyle(theme.color("foreground") ?? .primary) | |
| 234 | 235 | HStack(spacing: 6) { |
| 235 | Text(entry.category).font(.caption).foregroundStyle(.secondary) | |
| 236 | Text(entry.category).font(.caption).foregroundStyle(theme.color("agenda-category") ?? .secondary) | |
| 236 | 237 | if !entry.tags.isEmpty { |
| 237 | Text(entry.tags.joined(separator: " ")).font(.caption).foregroundStyle(.secondary).lineLimit(1) | |
| 238 | Text(entry.tags.joined(separator: " ")).font(.caption).foregroundStyle(theme.color("tags") ?? .secondary).lineLimit(1) | |
| 238 | 239 | } |
| 239 | 240 | } |
| 240 | 241 | if let deadline = entry.deadline { |
| 241 | Text("Deadline \(deadline)").font(.caption).foregroundStyle(.red) | |
| 242 | // As the agenda colours a deadline: overdue when past, else due soon. | |
| 243 | let overdue = deadline.prefix(10) < Date().formatted(Date.ISO8601FormatStyle(timeZone: .current).year().month().day()) | |
| 244 | Text("Deadline \(deadline)").font(.caption).foregroundStyle(theme.color(overdue ? "agenda-overdue" : "agenda-due-soon") ?? .red) | |
| 242 | 245 | } else if let scheduled = entry.scheduled { |
| 243 | Text("Scheduled \(scheduled)").font(.caption).foregroundStyle(.secondary) | |
| 246 | Text("Scheduled \(scheduled)").font(.caption).foregroundStyle(theme.color("agenda-time") ?? .secondary) | |
| 244 | 247 | } |
| 245 | 248 | } |
| 246 | 249 | .padding(8) |
| 247 | 250 | .frame(maxWidth: .infinity, alignment: .leading) |
| 248 | .background(RoundedRectangle(cornerRadius: 6).fill(Color(nsColor: .controlBackgroundColor))) | |
| 251 | .background(RoundedRectangle(cornerRadius: 6).fill(theme.color("block-background") ?? Color(nsColor: .controlBackgroundColor))) | |
| 249 | 252 | .overlay { |
| 250 | 253 | if selected { RoundedRectangle(cornerRadius: 6).strokeBorder(theme.color("accent") ?? .accentColor, lineWidth: 2) } |
| 251 | 254 | } |
| 252 | 255 | } |
| 253 | 256 | |
| 257 | /// A keyword's colour as the agenda draws it: its own, else its class's (NEXT, WAIT, …). | |
| 258 | private func keywordColor(_ keyword: String, done: Bool) -> Color { | |
| 259 | theme.dynamic(done ? .systemGreen : .systemRed) { [theme] in theme.todoColor(keyword, isDone: done, dark: $0) } | |
| 260 | } | |
| 261 | ||
| 254 | 262 | // MARK: - Editing |
| 255 | 263 | |
| 256 | 264 | private func perform(_ command: any OrgCommand, on entry: BoardEntry, answers: [String: String] = [:]) { |
Sources/Orgstar/VersionViews.swift +18 −3 · view
| @@ -1,8 +1,23 @@ | ||
| 1 | 1 | import AppKit |
| 2 | 2 | import OrgApp |
| 3 | 3 | import OrgDocument |
| 4 | import OrgPresentation | |
| 4 | 5 | import SwiftUI |
| 5 | 6 | |
| 7 | /// A diff in the theme's colours: removed lines in its TODO red, added ones in its DONE green. | |
| 8 | struct ThemedDiff: View { | |
| 9 | let old: String | |
| 10 | let new: String | |
| 11 | @Environment(\.orgTheme) private var theme | |
| 12 | ||
| 13 | var body: some View { | |
| 14 | DiffView( | |
| 15 | old: old, new: new, removed: theme.color("todo") ?? .red, added: theme.color("done") ?? .green, | |
| 16 | foreground: theme.color("foreground"), background: theme.color("background") | |
| 17 | ) | |
| 18 | } | |
| 19 | } | |
| 20 | ||
| 6 | 21 | /// The buffer and the file on disk changed differently: what differs, and how to settle it. |
| 7 | 22 | struct ConflictSheet: View { |
| 8 | 23 | let session: DocumentSession |
| @@ -15,7 +30,7 @@ struct ConflictSheet: View { | ||
| 15 | 30 | .foregroundStyle(.secondary) |
| 16 | 31 | .fixedSize(horizontal: false, vertical: true) |
| 17 | 32 | if let versions = session.conflictVersions() { |
| 18 | DiffView(old: versions.disk, new: versions.mine) | |
| 33 | ThemedDiff(old: versions.disk, new: versions.mine) | |
| 19 | 34 | } |
| 20 | 35 | HStack { |
| 21 | 36 | Button("Decide Later") { dismiss() }.keyboardShortcut(.cancelAction) |
| @@ -51,7 +66,7 @@ struct SyncConflictSheet: View { | ||
| 51 | 66 | Text("Lines marked - are in the file, + in the copy. The copy goes to the recovery folder when it's resolved.") |
| 52 | 67 | .foregroundStyle(.secondary) |
| 53 | 68 | if let selected, let copy = session.recoveryText(selected), let mine = session.document?.text { |
| 54 | DiffView(old: mine, new: copy) | |
| 69 | ThemedDiff(old: mine, new: copy) | |
| 55 | 70 | } |
| 56 | 71 | } |
| 57 | 72 | HStack { |
| @@ -102,7 +117,7 @@ struct RecoverySheet: View { | ||
| 102 | 117 | VStack(alignment: .leading, spacing: 10) { |
| 103 | 118 | Text("Lines marked - are in the buffer, + in the kept version.").foregroundStyle(.secondary) |
| 104 | 119 | if let selected, let kept = session.recoveryText(selected), let mine = session.document?.text { |
| 105 | DiffView(old: mine, new: kept) | |
| 120 | ThemedDiff(old: mine, new: kept) | |
| 106 | 121 | } else { |
| 107 | 122 | Spacer() |
| 108 | 123 | } |
docs/manual/guide/01-files-and-folders.org +1 −1 · view
| @@ -247,7 +247,7 @@ To throw away your unsaved edits and load the file as it is on disk, choose File | ||
| 247 | 247 | |
| 248 | 248 | ** Conflicts |
| 249 | 249 | |
| 250 | When a buffer conflicts with its file, automatic saving stops for that buffer, the =Conflict= button appears in the toolbar, and the conflict sheet opens. The sheet shows the differences: lines marked =-= are on disk, lines marked =+= are in your version, with three lines of context around each change. Choose: | |
| 250 | When a buffer conflicts with its file, automatic saving stops for that buffer, the =Conflict= button appears in the toolbar, and the conflict sheet opens. The sheet shows the differences: lines marked =-= are on disk, lines marked =+= are in your version, with three lines of context around each change. Removed lines are tinted in the theme's =todo= color and added lines in its =done= color. Choose: | |
| 251 | 251 | |
| 252 | 252 | | Button | What it does | |
| 253 | 253 | |--------------------+------------------------------------------------------------------------------------------------------------------| |
docs/manual/guide/07-agenda.org +1 −1 · view
| @@ -702,7 +702,7 @@ Columns: TODO, priority, title, tags, scheduled, deadline, your property columns | ||
| 702 | 702 | |
| 703 | 703 | ** Kanban |
| 704 | 704 | |
| 705 | Each TODO keyword your files use gets a column, in sequence order, done keywords included. A card shows the priority and title, the category and tags, and the deadline (in red) or the scheduled date. Drag a card to another column to set that keyword; this is the same edit as changing the state in the editor, so logging and state-change notes apply (a note is asked for in the main window). Double-click a card to open its entry. With VoiceOver, each card has a Move to … action for each other column. | |
| 705 | Each TODO keyword your files use gets a column, in sequence order, done keywords included. Column headings take the keyword colours of the agenda and editor (see [[file:13-configuration.org][Configuration]]). A card shows the priority and title, the category and tags, and the deadline or the scheduled date, in the theme's agenda colours: a past deadline in =agenda-overdue=, one due today or later in =agenda-due-soon=. Drag a card to another column to set that keyword; this is the same edit as changing the state in the editor, so logging and state-change notes apply (a note is asked for in the main window). Double-click a card to open its entry. With VoiceOver, each card has a Move to … action for each other column. | |
| 706 | 706 | |
| 707 | 707 | From the keyboard, click a card or press an arrow key to select one. The arrow keys move between cards, =Return= opens the selected card's entry, and =⇧←= and =⇧→= move it to the column before or after, as dragging does. |
| 708 | 708 | |
docs/manual/guide/13-configuration.org +7 −7 · view
| @@ -752,17 +752,17 @@ The colors stack in this order, each over the one before: the themes chosen with | ||
| 752 | 752 | |
| 753 | 753 | | Key | Colors | |
| 754 | 754 | |-------------------------+--------------------------------------------------------------| |
| 755 | | =background= | the editor's background | | |
| 756 | | =foreground= | body text | | |
| 755 | | =background= | the editor's background; on the Mac, comparisons of versions | | |
| 756 | | =foreground= | body text; on the Mac, board cards and comparisons | | |
| 757 | 757 | | =cursor= | the caret | |
| 758 | 758 | | =selection= | selected text's background | |
| 759 | 759 | | =accent= | buttons, toggles and selection in lists; unset: the system's | |
| 760 | 760 | | =heading-1= … =heading-7= | headings of that level | |
| 761 | 761 | | =heading-8= | level 8 and deeper headings | |
| 762 | | =todo= | TODO keywords not yet done | | |
| 762 | | =todo= | TODO keywords not yet done; on the Mac, removed lines in comparisons | | |
| 763 | 763 | | =todo-next= | keywords of work under way: =NEXT=, =STRT= and the others above | |
| 764 | 764 | | =todo-waiting= | keywords of work on hold: =WAIT=, =HOLD= and the others above | |
| 765 | | =done= | DONE keywords | | |
| 765 | | =done= | DONE keywords; on the Mac, added lines in comparisons | | |
| 766 | 766 | | =todo-cancelled= | done keywords that cancel: =KILL=, =CANCELLED= and the others above | |
| 767 | 767 | | =priority= | =[#A]= cookies; in the agenda, priorities other than A, B and C | |
| 768 | 768 | | =priority-a= | agenda: priority A | |
| @@ -779,7 +779,7 @@ The colors stack in this order, each over the one before: the themes chosen with | ||
| 779 | 779 | | =keyword= | =#+KEYWORD= lines | |
| 780 | 780 | | =metadata= | planning lines, drawers, properties and clocks | |
| 781 | 781 | | =special= | footnotes, statistics cookies, targets, macros and LaTeX | |
| 782 | | =block-background= | the band behind blocks | | |
| 782 | | =block-background= | the band behind blocks; board cards | | |
| 783 | 783 | | =block-delimiter= | =#+begin_= and =#+end_= lines | |
| 784 | 784 | | =table= | tables | |
| 785 | 785 | | =line-number= | line numbers | |
| @@ -807,8 +807,8 @@ The colors stack in this order, each over the one before: the themes chosen with | ||
| 807 | 807 | | =agenda-today= | today's header and the now line | |
| 808 | 808 | | =agenda-time= | times and statuses of agenda rows with the normal status | |
| 809 | 809 | | =agenda-category= | categories | |
| 810 | | =agenda-overdue= | agenda: the status of entries past their deadline or scheduled date, and the Overdue group | | |
| 811 | | =agenda-due-soon= | agenda: the status of deadlines due today or coming up | | |
| 810 | | =agenda-overdue= | agenda: the status of entries past their deadline or scheduled date, and the Overdue group; past deadlines on board cards | | |
| 811 | | =agenda-due-soon= | agenda: the status of deadlines due today or coming up; other deadlines on board cards | | |
| 812 | 812 | | =agenda-event= | agenda: calendar events whose calendar has no color | |
| 813 | 813 | | =habit-clear= | habit graph: not due yet | |
| 814 | 814 | | =habit-ready= | habit graph: due | |