Commit 7e86cdaf6e

7e86cdaf6e6806ce6a715f7e497be77ee6260c17

parent: 8714ee0921

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-25 22:14 UTC

Board: keyword colours as in the agenda; theme colours in the diff and board

Board column headings and the table's TODO column use the agenda's
keyword colours, so NEXT and WAIT are no longer red. Cards take the
theme's foreground, block background, category, tag and time colours,
and a deadline is agenda-overdue when past and agenda-due-soon
otherwise. The Mac's conflict, sync-conflict and recovery comparisons
draw removed and added lines in the theme's todo and done colours on
its background.

Ref #223

Layout: unified · split

Changed files (6)
Sources/OrgApp/DiffView.swift +16 −5 · view
@@ -5,9 +5,19 @@ import SwiftUI
5public struct DiffView: View { 5public struct DiffView: View {
6 let lines: [DiffLine] 6 let lines: [DiffLine]
7 var context = 3 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 lines = lineDiff(old: old, new: new) 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 /// Lines to show, nil standing for a run of unchanged lines left out. 23 /// Lines to show, nil standing for a run of unchanged lines left out.
@@ -50,14 +60,15 @@ public struct DiffView: View {
50 #else 60 #else
51 .font(.system(.footnote, design: .monospaced)) 61 .font(.system(.footnote, design: .monospaced))
52 #endif 62 #endif
63 .foregroundStyle(foreground ?? .primary)
53 .textSelection(.enabled) 64 .textSelection(.enabled)
54 .padding(8) 65 .padding(8)
55 } 66 }
56 .defaultScrollAnchor(.topLeading) 67 .defaultScrollAnchor(.topLeading)
57 #if os(macOS) 68 #if os(macOS)
58 .background(Color(nsColor: .textBackgroundColor)) 69 .background(background ?? Color(nsColor: .textBackgroundColor))
59 #else 70 #else
60 .background(Color(uiColor: .secondarySystemBackground)) 71 .background(background ?? Color(uiColor: .secondarySystemBackground))
61 #endif 72 #endif
62 } 73 }
63 74
@@ -72,8 +83,8 @@ public struct DiffView: View {
72 private func background(_ kind: DiffLine.Kind) -> Color { 83 private func background(_ kind: DiffLine.Kind) -> Color {
73 switch kind { 84 switch kind {
74 case .same: .clear 85 case .same: .clear
75 case .removed: .red.opacity(0.18) 86 case .removed: removedColor.opacity(0.18)
76 case .added: .green.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 private var table: some View { 96 private var table: some View {
97 Table(rows, selection: $selection, sortOrder: $sortOrder) { 97 Table(rows, selection: $selection, sortOrder: $sortOrder) {
98 TableColumn("TODO", value: \.todoOrder) { row in 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 .width(min: 50, ideal: 60, max: 90) 101 .width(min: 50, ideal: 60, max: 90)
102 TableColumn("P", value: \.priority) { row in Text(row.priority) } 102 TableColumn("P", value: \.priority) { row in Text(row.priority) }
@@ -188,7 +188,7 @@ struct BoardView: View {
188 let cards = entries.filter { $0.todo == keyword } 188 let cards = entries.filter { $0.todo == keyword }
189 return VStack(alignment: .leading, spacing: 8) { 189 return VStack(alignment: .leading, spacing: 8) {
190 HStack { 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 Text("\(cards.count)").foregroundStyle(.secondary) 192 Text("\(cards.count)").foregroundStyle(.secondary)
193 } 193 }
194 ScrollView { 194 ScrollView {
@@ -231,26 +231,34 @@ struct BoardView: View {
231 let selected = current == entry.id 231 let selected = current == entry.id
232 return VStack(alignment: .leading, spacing: 4) { 232 return VStack(alignment: .leading, spacing: 4) {
233 Text((entry.priority.map { "[#\($0)] " } ?? "") + entry.title).lineLimit(3) 233 Text((entry.priority.map { "[#\($0)] " } ?? "") + entry.title).lineLimit(3)
234 .foregroundStyle(theme.color("foreground") ?? .primary)
234 HStack(spacing: 6) { 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 if !entry.tags.isEmpty { 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 if let deadline = entry.deadline { 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 } else if let scheduled = entry.scheduled { 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 .padding(8) 249 .padding(8)
247 .frame(maxWidth: .infinity, alignment: .leading) 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 .overlay { 252 .overlay {
250 if selected { RoundedRectangle(cornerRadius: 6).strokeBorder(theme.color("accent") ?? .accentColor, lineWidth: 2) } 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 // MARK: - Editing 262 // MARK: - Editing
255 263
256 private func perform(_ command: any OrgCommand, on entry: BoardEntry, answers: [String: String] = [:]) { 264 private func perform(_ command: any OrgCommand, on entry: BoardEntry, answers: [String: String] = [:]) {
Sources/Orgstar/VersionViews.swift +18 −3 · view
@@ -1,8 +1,23 @@
1import AppKit 1import AppKit
2import OrgApp 2import OrgApp
3import OrgDocument 3import OrgDocument
4import OrgPresentation
4import SwiftUI 5import SwiftUI
5 6
7/// A diff in the theme's colours: removed lines in its TODO red, added ones in its DONE green.
8struct 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/// The buffer and the file on disk changed differently: what differs, and how to settle it. 21/// The buffer and the file on disk changed differently: what differs, and how to settle it.
7struct ConflictSheet: View { 22struct ConflictSheet: View {
8 let session: DocumentSession 23 let session: DocumentSession
@@ -15,7 +30,7 @@ struct ConflictSheet: View {
15 .foregroundStyle(.secondary) 30 .foregroundStyle(.secondary)
16 .fixedSize(horizontal: false, vertical: true) 31 .fixedSize(horizontal: false, vertical: true)
17 if let versions = session.conflictVersions() { 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 HStack { 35 HStack {
21 Button("Decide Later") { dismiss() }.keyboardShortcut(.cancelAction) 36 Button("Decide Later") { dismiss() }.keyboardShortcut(.cancelAction)
@@ -51,7 +66,7 @@ struct SyncConflictSheet: View {
51 Text("Lines marked - are in the file, + in the copy. The copy goes to the recovery folder when it's resolved.") 66 Text("Lines marked - are in the file, + in the copy. The copy goes to the recovery folder when it's resolved.")
52 .foregroundStyle(.secondary) 67 .foregroundStyle(.secondary)
53 if let selected, let copy = session.recoveryText(selected), let mine = session.document?.text { 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 HStack { 72 HStack {
@@ -102,7 +117,7 @@ struct RecoverySheet: View {
102 VStack(alignment: .leading, spacing: 10) { 117 VStack(alignment: .leading, spacing: 10) {
103 Text("Lines marked - are in the buffer, + in the kept version.").foregroundStyle(.secondary) 118 Text("Lines marked - are in the buffer, + in the kept version.").foregroundStyle(.secondary)
104 if let selected, let kept = session.recoveryText(selected), let mine = session.document?.text { 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 } else { 121 } else {
107 Spacer() 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** Conflicts 248** Conflicts
249 249
250When 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: 250When 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| Button | What it does | 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** Kanban 703** Kanban
704 704
705Each 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. 705Each 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
707From 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. 707From 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| Key | Colors | 753| Key | Colors |
754|-------------------------+--------------------------------------------------------------| 754|-------------------------+--------------------------------------------------------------|
755| =background= | the editor's background | 755| =background= | the editor's background; on the Mac, comparisons of versions |
756| =foreground= | body text | 756| =foreground= | body text; on the Mac, board cards and comparisons |
757| =cursor= | the caret | 757| =cursor= | the caret |
758| =selection= | selected text's background | 758| =selection= | selected text's background |
759| =accent= | buttons, toggles and selection in lists; unset: the system's | 759| =accent= | buttons, toggles and selection in lists; unset: the system's |
760| =heading-1= … =heading-7= | headings of that level | 760| =heading-1= … =heading-7= | headings of that level |
761| =heading-8= | level 8 and deeper headings | 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| =todo-next= | keywords of work under way: =NEXT=, =STRT= and the others above | 763| =todo-next= | keywords of work under way: =NEXT=, =STRT= and the others above |
764| =todo-waiting= | keywords of work on hold: =WAIT=, =HOLD= and the others above | 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| =todo-cancelled= | done keywords that cancel: =KILL=, =CANCELLED= and the others above | 766| =todo-cancelled= | done keywords that cancel: =KILL=, =CANCELLED= and the others above |
767| =priority= | =[#A]= cookies; in the agenda, priorities other than A, B and C | 767| =priority= | =[#A]= cookies; in the agenda, priorities other than A, B and C |
768| =priority-a= | agenda: priority A | 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| =keyword= | =#+KEYWORD= lines | 779| =keyword= | =#+KEYWORD= lines |
780| =metadata= | planning lines, drawers, properties and clocks | 780| =metadata= | planning lines, drawers, properties and clocks |
781| =special= | footnotes, statistics cookies, targets, macros and LaTeX | 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| =block-delimiter= | =#+begin_= and =#+end_= lines | 783| =block-delimiter= | =#+begin_= and =#+end_= lines |
784| =table= | tables | 784| =table= | tables |
785| =line-number= | line numbers | 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| =agenda-today= | today's header and the now line | 807| =agenda-today= | today's header and the now line |
808| =agenda-time= | times and statuses of agenda rows with the normal status | 808| =agenda-time= | times and statuses of agenda rows with the normal status |
809| =agenda-category= | categories | 809| =agenda-category= | categories |
810| =agenda-overdue= | agenda: the status of entries past their deadline or scheduled date, and the Overdue group | 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 | 811| =agenda-due-soon= | agenda: the status of deadlines due today or coming up; other deadlines on board cards |
812| =agenda-event= | agenda: calendar events whose calendar has no color | 812| =agenda-event= | agenda: calendar events whose calendar has no color |
813| =habit-clear= | habit graph: not due yet | 813| =habit-clear= | habit graph: not due yet |
814| =habit-ready= | habit graph: due | 814| =habit-ready= | habit graph: due |
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