Commit 801e496807

801e496807e41f08001dbd99622e2fa686a34058

parent: a15753a827

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-27 04:43 UTC

Flashcards in org-fc's format with review on Mac, iOS and watch

Cards are org-fc's: the fc tag, FC_CREATED, FC_TYPE, FC_ALGO, ID and a
REVIEW_DATA table, scheduled with org-fc's default SM2 (sm2-v1). Make
Normal, Double, Cloze and Text-Input Flashcard, Update, Suspend and
Unsuspend Flashcard write what org-fc writes; oracle tests compare them,
ratings, the review history and the due filters with org-fc in Emacs
(ORGSTAR_ORG_FC). Due cards are found through the index's fc tags.

Review Flashcards on the Mac (Window menu, palette) and iPhone and iPad
(agenda Views menu, Commands, Go menu, orgstar://review) rates through
the document session and appends org-fc's review history
(org-fc-review-history-file in config.toml). A Flashcards widget counts
due cards; the watch reviews normal and double cards.

Closes #172

Layout: unified · split

Changed files (40)
Sources/OrgApp/AgendaSnapshot.swift +5 · view
@@ -272,6 +272,8 @@ public enum AppLink: Equatable, Sendable {
272272 case clock
273273 /// The capture sheet, with a template's key or the first template.
274274 case capture(template: String?)
275 /// The flashcard review.
276 case review
275277
276278 public static let scheme = "orgstar"
277279
@@ -283,6 +285,8 @@ public enum AppLink: Equatable, Sendable {
283285 components.host = "agenda"
284286 case .clock:
285287 components.host = "clock"
288 case .review:
289 components.host = "review"
286290 case .capture(let template):
287291 components.host = "capture"
288292 if let template { components.queryItems = [URLQueryItem(name: "template", value: template)] }
@@ -299,6 +303,7 @@ public enum AppLink: Equatable, Sendable {
299303 switch components.host {
300304 case "agenda": self = .agenda
301305 case "clock": self = .clock
306 case "review": self = .review
302307 case "capture": self = .capture(template: query("template"))
303308 case "entry":
304309 guard let path = query("path"), let offset = query("offset").flatMap(Int.init) else { return nil }
Sources/OrgApp/CommandTitles.swift +8 · view
@@ -181,6 +181,10 @@ enum CommandTitles {
181181 String(localized: "Lint All Folders", comment: "Command title"),
182182 String(localized: "Lint File", comment: "Command title"),
183183 String(localized: "Lower Priority", comment: "Command title"),
184 String(localized: "Make Cloze Flashcard…", comment: "Command title"),
185 String(localized: "Make Double Flashcard", comment: "Command title"),
186 String(localized: "Make Normal Flashcard", comment: "Command title"),
187 String(localized: "Make Text-Input Flashcard", comment: "Command title"),
184188 String(localized: "Mark Subtree", comment: "Command title"),
185189 String(localized: "Mark as Default Clock Task", comment: "Command title"),
186190 String(localized: "Messages", comment: "Command title"),
@@ -278,6 +282,7 @@ enum CommandTitles {
278282 String(localized: "Resolve Open Clocks…", comment: "Command title"),
279283 String(localized: "Resolve Sync Conflicts…", comment: "Command title"),
280284 String(localized: "Revert to File on Disk", comment: "Command title"),
285 String(localized: "Review Flashcards", comment: "Command title"),
281286 String(localized: "Run Last Macro", comment: "Command title"),
282287 String(localized: "Run Macro…", comment: "Command title"),
283288 String(localized: "Run Source Block", comment: "Command title"),
@@ -338,6 +343,7 @@ enum CommandTitles {
338343 String(localized: "Store ID Link", comment: "Command title"),
339344 String(localized: "Store Link", comment: "Command title"),
340345 String(localized: "Strike-Through", comment: "Command title"),
346 String(localized: "Suspend Flashcard", comment: "Command title"),
341347 String(localized: "Switch to Buffer…", comment: "Command title"),
342348 String(localized: "Sync Attachments", comment: "Command title"),
343349 String(localized: "Sync with Working Copy", comment: "Command title"),
@@ -363,8 +369,10 @@ enum CommandTitles {
363369 String(localized: "Underline", comment: "Command title"),
364370 String(localized: "Undo", comment: "Command title"),
365371 String(localized: "Unset Attachment Folder", comment: "Command title"),
372 String(localized: "Unsuspend Flashcard", comment: "Command title"),
366373 String(localized: "Up to Parent Heading", comment: "Command title"),
367374 String(localized: "Update Dynamic Block", comment: "Command title"),
375 String(localized: "Update Flashcard", comment: "Command title"),
368376 String(localized: "Update at Point", comment: "Command title"),
369377 String(localized: "Use Selection for Find", comment: "Command title"),
370378 String(localized: "Verbatim", comment: "Command title"),
Sources/OrgApp/FlashcardReview.swift added +172 · view
@@ -0,0 +1,172 @@
1import Foundation
2import Observation
3import OrgCore
4import OrgIndex
5
6/// A review of the flashcards due across the workspace, as `org-fc-review` runs one over
7/// `org-fc-directories`: each due position shown, flipped and rated, its review data written
8/// back through the document session (an edit the buffer can undo when the file is open) and
9/// a line added to the review history. A position rated Again comes back at the end.
10@MainActor
11@Observable
12public final class FlashcardReview {
13 /// Positions left, the one shown first.
14 public private(set) var queue: [Flashcards.Item] = []
15 /// What the first position shows, read from its file's current text.
16 public private(set) var face: Flashcards.Face?
17 public var flipped = false
18 /// A text-input card's typed answer.
19 public var typed = ""
20 public private(set) var reviewed = 0
21 public private(set) var isLoading = false
22 /// Set once the first load finished.
23 public private(set) var loaded = false
24 /// Why the last action didn't happen, for the screen to show.
25 public var message: String?
26
27 private let workspace: WorkspaceModel
28 private let session: DocumentSession
29 @ObservationIgnored private var shownAt = Date()
30 /// Where ratings are logged: `org-fc-review-history-file`.
31 @ObservationIgnored public var history = OrgPreferences.fcReviewHistoryFile()
32
33 public init(workspace: WorkspaceModel, session: DocumentSession) {
34 self.workspace = workspace
35 self.session = session
36 }
37
38 public var current: Flashcards.Item? { queue.first }
39
40 /// The cards in the workspace's files, open files as their buffers have them. Only files
41 /// whose index rows have a heading tagged `fc` are read.
42 public static func cards(workspace: WorkspaceModel, session: DocumentSession) async -> [(path: String, card: Flashcards.Card)] {
43 let open = session.openDocuments
44 let overlay = workspace.overlay(open)
45 let paths = (try? workspace.index.files(withLocalTag: Flashcards.tag, overlay: overlay)) ?? []
46 let texts = session.openTexts
47 let defaults = session.defaults
48 return await read(paths: paths, texts: texts, defaults: defaults)
49 }
50
51 @concurrent
52 private static func read(paths: [String], texts: [String: String], defaults: OrgSettings) async -> [(path: String, card: Flashcards.Card)] {
53 paths.flatMap { path -> [(path: String, card: Flashcards.Card)] in
54 guard path.hasSuffix(".org"), let text = texts[path] ?? (try? String(contentsOfFile: path, encoding: .utf8)) else { return [] }
55 return Flashcards.cards(in: text, defaults: defaults).map { (path, $0) }
56 }
57 }
58
59 /// Finds the positions due now and shows the first.
60 public func start(now: Date = Date()) async {
61 isLoading = true
62 let cards = await Self.cards(workspace: workspace, session: session)
63 queue = Flashcards.due(cards, at: now)
64 reviewed = 0
65 isLoading = false
66 loaded = true
67 show()
68 }
69
70 /// The first position's face, from its file as it is now.
71 private func show() {
72 flipped = false
73 typed = ""
74 face = nil
75 while let item = queue.first {
76 if let card = fresh(item), let face = Flashcards.face(card, position: item.position) {
77 queue[0].card = card
78 self.face = face
79 shownAt = Date()
80 return
81 }
82 queue.removeFirst()
83 }
84 }
85
86 /// The item's card as its file has it now.
87 private func fresh(_ item: Flashcards.Item) -> Flashcards.Card? {
88 guard let text = session.exportText(of: item.path) else { return nil }
89 return Flashcards.cards(in: text, defaults: session.defaults).first { $0.id == item.card.id }
90 }
91
92 public func flip() {
93 guard face != nil else { return }
94 flipped = true
95 }
96
97 /// Rates the shown position, writes its review data and the history line, and shows the next.
98 public func rate(_ rating: Flashcards.Rating, now: Date = Date()) {
99 guard let item = current else { return }
100 switch Self.rate(path: item.path, card: item.card.id, position: item.position, rating: rating, seconds: now.timeIntervalSince(shownAt), session: session, history: history, now: now) {
101 case .rated(let problem):
102 message = problem
103 case .gone:
104 message = String(localized: "The card changed; it was skipped.", comment: "Flashcard review")
105 queue.removeFirst()
106 return show()
107 case .failed(let reason):
108 message = reason
109 return
110 }
111 reviewed += 1
112 queue.removeFirst()
113 if rating == .again { queue.append(item) }
114 show()
115 }
116
117 public enum Outcome: Equatable {
118 /// Rated; with why the history line couldn't be added, if it couldn't.
119 case rated(String?)
120 /// The card or its position is no longer in the file.
121 case gone
122 case failed(String)
123 }
124
125 /// Rates a position of the card with ID `card` in `path`, through the session, and adds the
126 /// line to the review history: for the review screen and for the watch.
127 public static func rate(path: String, card id: String, position name: String, rating: Flashcards.Rating, seconds: Double, session: DocumentSession,
128 history: URL = OrgPreferences.fcReviewHistoryFile(), now: Date = Date()) -> Outcome {
129 guard let text = session.exportText(of: path), let card = Flashcards.cards(in: text, defaults: session.defaults).first(where: { $0.id == id }),
130 let position = card.positions.first(where: { $0.name == name }) else { return .gone }
131 if case .failed(let reason) = session.perform(RateFlashcard(card: id, position: name, rating: rating), path: path, at: 0, expect: nil, now: now) {
132 return .failed(reason)
133 }
134 let line = Flashcards.historyLine(at: now, path: path, id: id, position: position, rating: rating, seconds: seconds)
135 do {
136 try appendHistory(line, to: history)
137 return .rated(nil)
138 } catch {
139 return .rated(String(localized: "Can't add to the review history: \(error.localizedDescription)", comment: "Flashcard review"))
140 }
141 }
142
143 /// Tags the shown card `suspended` and leaves its positions out of the rest of the review.
144 public func suspend() {
145 guard let item = current, let card = fresh(item) else { return }
146 let step = session.perform(SuspendFlashcard(), path: item.path, at: card.headingOffset, expect: (card.headingOffset, card.headingLine))
147 if case .failed(let reason) = step {
148 message = reason
149 return
150 }
151 queue.removeAll { $0.path == item.path && $0.card.id == item.card.id }
152 show()
153 }
154
155 static func appendHistory(_ line: String, to file: URL) throws {
156 let manager = FileManager.default
157 if !manager.fileExists(atPath: file.path) {
158 try manager.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)
159 try Data(line.utf8).write(to: file)
160 return
161 }
162 let handle = try FileHandle(forWritingTo: file)
163 defer { try? handle.close() }
164 try handle.seekToEnd()
165 try handle.write(contentsOf: Data(line.utf8))
166 }
167
168 /// Whether the typed answer is the expected one.
169 public var typedIsRight: Bool {
170 face?.expected.map { $0 == typed } ?? false
171 }
172}
Sources/OrgApp/FlashcardReviewView.swift added +161 · view
@@ -0,0 +1,161 @@
1import OrgCore
2import SwiftUI
3
4/// The review screen, on the Mac and on iPhone and iPad: a card's front, Show Answer, then
5/// the back with org-fc's four ratings as large buttons. On the Mac, Space or Return flips
6/// and A, H, G and E rate, as in org-fc.
7public struct FlashcardReviewView: View {
8 @Bindable var review: FlashcardReview
9 /// Opens the shown card's heading in the editor.
10 let open: (String, Int) -> Void
11
12 public init(review: FlashcardReview, open: @escaping (String, Int) -> Void) {
13 self.review = review
14 self.open = open
15 }
16
17 public var body: some View {
18 VStack(spacing: 0) {
19 if review.isLoading && !review.loaded {
20 ProgressView().frame(maxWidth: .infinity, maxHeight: .infinity)
21 } else if let face = review.face, let item = review.current {
22 card(face, item)
23 Divider()
24 controls(face)
25 .padding(16)
26 } else {
27 ContentUnavailableView {
28 Label(review.reviewed > 0 ? "Review Done" : "No Cards Due", systemImage: "rectangle.on.rectangle.angled")
29 } description: {
30 Text(review.reviewed > 0
31 ? "\(review.reviewed) reviewed. Nothing else is due."
32 : "Flashcards are headings tagged fc, in org-fc's format. Make one with Make Normal Flashcard or another Make Flashcard command.")
33 } actions: {
34 Button("Check Again") { Task { await review.start() } }
35 }
36 }
37 }
38 .alert("Flashcards", isPresented: Binding(get: { review.message != nil }, set: { if !$0 { review.message = nil } })) {
39 Button("OK") { review.message = nil }
40 } message: {
41 Text(review.message ?? "")
42 }
43 .task { if !review.loaded { await review.start() } }
44 }
45
46 private func card(_ face: Flashcards.Face, _ item: Flashcards.Item) -> some View {
47 let side = review.flipped ? face.back : face.front
48 return ScrollView {
49 VStack(alignment: .leading, spacing: 12) {
50 HStack {
51 Text("\(review.queue.count) left").font(.caption).foregroundStyle(.secondary).monospacedDigit()
52 Spacer()
53 Menu {
54 Button("Open in Editor", systemImage: "square.and.pencil") { open(item.path, item.card.headingOffset) }
55 Button("Suspend Card", systemImage: "pause.circle") { review.suspend() }
56 } label: {
57 Label("Card Actions", systemImage: "ellipsis.circle").labelStyle(.iconOnly)
58 }
59 .fixedSize()
60 }
61 Text(Self.styled(side, title: true)).font(.title2.weight(.semibold))
62 if !side.text.isEmpty {
63 Text(Self.styled(side, title: false)).font(.body)
64 }
65 if let expected = face.expected, review.flipped {
66 answerCheck(expected)
67 }
68 }
69 .textSelection(.enabled)
70 .frame(maxWidth: 700, alignment: .leading)
71 .frame(maxWidth: .infinity)
72 .padding(20)
73 }
74 }
75
76 private func answerCheck(_ expected: String) -> some View {
77 VStack(alignment: .leading, spacing: 4) {
78 Label(review.typedIsRight ? "Correct" : "Not quite", systemImage: review.typedIsRight ? "checkmark.circle.fill" : "xmark.circle.fill")
79 .foregroundStyle(review.typedIsRight ? Color.green : Color.red)
80 Text("Your answer: \(review.typed)")
81 if !review.typedIsRight { Text("Expected: \(expected)") }
82 }
83 .padding(12)
84 .background(.quaternary, in: RoundedRectangle(cornerRadius: 8))
85 }
86
87 @ViewBuilder
88 private func controls(_ face: Flashcards.Face) -> some View {
89 if review.flipped {
90 HStack(spacing: 10) {
91 rating(.again, "Again", .red, key: "a")
92 rating(.hard, "Hard", .orange, key: "h")
93 rating(.good, "Good", .green, key: "g")
94 rating(.easy, "Easy", .blue, key: "e")
95 }
96 } else if face.expected != nil {
97 HStack(spacing: 10) {
98 TextField("Your Answer", text: $review.typed)
99 .textFieldStyle(.roundedBorder)
100 .autocorrectionDisabled()
101 #if os(iOS)
102 .textInputAutocapitalization(.never)
103 #endif
104 .onSubmit { review.flip() }
105 big(Button("Check") { review.flip() }, tint: .accentColor)
106 .frame(maxWidth: 160)
107 }
108 } else {
109 big(Button("Show Answer") { review.flip() }, tint: .accentColor)
110 .keyboardShortcut(.defaultAction)
111 }
112 }
113
114 private func rating(_ rating: Flashcards.Rating, _ title: LocalizedStringKey, _ tint: Color, key: KeyEquivalent) -> some View {
115 big(Button(title) { review.rate(rating) }, tint: tint)
116 .keyboardShortcut(key, modifiers: [])
117 }
118
119 private func big(_ button: Button<Text>, tint: Color) -> some View {
120 button
121 .font(.headline)
122 .buttonStyle(BigButtonStyle(tint: tint))
123 }
124
125 #if os(iOS)
126 static let buttonHeight: CGFloat = 64
127 #else
128 static let buttonHeight: CGFloat = 40
129 #endif
130
131 private struct BigButtonStyle: ButtonStyle {
132 let tint: Color
133 func makeBody(configuration: Configuration) -> some View {
134 configuration.label
135 .foregroundStyle(.white)
136 .frame(maxWidth: .infinity, minHeight: FlashcardReviewView.buttonHeight)
137 .background(tint.opacity(configuration.isPressed ? 0.7 : 1), in: RoundedRectangle(cornerRadius: 12))
138 .contentShape(RoundedRectangle(cornerRadius: 12))
139 }
140 }
141
142 /// The side's title (a placeholder while hidden) or text, with its marks in bold.
143 static func styled(_ side: Flashcards.Face.Side, title: Bool) -> AttributedString {
144 let titleText = side.title ?? "[…]"
145 let whole = (side.title ?? "") + "\n" + side.text
146 let part = title ? titleText : side.text
147 var string = AttributedString(part)
148 if title && side.title == nil { string.foregroundColor = .secondary }
149 let offset = title ? 0 : ((side.title ?? "") as NSString).length + 1
150 let ns = whole as NSString
151 for mark in side.marks {
152 let lower = mark.lowerBound - offset
153 guard lower >= 0, mark.upperBound - offset <= (part as NSString).length, mark.upperBound <= ns.length,
154 let range = Range(NSRange(location: lower, length: mark.count), in: part),
155 let attributed = Range(range, in: string) else { continue }
156 string[attributed].inlinePresentationIntent = .stronglyEmphasized
157 string[attributed].foregroundColor = .accentColor
158 }
159 return string
160 }
161}
Sources/OrgApp/OrgPreferences.swift +6 · view
@@ -232,6 +232,12 @@ public enum OrgPreferences {
232232 public static func citeGlobalBibliography(_ defaults: UserDefaults = .standard) -> [String] {
233233 string("citeGlobalBibliography", defaults).split(separator: ":").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
234234 }
235 /// `org-fc-review-history-file`: relative to the configuration folder unless absolute;
236 /// empty for `org-fc-reviews.tsv` there.
237 public static func fcReviewHistoryFile(_ defaults: UserDefaults = .standard) -> URL {
238 let path = OrgPaths.expandingTilde(string("fcReviewHistoryFile", defaults).nonEmpty ?? "org-fc-reviews.tsv")
239 return path.hasPrefix("/") ? URL(fileURLWithPath: path) : UserConfig.directory.appendingPathComponent(path)
240 }
235241 /// `org-yank-image-save-method`: "attach", or the folder pasted images go in.
236242 public static func yankImageSaveMethod(_ defaults: UserDefaults = .standard) -> String {
237243 string("yankImageSaveMethod", defaults).nonEmpty ?? "attach"
Sources/OrgApp/UserConfig.swift +3 −1 · view
@@ -220,7 +220,9 @@ public enum UserConfig {
220220 comment: "whether DIR and ID inherit for attachments: selective (as org-use-property-inheritance), t or nil", legacy: ""),
221221 Setting(section: "", key: "org-cite-global-bibliography", defaultsKey: "citeGlobalBibliography", kind: .string, fallback: .string(""),
222222 comment: "bibliography files (.bib or CSL-JSON .json) every file's citations use, separated by :", legacy: ""),
223 Setting(section: "", key: "org-yank-image-save-method", defaultsKey: "yankImageSaveMethod", kind: .string, fallback: .string("attach"),
223 Setting(section: "", key: "org-fc-review-history-file", defaultsKey: "fcReviewHistoryFile", kind: .string, fallback: .string(""),
224 comment: "the file flashcard reviews are logged to, as org-fc logs them; empty for org-fc-reviews.tsv in this folder", legacy: ""),
225 Setting(section: "", key: "org-yank-image-save-method",defaultsKey: "yankImageSaveMethod", kind: .string, fallback: .string("attach"),
224226 comment: "where pasted images go: attach (the entry's attachments) or a folder, relative to the org file's folder unless absolute", legacy: ""),
225227 Setting(section: "", key: "org-yank-dnd-method", defaultsKey: "yankDndMethod",
226228 kind: .choice([("ask", "ask"), ("attach", "attach"), ("open", "open"), ("file-link", "file-link")]), fallback: .string("ask"),
Sources/OrgApp/WatchPayload.swift +14 · view
@@ -1,7 +1,21 @@
11import Foundation
2import OrgCore
23import OrgPresentation
34import OrgWatchData
45
6extension WatchAgenda.Card {
7 /// The first `limit` of `items` that are positions of normal and double cards, which the
8 /// watch reviews, with their text cut to `length` characters.
9 public static func review(_ items: [Flashcards.Item], limit: Int = 30, length: Int = 400) -> [WatchAgenda.Card] {
10 func cut(_ text: String) -> String { text.count > length ? String(text.prefix(length)) + "…" : text }
11 return items.lazy.filter { [.normal, .double].contains($0.card.cardType) }.compactMap { item -> WatchAgenda.Card? in
12 guard let face = Flashcards.face(item.card, position: item.position) else { return nil }
13 return WatchAgenda.Card(path: item.path, card: item.card.id, position: item.position, title: face.front.title.map(cut), front: cut(face.front.text),
14 backTitle: cut(face.back.title ?? ""), back: cut(face.back.text))
15 }.prefix(limit).map { $0 }
16 }
17}
18
519extension WatchAgenda {
620 /// Today's group of the agenda, for the watch, with the running clock and the entry
721 /// Clock In Last would take.
Sources/OrgApp/WidgetData.swift +24 · view
@@ -69,6 +69,30 @@ public struct HabitSnapshot: WidgetData {
6969 }
7070}
7171
72/// When the flashcard positions a review would show fall due, for the Flashcards widget to
73/// count at each of its times.
74public struct FlashcardSnapshot: WidgetData {
75 public static let name = "flashcards.json"
76
77 public var due: [Date]
78
79 public init(due: [Date]) {
80 self.due = due.sorted()
81 }
82
83 public init(cards: [Flashcards.Card]) {
84 self.init(due: cards.flatMap(Flashcards.dueDates))
85 }
86
87 /// Positions due before `date`.
88 public func count(at date: Date) -> Int { due.prefix { $0 < date }.count }
89
90 /// The times after `date` the count goes up, at most `limit` of them.
91 public func changes(after date: Date, limit: Int = 24) -> [Date] {
92 Array(Set(due.filter { $0 >= date }.map { $0.addingTimeInterval(1) })).sorted().prefix(limit).map { $0 }
93 }
94}
95
7296/// The running clock and the entry Clock In Last would clock into, for the clock control.
7397public struct ClockSnapshot: WidgetData {
7498 public static let name = "clock.json"
Sources/OrgCore/Commands/Command.swift +2 · view
@@ -359,6 +359,8 @@ public enum Commands {
359359 InsertDrawer(), DragElement(forward: true), DragElement(forward: false), CycleBullet(previous: false), CycleBullet(previous: true),
360360 Emphasize(), Emphasize(marker: "*"), Emphasize(marker: "/"), Emphasize(marker: "_"), Emphasize(marker: "="), Emphasize(marker: "~"), Emphasize(marker: "+"),
361361 ExpandSnippet(), InsertSnippet(),
362 MakeFlashcard(.normal), MakeFlashcard(.double), MakeFlashcard(.cloze), MakeFlashcard(.textInput), UpdateFlashcard(),
363 SuspendFlashcard(), SuspendFlashcard(suspend: false),
362364 ]
363365
364366 public static var everything: [any OrgCommand] { all + TableCommand.Action.allCases.map(TableCommand.init) }
Sources/OrgCore/Flashcards/FlashcardCommands.swift added +296 · view
@@ -0,0 +1,296 @@
1import Foundation
2
3// org-fc's commands on a heading (org-fc 0.7, with `org-fc-algorithm` sm2-v1): making a card of
4// each type, updating a cloze card's holes, suspending, and rating a position, writing what
5// org-fc writes.
6
7/// `org-fc-type-normal-init`, `org-fc-type-double-init`, `org-fc-type-text-input-init` and
8/// `org-fc-type-cloze-init`: the heading at point becomes a card.
9public struct MakeFlashcard: OrgCommand {
10 public let type: Flashcards.CardType
11 let newID: @Sendable () -> String
12
13 public init(_ type: Flashcards.CardType, newID: @escaping @Sendable () -> String = { UUID().uuidString }) {
14 self.type = type
15 self.newID = newID
16 }
17
18 public var id: String { "org.fc.\(type.rawValue)" }
19 public var title: String {
20 switch type {
21 case .normal: "Make Normal Flashcard"
22 case .double: "Make Double Flashcard"
23 case .cloze: "Make Cloze Flashcard…"
24 case .textInput: "Make Text-Input Flashcard"
25 }
26 }
27
28 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
29
30 public func run(in context: EditContext) -> CommandStep {
31 guard entryHeading(at: context.caret, in: context.tree) != nil else { return .failed("Before first headline") }
32 var cloze: Flashcards.ClozeType?
33 if type == .cloze {
34 guard let answer = context.answers["cloze-type"] else {
35 return .prompt(Prompt(key: "cloze-type", message: "Cloze Type: ", choices: Flashcards.ClozeType.allCases.map(\.rawValue)))
36 }
37 guard let chosen = Flashcards.ClozeType(rawValue: answer) else { return .failed("Invalid cloze card type: \(answer)") }
38 cloze = chosen
39 }
40 return commitBuffer(context) { buffer in
41 try buffer.saveExcursion {
42 try buffer.backToHeading()
43 switch type {
44 case .normal:
45 try buffer.fcInitCard("normal", newID: newID)
46 try buffer.fcReviewDataUpdate(["front"])
47 case .double:
48 try buffer.fcInitCard("double", newID: newID)
49 try buffer.fcReviewDataUpdate(["front", "back"])
50 case .textInput:
51 guard buffer.fcHasAnswerLine() else { throw EmacsBuffer.UserError(message: "The card has no answer line") }
52 try buffer.fcInitCard("text-input", newID: newID)
53 try buffer.fcReviewDataUpdate(["front"])
54 case .cloze:
55 try buffer.fcInitCard("cloze", newID: newID)
56 try buffer.fcClozeUpdate()
57 buffer.entryPut("FC_CLOZE_TYPE", cloze!.rawValue)
58 }
59 }
60 }
61 }
62}
63
64/// `org-fc-update`: a cloze card's new holes get positions and review data; other types
65/// have nothing to update.
66public struct UpdateFlashcard: OrgCommand {
67 public init() {}
68 public var id: String { "org.fc.update" }
69 public var title: String { "Update Flashcard" }
70 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
71 public func run(in context: EditContext) -> CommandStep {
72 commitBuffer(context) { buffer in
73 try buffer.saveExcursion {
74 try buffer.fcGotoEntryHeading()
75 if buffer.entryProperty("FC_TYPE") == "cloze" { try buffer.fcClozeUpdate() }
76 }
77 }
78 }
79}
80
81/// `org-fc-suspend-card` and `org-fc-unsuspend-card`.
82public struct SuspendFlashcard: OrgCommand {
83 public let suspend: Bool
84 public init(suspend: Bool = true) { self.suspend = suspend }
85 public var id: String { suspend ? "org.fc.suspend" : "org.fc.unsuspend" }
86 public var title: String { suspend ? "Suspend Flashcard" : "Unsuspend Flashcard" }
87 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
88 public func run(in context: EditContext) -> CommandStep {
89 commitBuffer(context) { buffer in
90 try buffer.saveExcursion {
91 try buffer.fcGotoEntryHeading()
92 let tags = try SetTags.tags(in: buffer)
93 if suspend {
94 try buffer.fcAddTag(Flashcards.suspendedTag)
95 } else {
96 try SetTags.set(tags.filter { $0 != Flashcards.suspendedTag }, in: buffer)
97 }
98 }
99 }
100 }
101}
102
103/// `org-fc-review-rate`: the review data of the card with ID `card` at `position` updated
104/// for `rating` by SM2. `random` stands for the interval fuzz's `cl-random`, as a fraction
105/// of its limit. The caret may be anywhere: the card is found by its ID, so a review can rate
106/// cards whose offsets moved.
107public struct RateFlashcard: OrgCommand {
108 public let card: String
109 public let position: String
110 public let rating: Flashcards.Rating
111 public let random: Double
112
113 public init(card: String, position: String, rating: Flashcards.Rating, random: Double = Double.random(in: 0..<1)) {
114 self.card = card
115 self.position = position
116 self.rating = rating
117 self.random = random
118 }
119
120 public var id: String { "internal.fc.rate" }
121 public var title: String { "Rate Flashcard" }
122 public func applies(in context: EditContext) -> Bool { true }
123 public func run(in context: EditContext) -> CommandStep {
124 commitBuffer(context) { buffer in
125 try buffer.saveExcursion {
126 buffer.point = 0
127 let id = NSRegularExpression.escapedPattern(for: card)
128 while let match = buffer.searchForward("^[ \\t]*:ID:[ \\t]+" + id + "[ \\t]*$", caseInsensitive: true) {
129 try buffer.backToHeading()
130 if try SetTags.tags(in: buffer).contains(Flashcards.tag), buffer.entryID() == card {
131 try buffer.fcRate(position, rating: rating, random: random)
132 return
133 }
134 buffer.point = match[0]!.upperBound
135 }
136 throw EmacsBuffer.UserError(message: "The card is no longer in the file")
137 }
138 }
139 }
140}
141
142extension EmacsBuffer {
143 /// `org-fc--init-card`, from point at the heading.
144 func fcInitCard(_ type: String, newID: () -> String) throws {
145 if try SetTags.tags(in: self).contains(Flashcards.tag) { throw UserError(message: "Headline is already a flashcard") }
146 try backToHeading()
147 entryPut("FC_CREATED", Flashcards.timestamp(now))
148 entryPut("FC_TYPE", type)
149 entryPut("FC_ALGO", Flashcards.algorithm)
150 if entryID() == nil { entryPut("ID", newID()) }
151 try fcAddTag(Flashcards.tag)
152 }
153
154 /// `org-fc--add-tag`: the tag goes first unless the heading has it.
155 func fcAddTag(_ tag: String) throws {
156 let tags = try SetTags.tags(in: self)
157 if !tags.contains(tag) { try SetTags.set([tag] + tags, in: self) }
158 }
159
160 /// `org-fc-goto-entry-heading`.
161 func fcGotoEntryHeading() throws {
162 try backToHeading()
163 while try !SetTags.tags(in: self).contains(Flashcards.tag) {
164 guard upHeadingSafe() != nil else { throw UserError(message: "Not inside a flashcard entry") }
165 }
166 }
167
168 /// Whether `org-fc-text-input-content` finds a line, from point at the heading.
169 func fcHasAnswerLine() -> Bool {
170 saveExcursion {
171 func entry() -> (String, Bool) {
172 let end = saveExcursion { () -> Int in outlineNextHeading(); return point }
173 return (substring(lineStart(point), end), end < length)
174 }
175 let back = saveExcursion { () -> (String, Bool)? in
176 let level = outlineLevel
177 let end = endOfSubtree()
178 var found: (String, Bool)?
179 while outlineNextHeading(), point < end {
180 guard outlineLevel == level + 1, let match = lookingAt(complexHeadingPattern), let title = match[4],
181 Flashcards.backTitles.contains(substring(title.lowerBound, title.upperBound)) else { continue }
182 found = entry()
183 }
184 return found
185 }
186 let (text, followed) = back ?? entry()
187 return Flashcards.firstContentLine(text, followedByHeading: followed) != nil
188 }
189 }
190
191 private static let reviewDataPattern = "^[ \\t]*:" + Flashcards.drawer + ":[ \\t]*$"
192
193 /// `org-fc-review-data-position`: the start of the drawer's first line and of its `:END:`
194 /// line, from point at the heading; with `create`, a new drawer's.
195 func fcReviewDataPosition(create: Bool) -> (Int, Int)? {
196 endOfMetaData()
197 let end = atHeading ? point : saveExcursion { outlineNextHeading(); return point }
198 while let match = searchForward(Self.reviewDataPattern, bound: end, caseInsensitive: true) {
199 let begin = lineEnd(match[0]!.upperBound) + 1
200 let close = saveExcursion { () -> Int? in
201 point = match[0]!.upperBound
202 return searchForward("^[ \\t]*:END:[ \\t]*$", bound: end, caseInsensitive: true).map { lineStart($0[0]!.lowerBound) }
203 }
204 if let close, begin <= close { return (begin, close) }
205 }
206 guard create else { return nil }
207 if !bolp { insert("\n") }
208 insert(":" + Flashcards.drawer + ":\n:END:\n")
209 let at = lineStart(point - 1)
210 return (at, at)
211 }
212
213 /// `org-fc-review-data-parse`: the table's headers and rows by position name.
214 func fcReviewDataParse() throws -> (headers: [String], rows: [(name: String, values: [String: String])]) {
215 let algorithm = entryProperty("FC_ALGO") ?? Flashcards.algorithm
216 guard algorithm == Flashcards.algorithm else { throw UserError(message: "orgstar schedules only SM2 cards, not \(algorithm)") }
217 guard let (begin, _) = saveExcursion({ fcReviewDataPosition(create: false) }) else { return (Flashcards.SM2.headers, []) }
218 return saveExcursion {
219 point = begin
220 let table = tableToLisp()
221 guard let first = table.first, let headers = first else { return (Flashcards.SM2.headers, []) }
222 let rows = table.dropFirst(2).compactMap { $0 }.map { cells -> (name: String, values: [String: String]) in
223 let values = Dictionary(zip(headers, cells), uniquingKeysWith: { a, _ in a })
224 return (values["position"] ?? "", values)
225 }
226 return (headers, rows)
227 }
228 }
229
230 /// `org-fc-review-data-write`.
231 func fcReviewDataWrite(headers: [String], rows: [[String: String]]) {
232 saveExcursion {
233 let lines = ["| " + headers.joined(separator: " | ") + " |\n", "|" + headers.map { _ in "-" }.joined(separator: "+") + "|\n"]
234 + rows.map { row in "| " + headers.map { row[$0] ?? "nil" }.joined(separator: " | ") + " |\n" }
235 let (begin, end) = fcReviewDataPosition(create: true)!
236 deleteRegion(begin, end)
237 point = begin
238 insert(lines.joined())
239 tableAlign()
240 }
241 }
242
243 /// `org-fc-review-data-update`: rows for exactly `names`, new ones with SM2's initial data.
244 func fcReviewDataUpdate(_ names: [String]) throws {
245 let (headers, rows) = try fcReviewDataParse()
246 let sm2 = Flashcards.SM2()
247 let kept = names.map { name in rows.first { $0.name == name }?.values ?? sm2.initial(name, now: now) }
248 fcReviewDataWrite(headers: headers, rows: kept)
249 }
250
251 /// `org-fc-type-cloze-update`, from point at the heading.
252 func fcClozeUpdate() throws {
253 var end = saveExcursion { () -> Int in outlineNextHeading(); return point - 1 }
254 var hole = Int(Flashcards.number(entryProperty(Flashcards.clozeMaxProperty) ?? "-1")) + 1
255 var ids: [String] = []
256 saveExcursion {
257 while let match = searchForward(Flashcards.holePattern, bound: end, caseInsensitive: false) {
258 if let id = match[3] {
259 ids.append(substring(id.lowerBound, id.upperBound))
260 } else {
261 let id = String(hole)
262 hole += 1
263 end += 1 + (id as NSString).length
264 point = match[0]!.upperBound - 1
265 insert("@" + id)
266 ids.append(id)
267 }
268 }
269 }
270 entryPut(Flashcards.clozeMaxProperty, String(hole - 1))
271 try fcReviewDataUpdate(ids)
272 }
273
274 /// `org-fc-algo-update-review-data`, from point at the heading. Returns the row before.
275 @discardableResult
276 func fcRate(_ position: String, rating: Flashcards.Rating, random: Double) throws -> [String: String] {
277 let (headers, rows) = try fcReviewDataParse()
278 guard let current = rows.first(where: { $0.name == position })?.values else {
279 throw UserError(message: "No review data row found for this position")
280 }
281 let next = Flashcards.SM2().next(current, rating: rating, now: now, random: random)
282 let updated = rows.map { row -> [String: String] in
283 guard row.name == position else { return row.values }
284 var values = row.values
285 for header in headers { values[header] = next[header] ?? row.values[header] }
286 return values
287 }
288 fcReviewDataWrite(headers: headers, rows: updated)
289 return current
290 }
291}
292
293extension Flashcards {
294 /// `org-fc-type-cloze-max-hole-property`.
295 static let clozeMaxProperty = "FC_CLOZE_MAX"
296}
Sources/OrgCore/Flashcards/FlashcardFaces.swift added +107 · view
@@ -0,0 +1,107 @@
1import Foundation
2
3extension Flashcards {
4 /// What a card shows for one position, before and after it is flipped, as org-fc's card
5 /// types set up and flip a heading during a review.
6 public struct Face: Sendable, Equatable {
7 public struct Side: Sendable, Equatable {
8 /// The heading's title; nil while it is hidden.
9 public var title: String?
10 public var text: String
11 /// Ranges of `title + "\n" + text`, in UTF-16 offsets, to emphasize: a cloze hole.
12 public var marks: [Range<Int>]
13
14 public init(title: String?, text: String, marks: [Range<Int>] = []) {
15 self.title = title
16 self.text = text
17 self.marks = marks
18 }
19 }
20
21 public var front: Side
22 public var back: Side
23 /// For text-input cards: the answer to type, without emphasis markers.
24 public var expected: String?
25 }
26
27 /// `org-fc-type-cloze-hole-re`: 1 text, 2 hint, 3 the hole's position.
28 static let holePattern = "\\{\\{((?:\\$[^$]+\\$|[^}])*)\\}(?:\\{((?:\\$[^$]\\$|[^}])*)\\})?(?:@([0-9]+))?\\}"
29 static let holeRegex = try! NSRegularExpression(pattern: holePattern)
30
31 /// The card's face for `position`; nil for a type orgstar doesn't know or a position the
32 /// card doesn't have.
33 public static func face(_ card: Card, position: String) -> Face? {
34 func join(_ parts: [String]) -> String { parts.filter { !$0.isEmpty }.joined(separator: "\n\n") }
35 let answer = join([card.body, card.children])
36 switch card.cardType {
37 case .normal, .textInput:
38 let front = Face.Side(title: card.title, text: card.back == nil ? "" : card.body)
39 let expected = card.cardType == .textInput ? card.answerLine.map(deemphasize) : nil
40 return Face(front: front, back: Face.Side(title: card.title, text: answer), expected: expected)
41 case .double:
42 switch position {
43 case "front": return Face(front: Face.Side(title: card.title, text: card.back == nil ? "" : card.body), back: Face.Side(title: card.title, text: answer))
44 case "back":
45 let front = card.back.map { Face.Side(title: card.title, text: $0) } ?? Face.Side(title: nil, text: card.body)
46 return Face(front: front, back: Face.Side(title: card.title, text: answer))
47 default: return nil
48 }
49 case .cloze:
50 guard let id = Int(position), let type = card.clozeType else { return nil }
51 return cloze(card, hole: id, type: type)
52 case nil:
53 return nil
54 }
55 }
56
57 /// `org-fc-type-cloze-hide-holes` and the flip that follows it.
58 static func cloze(_ card: Card, hole: Int, type: ClozeType) -> Face? {
59 let source = card.title + "\n" + card.body as NSString
60 let matches = holeRegex.matches(in: source as String, range: NSRange(location: 0, length: source.length)).filter { $0.range(at: 3).location != NSNotFound }
61 guard let current = matches.firstIndex(where: { Int(source.substring(with: $0.range(at: 3))) == hole }) else { return nil }
62 func visible(_ i: Int) -> Bool {
63 switch type {
64 case .enumeration: i < current
65 case .deletion: true
66 case .single: false
67 case .context: abs(i - current) <= clozeContext
68 }
69 }
70 func render(flipped: Bool) -> (String, [Range<Int>]) {
71 var out = ""
72 var marks: [Range<Int>] = []
73 var at = 0
74 for (i, match) in matches.enumerated() {
75 out += source.substring(with: NSRange(location: at, length: match.range.location - at))
76 let text = source.substring(with: match.range(at: 1))
77 let shown: String
78 if i == current {
79 let hint = match.range(at: 2).location == NSNotFound ? "" : source.substring(with: match.range(at: 2))
80 shown = flipped ? text : "[..." + hint + "]"
81 let start = (out as NSString).length
82 marks.append(start..<(start + (shown as NSString).length))
83 } else {
84 shown = visible(i) ? text : "..."
85 }
86 out += shown
87 at = NSMaxRange(match.range)
88 }
89 out += source.substring(from: at)
90 return (out, marks)
91 }
92 func side(flipped: Bool) -> Face.Side {
93 let (text, marks) = render(flipped: flipped)
94 let split = text.firstIndex(of: "\n")!
95 var body = String(text[text.index(after: split)...])
96 if flipped, !card.children.isEmpty { body += (body.isEmpty ? "" : "\n\n") + card.children }
97 return Face.Side(title: String(text[..<split]), text: body, marks: marks)
98 }
99 return Face(front: side(flipped: false), back: side(flipped: true))
100 }
101
102 /// `org-fc-deemphasize`: the text of the line's first emphasis, else the line.
103 static func deemphasize(_ line: String) -> String {
104 guard let match = line.firstMatch(of: /(?:^|[\s\-('"{])([*\/_=~+])(\S|\S.*?\S)\1(?:[\s\-.,:!?;'")}\[\\]|$)/) else { return line }
105 return String(match.2)
106 }
107}
Sources/OrgCore/Flashcards/FlashcardSM2.swift added +44 · view
@@ -0,0 +1,44 @@
1import Foundation
2
3extension Flashcards {
4 /// org-fc's variant of SM2 (`org-fc-algo-sm2`, `org-fc-algorithm` `sm2-v1`) with its
5 /// default parameters.
6 public struct SM2: Sendable, Equatable {
7 public var easeMin = 1.3
8 public var easeMax = 5.0
9 public var easeInitial = 2.5
10 public var fuzzMin = 0.9
11 public var fuzzMax = 1.1
12 public var changes: [Rating: Double] = [.again: -0.3, .hard: -0.15, .good: 0.0, .easy: 0.15]
13 /// Intervals in days of the first boxes.
14 public var intervals = [0.0, 0.01, 1.0, 6.0]
15
16 public static let headers = ["position", "ease", "box", "interval", "due"]
17
18 public init() {}
19
20 /// `org-fc-algo-initial-review-data`.
21 public func initial(_ name: String, now: Date) -> [String: String] {
22 ["position": name, "ease": String(format: "%.2f", easeInitial), "box": "0", "interval": String(format: "%.2f", 0.0),
23 "due": Flashcards.timestamp(now)]
24 }
25
26 /// `org-fc-algo-next-review-data`. `random` stands for `cl-random`'s value as a
27 /// fraction of its limit, in [0, 1).
28 public func next(_ current: [String: String], rating: Rating, now: Date, random: Double) -> [String: String] {
29 let ease = Flashcards.number(current["ease"])
30 let box = Int(Flashcards.number(current["box"]))
31 let interval = Flashcards.number(current["interval"])
32 let nextEase = box < 2 ? ease : min(max(ease + changes[rating]!, easeMin), easeMax)
33 let nextBox = box == 0 && rating == .easy ? 2 : rating == .again ? 0 : box + 1
34 let nextInterval: Double
35 if nextBox < intervals.count {
36 nextInterval = intervals[nextBox]
37 } else {
38 nextInterval = nextEase * interval * (fuzzMin + (fuzzMax - fuzzMin) * random)
39 }
40 return ["ease": String(format: "%.2f", nextEase), "box": String(nextBox), "interval": String(format: "%.2f", nextInterval),
41 "due": Flashcards.timestamp(now, plus: nextInterval)]
42 }
43 }
44}
Sources/OrgCore/Flashcards/Flashcards.swift added +291 · view
@@ -0,0 +1,291 @@
1import Foundation
2
3/// Flashcards in org-fc's format (github.com/l3kn/org-fc), so cards and their review data
4/// carry over to Emacs: a heading tagged `fc` with `FC_CREATED`, `FC_TYPE`, `FC_ALGO` and an
5/// `ID`, and a `REVIEW_DATA` drawer holding a table with a row per position (position, ease,
6/// box, interval, due). `suspended` leaves a card out of reviews.
7public enum Flashcards {
8 public static let tag = "fc"
9 public static let suspendedTag = "suspended"
10 public static let drawer = "REVIEW_DATA"
11 /// `FC_ALGO` of new cards: org-fc's SM2, the only algorithm `org-fc` loads by default.
12 public static let algorithm = "sm2"
13 /// `org-fc-algorithm`, written to the review history.
14 public static let historyAlgorithm = "sm2-v1"
15 /// `org-fc-back-heading-titles`.
16 public static let backTitles = ["Back"]
17 /// `org-fc-type-cloze-context`.
18 public static let clozeContext = 1
19
20 public enum CardType: String, CaseIterable, Sendable {
21 case normal, double, cloze
22 case textInput = "text-input"
23 }
24
25 /// `org-fc-type-cloze-types`.
26 public enum ClozeType: String, CaseIterable, Sendable {
27 case deletion, enumeration, context, single
28 }
29
30 public enum Rating: String, CaseIterable, Sendable {
31 case again, hard, good, easy
32 }
33
34 /// One row of the review data table.
35 public struct Position: Sendable, Equatable {
36 public var name: String
37 /// The row's cells by column name, as written.
38 public var values: [String: String]
39
40 public init(name: String, values: [String: String]) {
41 self.name = name
42 self.values = values
43 }
44
45 public var due: Date? { values["due"].flatMap(Flashcards.date) }
46 public var ease: Double { Flashcards.number(values["ease"]) }
47 public var box: Int { Int(Flashcards.number(values["box"])) }
48 public var interval: Double { Flashcards.number(values["interval"]) }
49 }
50
51 /// A heading tagged `fc` with a `REVIEW_DATA` drawer after its property drawer, as org-fc's
52 /// indexer finds them.
53 public struct Card: Sendable, Equatable {
54 public var id: String
55 public var title: String
56 /// `FC_TYPE` as written.
57 public var type: String
58 public var clozeType: ClozeType?
59 /// `FC_ALGO`; nil for cards from before org-fc 0.6, which are SM2's.
60 public var algorithm: String?
61 public var created: Date?
62 public var suspended: Bool
63 /// Inherited tags first, then the heading's own.
64 public var tags: [String]
65 public var positions: [Position]
66 /// Where the heading starts, and its line.
67 public var headingOffset: Int
68 public var headingLine: String
69 /// The entry's text before its first subheading, without planning lines and drawers.
70 public var body: String
71 /// The subheadings, without planning lines and drawers.
72 public var children: String
73 /// The text of the `Back` subheading, if there is one.
74 public var back: String?
75 /// The first line of the answer, as text-input cards compare it: the line after the
76 /// `Back` heading's metadata, or the entry's.
77 public var answerLine: String?
78
79 public var cardType: CardType? { CardType(rawValue: type) }
80
81 /// Positions due before `now`, unless the card is suspended.
82 public func due(at now: Date) -> [Position] {
83 suspended ? [] : positions.filter { ($0.due ?? .distantFuture) < now }
84 }
85 }
86
87 // MARK: - Reading
88
89 /// The cards in `text`.
90 public static func cards(in text: String, defaults: OrgSettings = .default) -> [Card] {
91 guard text.contains(":" + tag + ":") else { return [] }
92 let tree = OrgParser.parse(text, defaults: defaults)
93 let model = DocumentModel(tree: tree)
94 let ns = text as NSString
95 var cards: [Card] = []
96 for (index, heading) in model.headings.enumerated() where heading.localTags.contains(tag) {
97 let lineEnd = ns.lineRange(for: NSRange(location: heading.headingRange.lowerBound, length: 0))
98 let bodyStart = NSMaxRange(lineEnd)
99 let childIndexes = model.headings.indices.filter { model.headings[$0].parent == index }
100 let bodyEnd = childIndexes.first.map { model.headings[$0].sectionRange.lowerBound } ?? heading.sectionRange.upperBound
101 let entry = ns.substring(with: NSRange(location: bodyStart, length: max(0, bodyEnd - bodyStart)))
102 guard let positions = reviewData(entry) else { continue }
103 func property(_ key: String) -> String? { heading.properties.last { $0.key.uppercased() == key && !$0.additive }?.value }
104 let backIndex = childIndexes.last { model.headings[$0].level == heading.level + 1 && backTitles.contains(model.headings[$0].title) }
105 let backRange = backIndex.map { model.headings[$0].sectionRange }
106 let back = backRange.map { ns.substring(with: NSRange(location: $0.lowerBound, length: $0.upperBound - $0.lowerBound)) }
107 let children = ns.substring(with: NSRange(location: bodyEnd, length: heading.sectionRange.upperBound - bodyEnd))
108 let headingLine = ns.substring(with: NSRange(location: lineEnd.location, length: lineEnd.length)).trimmingCharacters(in: .newlines)
109 cards.append(Card(
110 id: property("ID") ?? "", title: heading.title, type: property("FC_TYPE") ?? "",
111 clozeType: property("FC_CLOZE_TYPE").flatMap(ClozeType.init(rawValue:)), algorithm: property("FC_ALGO"),
112 created: property("FC_CREATED").flatMap(date), suspended: heading.localTags.contains(suspendedTag),
113 tags: model.tags(of: index).map(\.value), positions: positions,
114 headingOffset: heading.headingRange.lowerBound, headingLine: headingLine,
115 body: readable(entry), children: readable(children), back: back.map { readable(lines($0).dropFirst().joined(separator: "\n")) },
116 answerLine: back.map { firstContentLine($0, followedByHeading: backRange!.upperBound < ns.length) }
117 ?? firstContentLine(headingLine + "\n" + entry, followedByHeading: bodyEnd < ns.length)
118 ))
119 }
120 return cards
121 }
122
123 /// The rows of the `REVIEW_DATA` drawer in an entry's text, if it has one after its
124 /// property drawer.
125 static func reviewData(_ entry: String) -> [Position]? {
126 let all = lines(entry)
127 guard let properties = all.firstIndex(where: { isDrawerLine($0, "PROPERTIES") }),
128 let propertiesEnd = all[properties...].firstIndex(where: { isDrawerLine($0, "END") }),
129 let start = all[(propertiesEnd + 1)...].firstIndex(where: { isDrawerLine($0, drawer) }),
130 let end = all[(start + 1)...].firstIndex(where: { isDrawerLine($0, "END") }) else { return nil }
131 var headers: [String] = []
132 var positions: [Position] = []
133 var separated = false
134 for line in all[(start + 1)..<end] {
135 let trimmed = line.trimmingCharacters(in: .whitespaces)
136 guard trimmed.hasPrefix("|"), trimmed.hasSuffix("|") else { continue }
137 if trimmed.range(of: "^\\|[-+]+\\|$", options: .regularExpression) != nil {
138 separated = true
139 continue
140 }
141 let cells = trimmed.dropFirst().dropLast().split(separator: "|", omittingEmptySubsequences: false).map { $0.trimmingCharacters(in: .whitespaces) }
142 if !separated {
143 headers = cells
144 } else if cells.count == headers.count {
145 let values = Dictionary(zip(headers, cells), uniquingKeysWith: { a, _ in a })
146 positions.append(Position(name: values["position"] ?? "", values: values))
147 }
148 }
149 return positions
150 }
151
152 static func isDrawerLine(_ line: String, _ name: String) -> Bool {
153 line.trimmingCharacters(in: .whitespaces).caseInsensitiveCompare(":" + name + ":") == .orderedSame
154 }
155
156 static func lines(_ text: String) -> [String] {
157 text.split(separator: "\n", omittingEmptySubsequences: false).map(String.init)
158 }
159
160 /// `text` without planning lines and drawers, and without blank lines at either end.
161 public static func readable(_ text: String) -> String {
162 var kept: [String] = []
163 var inDrawer = false
164 for line in lines(text) {
165 let trimmed = line.trimmingCharacters(in: .whitespaces)
166 if inDrawer {
167 if trimmed.caseInsensitiveCompare(":END:") == .orderedSame { inDrawer = false }
168 continue
169 }
170 if trimmed.range(of: "^:[\\w-]+:$", options: .regularExpression) != nil {
171 inDrawer = true
172 continue
173 }
174 if trimmed.range(of: "^(SCHEDULED|DEADLINE|CLOSED):", options: .regularExpression) != nil { continue }
175 kept.append(line)
176 }
177 while kept.first?.trimmingCharacters(in: .whitespaces).isEmpty == true { kept.removeFirst() }
178 while kept.last?.trimmingCharacters(in: .whitespaces).isEmpty == true { kept.removeLast() }
179 return kept.joined(separator: "\n")
180 }
181
182 /// `org-fc-text-input-content`: the line after a heading's planning and drawers, unless
183 /// it is a heading. `text` starts with the heading line and runs to the next heading.
184 static func firstContentLine(_ text: String, followedByHeading: Bool) -> String? {
185 var lines = lines(text)
186 if text.hasSuffix("\n") { lines.removeLast() }
187 var i = 1
188 while i < lines.count, lines[i].range(of: "^(SCHEDULED|DEADLINE): *<[^>]+>", options: .regularExpression) != nil { i += 1 }
189 while i < lines.count, lines[i].range(of: "^[ \\t]*:[\\w-]+:[ \\t]*$", options: .regularExpression) != nil {
190 guard let end = lines[(i + 1)...].firstIndex(where: { $0.contains(":END:") }) else { return nil }
191 i = end + 1
192 }
193 guard i < lines.count else { return followedByHeading ? nil : "" }
194 return lines[i].range(of: "^\\*+ ", options: .regularExpression) != nil ? nil : lines[i]
195 }
196
197 // MARK: - Values
198
199 /// `string-to-number`.
200 static func number(_ string: String?) -> Double {
201 guard let string else { return 0 }
202 let trimmed = string.trimmingCharacters(in: .whitespaces)
203 if let value = Double(trimmed) { return value }
204 let prefix = trimmed.prefix { $0.isNumber || $0 == "." || $0 == "-" || $0 == "+" }
205 return Double(prefix) ?? 0
206 }
207
208 /// `org-fc-timestamp-in`: `%FT%TZ` in UTC, `days` after `now`.
209 public static func timestamp(_ now: Date, plus days: Double = 0) -> String {
210 let seconds = now.timeIntervalSince1970 + days * 60 * 60 * 24
211 var time = time_t(seconds.rounded(.down))
212 var parts = tm()
213 gmtime_r(&time, &parts)
214 return String(format: "%04d-%02d-%02dT%02d:%02d:%02dZ", Int(parts.tm_year) + 1900, Int(parts.tm_mon) + 1, Int(parts.tm_mday),
215 Int(parts.tm_hour), Int(parts.tm_min), Int(parts.tm_sec))
216 }
217
218 /// A `%FT%TZ` timestamp.
219 public static func date(_ string: String) -> Date? {
220 let parts = string.split(whereSeparator: { "-T:Z".contains($0) }).compactMap { Int($0) }
221 guard string.hasSuffix("Z"), parts.count == 6 else { return nil }
222 var t = tm()
223 t.tm_year = Int32(parts[0] - 1900)
224 t.tm_mon = Int32(parts[1] - 1)
225 t.tm_mday = Int32(parts[2])
226 t.tm_hour = Int32(parts[3])
227 t.tm_min = Int32(parts[4])
228 t.tm_sec = Int32(parts[5])
229 return Date(timeIntervalSince1970: TimeInterval(timegm(&t)))
230 }
231
232 // MARK: - Review history
233
234 /// A line of `org-fc-review-history-file`, as `org-fc-algo-log-review` appends it: the
235 /// position's values before the rating, and the seconds between showing and rating it.
236 public static func historyLine(at now: Date, path: String, id: String, position: Position, rating: Rating, seconds: Double) -> String {
237 [timestamp(now), path, id, position.name, position.values["ease"] ?? "", position.values["box"] ?? "", position.values["interval"] ?? "",
238 rating.rawValue, String(format: "%.2f", seconds), historyAlgorithm].joined(separator: "\t") + "\n"
239 }
240
241 // MARK: - Review sessions
242
243 /// A position to review.
244 public struct Item: Sendable, Equatable {
245 public var path: String
246 public var card: Card
247 public var position: String
248
249 public init(path: String, card: Card, position: String) {
250 self.path = path
251 self.card = card
252 self.position = position
253 }
254 }
255
256 /// The positions due at `now`, as `org-fc-review` queues them with its default filters:
257 /// suspended cards and positions not yet due left out, and one position for each card
258 /// other than single and enumeration cloze cards. Shuffled as `org-fc-shuffle-positions`
259 /// does: each card's positions keep their order.
260 public static func due<G: RandomNumberGenerator>(_ cards: [(path: String, card: Card)], at now: Date, shuffle: Bool = true, using generator: inout G) -> [Item] {
261 var keyed: [(Double, Item)] = []
262 for (path, card) in cards {
263 var due = card.due(at: now)
264 guard !due.isEmpty else { continue }
265 if !(card.cardType == .cloze && [.single, .enumeration].contains(card.clozeType)) { due = [due[0]] }
266 let keys = due.map { _ in Double.random(in: 0..<1, using: &generator) }.sorted(by: >)
267 keyed += zip(keys, due).map { ($0, Item(path: path, card: card, position: $1.name)) }
268 }
269 guard shuffle else { return keyed.map(\.1) }
270 return keyed.enumerated().sorted { $0.element.0 != $1.element.0 ? $0.element.0 > $1.element.0 : $0.offset < $1.offset }.map(\.element.1)
271 }
272
273 public static func due(_ cards: [(path: String, card: Card)], at now: Date, shuffle: Bool = true) -> [Item] {
274 var generator = SystemRandomNumberGenerator()
275 return due(cards, at: now, shuffle: shuffle, using: &generator)
276 }
277
278 /// When each position a review would show falls due: every position of single and
279 /// enumeration cloze cards, the earliest of the others' (a review shows one of them).
280 public static func dueDates(_ card: Card) -> [Date] {
281 guard !card.suspended else { return [] }
282 let dates = card.positions.compactMap(\.due)
283 if card.cardType == .cloze && [.single, .enumeration].contains(card.clozeType) { return dates }
284 return dates.min().map { [$0] } ?? []
285 }
286
287 /// How many positions a review started at `now` would show.
288 public static func dueCount(_ cards: [Card], at now: Date) -> Int {
289 cards.reduce(0) { $0 + dueDates($1).filter { $0 < now }.count }
290 }
291}
Sources/OrgEditorAppKit/EditorCommands.swift +1 · view
@@ -121,6 +121,7 @@ public enum EditorCommands {
121121 EditorCommand(id: "app.agenda", title: "Agenda", action: .app),
122122 EditorCommand(id: "app.capture", title: "Capture…", action: .app),
123123 EditorCommand(id: "app.board", title: "Board", action: .app),
124 EditorCommand(id: "app.flashcards.review", title: "Review Flashcards", action: .app),
124125 EditorCommand(id: "app.clock.in", title: "Clock In", action: .app),
125126 EditorCommand(id: "app.clock.in-recent", title: "Clock In to Recent Entry…", action: .app),
126127 EditorCommand(id: "app.clock.in-last", title: "Clock In to Last Entry", action: .app),
Sources/OrgIndex/IndexStore.swift +13 · view
@@ -403,6 +403,19 @@ public final class IndexStore: Sendable {
403403 }
404404 }
405405
406 /// Files with a heading tagged `tag` itself, not by inheritance: org-fc's flashcards for
407 /// `fc`. Unsaved buffers' in place of their files'.
408 public func files(withLocalTag tag: String, overlay: [String: FileRecord] = [:]) throws -> [String] {
409 let indexed = try database.read { db in
410 try String.fetchAll(db, sql: """
411 SELECT DISTINCT f.path FROM tags t JOIN headings h ON h.id = t.heading_id JOIN files f ON f.id = h.file_id
412 WHERE t.tag = ? AND t.inherited = 0 ORDER BY f.path
413 """, arguments: [tag])
414 }
415 let live = overlay.values.filter { $0.headings.contains { $0.tags.contains { $0.name == tag && !$0.inherited } } }.map(\.path)
416 return (indexed.filter { overlay[$0] == nil } + live).sorted()
417 }
418
406419 public func headings(withID id: String, overlay: [String: FileRecord] = [:]) throws -> [HeadingLocation] {
407420 let indexed = try database.read { db in
408421 try Row.fetchAll(
Sources/OrgWatchData/WatchAgenda.swift +41 · view
@@ -65,6 +65,37 @@ public struct WatchAgenda: Codable, Equatable, Sendable {
6565 }
6666 }
6767
68 /// A flashcard position due for review: a normal or double card's two sides as text.
69 public struct Card: Codable, Equatable, Sendable, Identifiable {
70 public var path: String
71 /// The card's ID.
72 public var card: String
73 public var position: String
74 /// The front's title; nil while it is hidden.
75 public var title: String?
76 public var front: String
77 public var backTitle: String
78 public var back: String
79
80 public var id: String { path + "\n" + card + "\n" + position }
81
82 public init(path: String, card: String, position: String, title: String?, front: String, backTitle: String, back: String) {
83 self.path = path
84 self.card = card
85 self.position = position
86 self.title = title
87 self.front = front
88 self.backTitle = backTitle
89 self.back = back
90 }
91
92 /// The action rating it `rating` (`again`, `hard`, `good` or `easy`).
93 public func rate(_ rating: String) -> WatchAction { .rate(path: path, card: card, position: position, rating: rating) }
94 }
95
96 /// Flashcard positions due, in review order; nil from a phone without them.
97 public var cards: [Card]?
98
6899 public var generated: Date
69100 /// Midnight starting today.
70101 public var day: Date
@@ -114,6 +145,14 @@ public struct WatchAgenda: Codable, Equatable, Sendable {
114145 return (rows + overdue).filter { !$0.isDone && !$0.isEvent && $0.todo != nil }.count
115146 }
116147
148 /// `card` rated here before the phone sends the agenda again: gone, or with Again, last.
149 public func rating(_ card: Card, again: Bool) -> WatchAgenda {
150 var copy = self
151 copy.cards?.removeAll { $0.id == card.id }
152 if again { copy.cards?.append(card) }
153 return copy
154 }
155
117156 /// `entry` marked done here before the phone sends the agenda again.
118157 public func markingDone(_ id: String) -> WatchAgenda {
119158 var copy = self
@@ -181,6 +220,8 @@ public enum WatchAction: Codable, Equatable, Sendable {
181220 case clockInLast
182221 /// Dictated text for the capture inbox.
183222 case capture(text: String)
223 /// Rates a flashcard position, found by its card's ID.
224 case rate(path: String, card: String, position: String, rating: String)
184225
185226 /// The user info key an action travels under.
186227 public static let key = "action"
Sources/Orgstar/ContentView.swift +6 · view
@@ -1370,6 +1370,10 @@ struct ContentView: View {
13701370 if (try? HabitSnapshot(habits: await days.habits(open: open), theme: theme).write()) == true {
13711371 WidgetCenter.shared.reloadTimelines(ofKind: "sh.krz.orgstar.habits")
13721372 }
1373 let cards = await FlashcardReview.cards(workspace: workspace, session: session)
1374 if (try? FlashcardSnapshot(cards: cards.map(\.card)).write()) == true {
1375 WidgetCenter.shared.reloadTimelines(ofKind: "sh.krz.orgstar.flashcards")
1376 }
13731377 if (try? snapshot.write(to: file)) == true { WidgetCenter.shared.reloadAllTimelines() }
13741378 }
13751379
@@ -1586,6 +1590,8 @@ struct ContentView: View {
15861590 openWindow(id: "clock-report")
15871591 case "app.board":
15881592 openWindow(id: "board")
1593 case "app.flashcards.review":
1594 openWindow(id: "flashcards")
15891595 case "app.node.graph":
15901596 openWindow(id: "graph")
15911597 case "app.sidebar-agenda":
Sources/Orgstar/FlashcardWindow.swift added +27 · view
@@ -0,0 +1,27 @@
1import OrgApp
2import SwiftUI
3
4/// Window ▸ Review Flashcards: the cards due across the workspace, reviewed one at a time.
5/// Opening a card shows its heading in the main window.
6struct FlashcardWindow: View {
7 let commands: AppCommands
8 @State private var review: FlashcardReview
9 @Environment(\.openWindow) private var openWindow
10
11 init(workspace: WorkspaceModel, session: DocumentSession, commands: AppCommands) {
12 self.commands = commands
13 _review = State(initialValue: FlashcardReview(workspace: workspace, session: session))
14 }
15
16 var body: some View {
17 FlashcardReviewView(review: review) { path, offset in
18 if !commands.mainWindowOpen { openWindow(id: "main") }
19 commands.jump(path: path, offset: offset)
20 }
21 .frame(minWidth: 420, minHeight: 360)
22 .navigationTitle("Review Flashcards")
23 .toolbar {
24 Button("Start Again", systemImage: "arrow.clockwise") { Task { await review.start() } }
25 }
26 }
27}
Sources/Orgstar/OrgstarApp.swift +9 · view
@@ -172,6 +172,7 @@ final class AppCommands {
172172 switch link {
173173 case .agenda: run("app.agenda")
174174 case .clock: run("app.clock.goto")
175 case .review: run("app.flashcards.review")
175176 case .entry(let path, let offset): jump(path: path, offset: offset)
176177 case .capture(let template):
177178 captureSerial += 1
@@ -601,6 +602,13 @@ struct OrgstarApp: App {
601602 }
602603 }
603604 .defaultSize(width: 900, height: 700)
605 Window("Review Flashcards", id: "flashcards") {
606 if case .success(let model) = workspace {
607 FlashcardWindow(workspace: model, session: session, commands: commands)
608 .tint(ConfigSync.shared.theme.color("accent"))
609 }
610 }
611 .defaultSize(width: 640, height: 560)
604612 Window("Lint All Folders", id: "lint-folders") {
605613 if case .success(let model) = workspace {
606614 FolderLintWindow(workspace: model, session: session, commands: commands)
@@ -953,6 +961,7 @@ struct AgendaMenuItem: View {
953961 Button("Board") { openWindow(id: "board") }
954962 .keyboardShortcut("b", modifiers: [.command, .shift])
955963 Button("Graph") { if ProAccess.shared.allows(.roam) { openWindow(id: "graph") } }
964 Button("Review Flashcards") { openWindow(id: "flashcards") }
956965 }
957966}
958967
Sources/OrgstarMobile/AgendaScreen.swift +3 · view
@@ -218,6 +218,7 @@ struct AgendaScreen: View, Equatable {
218218 Button("Select", systemImage: "checkmark.circle") { selecting = true }
219219 Divider()
220220 Button("Board", systemImage: "rectangle.split.3x1") { showingBoard = true }
221 Button("Review Flashcards", systemImage: "rectangle.on.rectangle.angled") { model.reviewRequested = true }
221222 Button("Print…", systemImage: "printer") { printAgenda() }
222223 } label: {
223224 Label("Views", systemImage: "list.bullet.rectangle")
@@ -637,6 +638,7 @@ struct AgendaScreen: View, Equatable {
637638 CommandRow(id: "agenda.filter", title: String(localized: "Filter…")),
638639 CommandRow(id: "agenda.select", title: String(localized: "Select")),
639640 CommandRow(id: "agenda.board", title: CommandTitle.localized("Board")),
641 CommandRow(id: "app.flashcards.review", title: CommandTitle.localized("Review Flashcards")),
640642 CommandRow(id: "agenda.print", title: CommandTitle.localized("Print…")),
641643 CommandRow(id: "app.capture", title: CommandTitle.localized("Capture…")),
642644 ]
@@ -658,6 +660,7 @@ struct AgendaScreen: View, Equatable {
658660 case "agenda.filter": showingFilter = true
659661 case "agenda.select": selecting = true
660662 case "agenda.board": showingBoard = true
663 case "app.flashcards.review": model.reviewRequested = true
661664 case "agenda.print": printAgenda()
662665 case "app.capture": model.captureRequest = CaptureRequest()
663666 default: _ = MobileClock.run(id, model: model, workspace: workspace) { message = $0 }
Sources/OrgstarMobile/AppMenus.swift +2 · view
@@ -9,6 +9,7 @@ struct WindowActions {
99 var capture: () -> Void
1010 var addFolder: () -> Void
1111 var board: () -> Void
12 var flashcards: () -> Void
1213 var clock: (String) -> Void
1314}
1415
@@ -80,6 +81,7 @@ struct AppMenus: SwiftUI.Commands {
8081 .keyboardShortcut("a", modifiers: [.command, .shift])
8182 Button("Board") { window?.board() }
8283 .keyboardShortcut("b", modifiers: [.command, .shift])
84 Button("Review Flashcards") { window?.flashcards() }
8385 Button("Folders") { window?.show(.folders) }
8486 Button("Settings") { window?.show(.settings) }
8587 .keyboardShortcut(",")
Sources/OrgstarMobile/EditorScreen.swift +3 · view
@@ -587,6 +587,8 @@ struct EditorScreen: View {
587587 sheet = .rename(kind, context.map { kind.initial(text: $0.text, caret: $0.caret, keywords: $0.tree.settings.todoKeywordNames) } ?? "")
588588 } else if id == "app.lint-folders" {
589589 sheet = .lintFolders
590 } else if id == "app.flashcards.review" {
591 model.reviewRequested = true
590592 } else if id == "app.lint" {
591593 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") }
592594 } else if id == "app.working-copy.sync" {
@@ -1164,6 +1166,7 @@ struct CommandPalette: View {
11641166 ("app.toggle-markup", "Show or Hide Markup"), ("app.word-count", "Word Count"),
11651167 ("org.snippet.next-field", "Next Snippet Field"), ("org.snippet.previous-field", "Previous Snippet Field"),
11661168 ("app.recovery", "Recovery Versions…"), ("app.sync-conflicts", "Resolve Sync Conflicts…"), ("app.lint", "Lint File"), ("app.lint-folders", "Lint All Folders"),
1169 ("app.flashcards.review", "Review Flashcards"),
11671170 ("app.working-copy.sync", "Sync with Working Copy"),
11681171 ("app.cite.insert", "Insert Citation…"),
11691172 ("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"),
Sources/OrgstarMobile/FlashcardScreen.swift added +29 · view
@@ -0,0 +1,29 @@
1#if os(iOS)
2import OrgApp
3import SwiftUI
4
5/// The flashcard review on iPhone and iPad, full screen. `done` closes it, with a card's file
6/// and heading to open when Open in Editor was chosen.
7struct FlashcardScreen: View {
8 let done: (String?, Int) -> Void
9 @State private var review: FlashcardReview
10
11 init(workspace: WorkspaceModel, session: DocumentSession, done: @escaping (String?, Int) -> Void) {
12 self.done = done
13 _review = State(initialValue: FlashcardReview(workspace: workspace, session: session))
14 }
15
16 var body: some View {
17 NavigationStack {
18 FlashcardReviewView(review: review) { path, offset in done(path, offset) }
19 .navigationTitle("Review")
20 .navigationBarTitleDisplayMode(.inline)
21 .toolbar {
22 ToolbarItem(placement: .cancellationAction) {
23 Button("Done") { done(nil, 0) }
24 }
25 }
26 }
27 }
28}
29#endif
Sources/OrgstarMobile/MobileEditor.swift +1 −1 · view
@@ -537,7 +537,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
537537 case "app.crypt.encrypt-entry": return onAppCommand != nil && OrgCrypt.heading(context.text, at: context.caret) != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) == nil
538538 case "app.crypt.open-entry", "app.crypt.decrypt-entry": return onAppCommand != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) != nil
539539 case "app.table-export", "app.table-export.tsv", "app.plot": return onAppCommand != nil && ImportTable.exportText(context.text, at: context.caret, path: "") != nil
540 case "app.word-count", "app.recovery", "app.sync-conflicts", "app.lint", "app.lint-folders", "app.attach.photo", "app.attach.camera", "app.attach.scan",
540 case "app.word-count", "app.recovery", "app.sync-conflicts", "app.lint", "app.lint-folders", "app.flashcards.review", "app.attach.photo", "app.attach.camera", "app.attach.scan",
541541 "app.rename-tag", "app.rename-todo-keyword": return onAppCommand != nil
542542 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true
543543 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
Sources/OrgstarMobile/MobileModel.swift +7 −1 · view
@@ -41,6 +41,8 @@ final class MobileModel {
4141 var captureRequest: CaptureRequest?
4242 /// Folders shows its folder picker, from File ▸ Add Folder… in the menu bar.
4343 var addingFolder = false
44 /// The flashcard review shows, from the agenda, the menu bar, a command or the widget.
45 var reviewRequested = false
4446 /// Calendar's events for the agenda, with `calendar-events`.
4547 let calendarEvents = CalendarEvents()
4648 /// Captures the watch sent, for the root view to pick up from the inbox.
@@ -361,7 +363,11 @@ final class MobileModel {
361363 if AgendaSnapshot.reloadsWidgets(locked: true, wasLocked: wasLocked, snapshotChanged: false) { WidgetCenter.shared.reloadAllTimelines() }
362364 return
363365 }
364 WatchLink.shared.send(WatchAgenda(groups: groups, today: days.today, clock: clock.running, lastClocked: clock.history.first?.title, generated: Date()))
366 let cards = await FlashcardReview.cards(workspace: workspace, session: session)
367 var watch = WatchAgenda(groups: groups, today: days.today, clock: clock.running, lastClocked: clock.history.first?.title, generated: Date())
368 watch.cards = WatchAgenda.Card.review(Flashcards.due(cards, at: Date()))
369 WatchLink.shared.send(watch)
370 if (try? FlashcardSnapshot(cards: cards.map(\.card)).write()) == true { WidgetCenter.shared.reloadTimelines(ofKind: "sh.krz.orgstar.flashcards") }
365371 await updateBadge(OverdueBadge.counts(groups, today: days.today, days: AgendaSnapshot.dayCount))
366372 if (try? HabitSnapshot(habits: await days.habits(open: session.openTexts), theme: theme).write()) == true { WidgetCenter.shared.reloadTimelines(ofKind: "sh.krz.orgstar.habits") }
367373 _ = try? TemplateList(templates: CaptureTemplates.load().templates.map { .init(key: $0.key, name: $0.name) }).write()
Sources/OrgstarMobile/OrgstarMobileApp.swift +9 −1 · view
@@ -318,10 +318,16 @@ struct RootView: View {
318318 tab = .folders
319319 model.addingFolder = true
320320 },
321 board: { showingBoard = true }, clock: clock))
321 board: { showingBoard = true }, flashcards: { model.reviewRequested = true }, clock: clock))
322322 .fullScreenCover(isPresented: $showingBoard) {
323323 BoardScreen(workspace: workspace, session: session) { showingBoard = false }
324324 }
325 .fullScreenCover(isPresented: Binding(get: { model.reviewRequested }, set: { model.reviewRequested = $0 })) {
326 FlashcardScreen(workspace: workspace, session: session) { path, offset in
327 model.reviewRequested = false
328 if let path { model.openRequest = .offset(path, offset) }
329 }
330 }
325331 // A removed folder's row goes from the sidebar.
326332 .onChange(of: workspace.rootPaths) {
327333 if case .folder(let root) = tab, !workspace.rootPaths.contains(root) { tab = .folders }
@@ -566,6 +572,8 @@ struct RootView: View {
566572 clock("app.clock.goto")
567573 case .capture(let template):
568574 capture = CaptureRequest(template: template)
575 case .review:
576 model.reviewRequested = true
569577 }
570578 }
571579
Sources/OrgstarMobile/WatchLink.swift +4 · view
@@ -52,6 +52,10 @@ final class WatchLink: NSObject, WCSessionDelegate {
5252 components.queryItems = [URLQueryItem(name: "body", value: text)]
5353 if let link = components.url?.absoluteString { try? model.inbox?.add(link) }
5454 model.watchCaptures += 1
55 case .rate(let path, let card, let position, let rating):
56 if let rating = Flashcards.Rating(rawValue: rating) {
57 _ = FlashcardReview.rate(path: path, card: card, position: position, rating: rating, seconds: 0, session: model.session)
58 }
5559 }
5660 await model.updateWidgets()
5761 }
Sources/OrgstarWatch/WatchApp.swift +58 · view
@@ -53,6 +53,10 @@ final class PhoneLink: NSObject, WCSessionDelegate {
5353 sentCaptures += 1
5454 case .clockInLast:
5555 break
56 case .rate(_, _, _, let rating):
57 if let agenda, let card = agenda.cards?.first(where: { $0.rate(rating) == action }) {
58 store(agenda.rating(card, again: rating == "again"))
59 }
5660 }
5761 let session = WCSession.default
5862 guard session.activationState == .activated else { return }
@@ -145,6 +149,13 @@ struct AgendaList: View {
145149 } footer: {
146150 Text("orgstar files it with a template when you next open it on iPhone.")
147151 }
152 if let cards = link.agenda?.cards, !cards.isEmpty {
153 Section("Flashcards") {
154 NavigationLink { CardReview(link: link) } label: {
155 Label("Review \(cards.count) cards", systemImage: "rectangle.on.rectangle.angled")
156 }
157 }
158 }
148159 if let agenda = link.agenda {
149160 if !agenda.overdue.isEmpty {
150161 Section("Overdue") { ForEach(agenda.overdue) { EntryRow(entry: $0, link: link) } }
@@ -159,6 +170,53 @@ struct AgendaList: View {
159170 }
160171}
161172
173/// Normal and double flashcards due, from the phone: the front, Show Answer, the back and
174/// org-fc's four ratings. The phone writes each rating to the card's file.
175struct CardReview: View {
176 let link: PhoneLink
177 @State private var flipped = false
178
179 var body: some View {
180 if let card = link.agenda?.cards?.first {
181 ScrollView {
182 VStack(alignment: .leading, spacing: 6) {
183 Text(flipped ? card.backTitle : card.title ?? "[…]").font(.headline)
184 .foregroundStyle(flipped || card.title != nil ? .primary : .secondary)
185 let text = flipped ? card.back : card.front
186 if !text.isEmpty { Text(text).font(.body) }
187 if flipped {
188 Grid(horizontalSpacing: 6, verticalSpacing: 6) {
189 GridRow {
190 rate(card, "again", "Again", .red)
191 rate(card, "hard", "Hard", .orange)
192 }
193 GridRow {
194 rate(card, "good", "Good", .green)
195 rate(card, "easy", "Easy", .blue)
196 }
197 }
198 .padding(.top, 4)
199 } else {
200 Button("Show Answer") { flipped = true }.padding(.top, 4)
201 }
202 }
203 }
204 .navigationTitle("\(link.agenda?.cards?.count ?? 0) left")
205 } else {
206 Text("Nothing else is due.").foregroundStyle(.secondary).navigationTitle("Flashcards")
207 }
208 }
209
210 private func rate(_ card: WatchAgenda.Card, _ rating: String, _ title: LocalizedStringKey, _ tint: Color) -> some View {
211 Button(title) {
212 flipped = false
213 link.send(card.rate(rating))
214 }
215 .tint(tint)
216 .buttonStyle(.borderedProminent)
217 }
218}
219
162220struct EntryRow: View {
163221 let entry: WatchAgenda.Entry
164222 let link: PhoneLink
Sources/OrgstarWidgets/FlashcardWidget.swift added +88 · view
@@ -0,0 +1,88 @@
1import OrgApp
2import SwiftUI
3import WidgetKit
4
5/// How many flashcards are due; tapping it starts the review.
6struct FlashcardWidget: Widget {
7 var body: some WidgetConfiguration {
8 StaticConfiguration(kind: "sh.krz.orgstar.flashcards", provider: FlashcardProvider()) { entry in
9 FlashcardView(entry: entry)
10 }
11 .configurationDisplayName("Flashcards")
12 .description("How many flashcards are due for review.")
13 #if os(macOS)
14 .supportedFamilies([.systemSmall])
15 #else
16 .supportedFamilies([.systemSmall, .accessoryCircular, .accessoryInline])
17 #endif
18 }
19}
20
21struct FlashcardEntry: TimelineEntry {
22 let date: Date
23 /// Nil until the app has written one.
24 let snapshot: FlashcardSnapshot?
25}
26
27/// The count now, and again each time another card falls due.
28struct FlashcardProvider: TimelineProvider {
29 func placeholder(in context: Context) -> FlashcardEntry {
30 FlashcardEntry(date: .now, snapshot: FlashcardSnapshot(due: [.now.addingTimeInterval(-60)]))
31 }
32
33 func getSnapshot(in context: Context, completion: @escaping (FlashcardEntry) -> Void) {
34 completion(FlashcardEntry(date: .now, snapshot: widgetsLocked ? nil : FlashcardSnapshot.read()))
35 }
36
37 func getTimeline(in context: Context, completion: @escaping (Timeline<FlashcardEntry>) -> Void) {
38 let snapshot = widgetsLocked ? nil : FlashcardSnapshot.read()
39 let dates = [Date.now] + (snapshot?.changes(after: .now) ?? [])
40 completion(Timeline(entries: dates.map { FlashcardEntry(date: $0, snapshot: snapshot) }, policy: .never))
41 }
42}
43
44struct FlashcardView: View {
45 let entry: FlashcardEntry
46 @Environment(\.widgetFamily) private var family
47
48 private var count: Int { entry.snapshot?.count(at: entry.date) ?? 0 }
49
50 var body: some View {
51 content
52 .widgetURL(AppLink.review.url)
53 #if os(macOS)
54 .containerBackground(for: .widget) { Color(nsColor: .windowBackgroundColor) }
55 #else
56 .containerBackground(for: .widget) { family == .systemSmall ? Color(uiColor: .systemBackground) : Color.clear }
57 #endif
58 }
59
60 @ViewBuilder
61 private var content: some View {
62 switch family {
63 case .accessoryInline:
64 Text("\(count) cards due")
65 case .accessoryCircular:
66 ZStack {
67 AccessoryWidgetBackground()
68 VStack(spacing: -2) {
69 Text("\(count)").font(.title2.weight(.semibold)).widgetAccentable()
70 Text("cards").font(.caption2)
71 }
72 }
73 .accessibilityLabel("\(count) cards due")
74 default:
75 VStack(alignment: .leading, spacing: 4) {
76 Label("Flashcards", systemImage: "rectangle.on.rectangle.angled").font(.subheadline.weight(.semibold)).widgetAccentable()
77 Spacer(minLength: 0)
78 if entry.snapshot == nil {
79 Text(widgetsLocked ? "Widgets need orgstar+." : "Open orgstar to count your cards here.").font(.caption).foregroundStyle(.secondary)
80 } else {
81 Text("\(count)").font(.system(size: 44, weight: .semibold, design: .rounded)).monospacedDigit()
82 Text(count == 0 ? "Nothing due" : "due for review").font(.caption).foregroundStyle(.secondary)
83 }
84 }
85 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
86 }
87 }
88}
Sources/OrgstarWidgets/OrgstarWidgets.swift +1 · view
@@ -19,6 +19,7 @@ struct OrgstarWidgets: WidgetBundle {
1919 TodayWidget()
2020 HabitsWidget()
2121 UpNextWidget()
22 FlashcardWidget()
2223 #if os(iOS)
2324 CaptureWidget()
2425 ClockActivityWidget()
Tests/OrgAppTests/FlashcardReviewTests.swift added +79 · view
@@ -0,0 +1,79 @@
1import Foundation
2import OrgCore
3import OrgDocument
4@testable import OrgIndex
5import Testing
6@testable import OrgApp
7
8@MainActor
9struct FlashcardReviewTests {
10 static func card(_ title: String, id: String, type: String = "normal", rows: [(String, String)], tags: String = ":fc:") -> String {
11 """
12 * \(title) \(tags)
13 :PROPERTIES:
14 :FC_CREATED: 2026-11-01T00:00:00Z
15 :FC_TYPE: \(type)
16 :FC_ALGO: sm2
17 :ID: \(id)
18 :END:
19 :REVIEW_DATA:
20 | position | ease | box | interval | due |
21 |----------+------+-----+----------+----------------------|
22 \(rows.map { "| \($0.0) | 2.50 | 0 | 0.00 | \($0.1) |" }.joined(separator: "\n"))
23 :END:
24 Answer of \(title)
25
26 """
27 }
28
29 static let now = Date(timeIntervalSince1970: 1_795_000_000)
30 static let past = "2026-11-17T00:00:00Z", future = "2026-12-30T00:00:00Z"
31
32 @Test func reviewRatesThroughTheSessionAndLogsTheHistory() async throws {
33 let notes = try Folder()
34 let deck = try notes.write("deck.org", Self.card("One", id: "one", rows: [("front", Self.past)])
35 + Self.card("Two", id: "two", type: "double", rows: [("front", Self.past), ("back", Self.past)])
36 + Self.card("Later", id: "later", rows: [("front", Self.future)]))
37 _ = try notes.write("other.org", "* Not a card\n")
38 _ = try notes.write("held.org", Self.card("Held", id: "held", rows: [("front", Self.past)], tags: ":suspended:fc:"))
39 let workspace = try WorkspaceModel(directory: nil)
40 try await workspace.addRoot(notes.url)
41 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
42 #expect(try workspace.index.files(withLocalTag: "fc") == [deck.path, notes.url.appendingPathComponent("held.org").path].sorted())
43
44 let review = FlashcardReview(workspace: workspace, session: session)
45 review.history = notes.url.appendingPathComponent("logs/reviews.tsv")
46 await review.start(now: Self.now)
47 // One position of the double card; not the card due later or the suspended one.
48 #expect(review.queue.map(\.card.id).sorted() == ["one", "two"])
49 let first = try #require(review.current)
50 #expect(review.face?.front.title == first.card.title)
51 review.flip()
52 review.rate(.again, now: Self.now)
53 #expect(review.queue.map(\.card.id) == [review.queue[0].card.id, first.card.id])
54 let second = try #require(review.current)
55 review.rate(.easy, now: Self.now)
56 #expect(review.queue.map(\.card.id) == [first.card.id] && review.reviewed == 2)
57
58 let text = try String(contentsOf: deck, encoding: .utf8)
59 let cards = Flashcards.cards(in: text)
60 let card = try #require(cards.first { $0.id == second.card.id })
61 let rated = try #require(card.positions.first { $0.name == second.position })
62 #expect(rated.values["box"] == "2" && rated.values["due"] == "2026-11-19T11:06:40Z")
63 let history = try String(contentsOf: review.history, encoding: .utf8).split(separator: "\n")
64 #expect(history.count == 2)
65 #expect(history[0].hasPrefix("2026-11-18T11:06:40Z\t\(deck.path)\t\(first.card.id)\t\(first.position)\t2.50\t0\t0.00\tagain\t"))
66 #expect(history[1].contains("\t\(second.card.id)\t\(second.position)\t2.50\t0\t0.00\teasy\t") && history[1].hasSuffix("\tsm2-v1"))
67
68 review.suspend()
69 #expect(review.queue.isEmpty && review.face == nil)
70 #expect(Flashcards.cards(in: try String(contentsOf: deck, encoding: .utf8)).first { $0.id == first.card.id }?.suspended == true)
71 }
72
73 @Test func snapshotCountsAsTimePasses() {
74 let snapshot = FlashcardSnapshot(due: [Self.now.addingTimeInterval(60), Self.now.addingTimeInterval(-60), Self.now.addingTimeInterval(60)])
75 #expect(snapshot.count(at: Self.now) == 1)
76 #expect(snapshot.count(at: Self.now.addingTimeInterval(61)) == 3)
77 #expect(snapshot.changes(after: Self.now) == [Self.now.addingTimeInterval(61)])
78 }
79}
Tests/OrgCoreTests/FlashcardOracleTests.swift added +270 · view
@@ -0,0 +1,270 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5/// org-fc itself, run in Emacs, when it's installed: the load-path directory in
6/// `ORGSTAR_ORG_FC`, else a Doom or package.el install.
7struct FlashcardOracleTests {
8 static let loadPath: String? = {
9 if let path = ProcessInfo.processInfo.environment["ORGSTAR_ORG_FC"] { return path }
10 let fm = FileManager.default, home = NSHomeDirectory()
11 let roots = ["\(home)/.config/emacs/.local/straight", "\(home)/.emacs.d/.local/straight"].flatMap { root in
12 ((try? fm.contentsOfDirectory(atPath: root)) ?? []).filter { $0.hasPrefix("build-") }.sorted().reversed().map { "\(root)/\($0)" }
13 } + ["\(home)/.emacs.d/elpa", "\(home)/.config/emacs/elpa"]
14 for root in roots {
15 let names = (try? fm.contentsOfDirectory(atPath: root)) ?? []
16 if let name = names.filter({ $0 == "org-fc" || ($0.hasPrefix("org-fc-") && $0.dropFirst(7).first?.isNumber == true) }).sorted().last {
17 return "\(root)/\(name)"
18 }
19 }
20 return nil
21 }()
22
23 static var enabled: Bool { loadPath != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil }
24
25 static let now = 1_795_000_000.25
26
27 /// Loads org-fc, with the clock at `now` (or `nows`, one per call to `time-to-seconds`), IDs
28 /// `id-1`, `id-2`, … and `cl-random` returning `randoms` in turn as fractions of its limit.
29 static func prelude(history: String = "/dev/null") -> String {
30 """
31 (setq load-path (cons \(loadPath!.debugDescription) load-path) make-backup-files nil auto-save-default nil create-lockfiles nil
32 org-id-track-globally nil org-fc-review-history-file \(history.debugDescription))
33 (require 'org-fc)
34 (defvar oracle-now \(now))
35 (defvar oracle-randoms nil)
36 (defvar oracle-ids 0)
37 """
38 }
39
40 static func form(_ body: String) -> String {
41 """
42 (cl-letf (((symbol-function 'time-to-seconds) (lambda (&optional _) oracle-now))
43 ((symbol-function 'org-id-new) (lambda (&rest _) (format "id-%d" (setq oracle-ids (1+ oracle-ids)))))
44 ((symbol-function 'cl-random) (lambda (limit &optional _) (* limit (pop oracle-randoms)))))
45 \(body))
46 """
47 }
48
49 /// Runs `command` on `text` with the caret at the start of the heading `title`.
50 static func run(_ command: any OrgCommand, on title: String, in text: String, now: Double = now, answers: [String: String] = [:]) -> (text: String, failed: String?) {
51 let found = (text as NSString).range(of: "(?m)^\\*+ " + NSRegularExpression.escapedPattern(for: title), options: .regularExpression).location
52 let caret = found == NSNotFound ? 0 : found
53 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: Date(timeIntervalSince1970: now), answers: answers)
54 switch command.run(in: context) {
55 case .commit(let result):
56 var new = text
57 for edit in result.edits.sorted(by: { $0.range.lowerBound > $1.range.lowerBound }) { new = edit.apply(to: new) }
58 return (new, nil)
59 case .failed(let message): return (text, message)
60 default: return (text, "other")
61 }
62 }
63
64 static let cards = """
65 #+title: Cards
66 #+filetags: :lang:
67
68 * Capital of France
69 Paris
70 * Hund :german:
71 SCHEDULED: <2026-11-20 Fri>
72 :PROPERTIES:
73 :CUSTOM: kept
74 :END:
75 dog
76 ** Notes
77 masculine
78 * Two sided
79 Front text
80 ** Back
81 Back text
82 * Animals
83 The {{cat}{animal}} sat on the {{mat}}, and $x^{2}$ is {{$x^{2}$}{math}@4}.
84 * Enumerate {{one}}
85 - {{two}}
86 - {{three}{hint}}
87 * Type it
88 *Answer*
89 * Typed back
90 Question
91 ** Back
92 =exact=
93 * Not typed
94 ** Child
95 * Context
96 {{a}} {{b}} {{c}} {{d}}
97 * Already :fc:
98 :PROPERTIES:
99 :ID: kept-id
100 :END:
101 """
102
103 static let steps: [(title: String, command: any OrgCommand, answers: [String: String], form: String)] = [
104 ("Capital of France", MakeFlashcard(.normal), [:], "(org-fc-type-normal-init)"),
105 ("Hund", MakeFlashcard(.double), [:], "(org-fc-type-double-init)"),
106 ("Two sided", MakeFlashcard(.double), [:], "(org-fc-type-double-init)"),
107 ("Animals", MakeFlashcard(.cloze), ["cloze-type": "deletion"], "(org-fc-type-cloze-init 'deletion)"),
108 ("Enumerate", MakeFlashcard(.cloze), ["cloze-type": "enumeration"], "(org-fc-type-cloze-init 'enumeration)"),
109 ("Type it", MakeFlashcard(.textInput), [:], "(org-fc-type-text-input-init)"),
110 ("Typed back", MakeFlashcard(.textInput), [:], "(org-fc-type-text-input-init)"),
111 ("Not typed", MakeFlashcard(.textInput), [:], "(org-fc-type-text-input-init)"),
112 ("Context", MakeFlashcard(.cloze), ["cloze-type": "context"], "(org-fc-type-cloze-init 'context)"),
113 ("Already", MakeFlashcard(.normal), [:], "(org-fc-type-normal-init)"),
114 ]
115
116 /// Each `org-fc-type-*-init` on headings with and without drawers, planning, subheadings,
117 /// a `Back` heading, cloze holes with hints, positions and math, and on a heading that is
118 /// already a card or has no answer line (both refused, nothing changed).
119 @Test(.enabled(if: enabled)) func makingCardsMatchesOrgFc() throws {
120 let calls = Self.steps.map { step in
121 "(goto-char (point-min)) (re-search-forward \(("^\\*+ " + step.title).debugDescription)) (beginning-of-line) (ignore-errors \(step.form))"
122 }.joined(separator: "\n")
123 let theirs = try EmacsOracle.evaluate(Self.cards, Self.form("(progn \(calls) (list (buffer-substring-no-properties (point-min) (point-max))))"), prelude: Self.prelude())
124 let ids = Counter()
125 var ours = Self.cards
126 var refused: [String] = []
127 for step in Self.steps {
128 let result = Self.run(Self.numbered(step.command, ids), on: step.title, in: ours, answers: step.answers)
129 ours = result.text
130 if result.failed != nil { refused.append(step.title) }
131 }
132 #expect(refused == ["Not typed", "Already"])
133 #expect(ours.contains("{{cat}{animal}@0}") && ours.contains("| front | 2.50 | 0 | 0.00 | 2026-11-18T11:06:40Z |"))
134 #expect(ours == theirs.first, "\(theirs.first ?? "")")
135 }
136
137 final class Counter: @unchecked Sendable {
138 var count = 0
139 func next() -> String {
140 count += 1
141 return "id-\(count)"
142 }
143 }
144
145 /// `command`, giving IDs `id-1`, `id-2`, … as the oracle's `org-id-new` does.
146 static func numbered(_ command: any OrgCommand, _ ids: Counter) -> any OrgCommand {
147 (command as? MakeFlashcard).map { made in MakeFlashcard(made.type) { ids.next() } } ?? command
148 }
149
150 static func initialized() throws -> String {
151 let ids = Counter()
152 var text = Self.cards
153 for step in Self.steps {
154 text = Self.run(Self.numbered(step.command, ids), on: step.title, in: text, answers: step.answers).text
155 }
156 return text
157 }
158
159 static let ratings: [(id: String, position: String, rating: Flashcards.Rating, days: Double, random: Double)] = [
160 ("id-1", "front", .good, 0, 0.5),
161 ("id-1", "front", .good, 0.02, 0.5),
162 ("id-1", "front", .good, 1.1, 0.5),
163 ("id-1", "front", .good, 7.5, 0.13),
164 ("id-1", "front", .hard, 25, 0.97),
165 ("id-1", "front", .easy, 60, 0.0),
166 ("id-1", "front", .again, 140, 0.4),
167 ("id-2", "back", .easy, 0, 0.5),
168 ("id-2", "back", .hard, 1.5, 0.5),
169 ("id-2", "back", .hard, 8, 0.71),
170 ("id-2", "front", .again, 8, 0.5),
171 ("id-4", "1", .easy, 0, 0.5),
172 ("id-4", "4", .good, 0, 0.5),
173 ("id-5", "2", .hard, 0, 0.5),
174 ]
175
176 /// Ratings through every box and branch of SM2 (learning boxes, easy from box 0, fuzzed
177 /// intervals, ease clamped, again back to box 0), written to the drawer and to the review
178 /// history as `org-fc-review-rate` writes them.
179 @Test(.enabled(if: enabled)) func ratingsMatchOrgFc() throws {
180 let start = try Self.initialized()
181 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-fc-\(UUID().uuidString)")
182 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
183 defer { try? FileManager.default.removeItem(at: folder) }
184 let history = folder.appendingPathComponent("reviews.tsv")
185 let calls = Self.ratings.map { r in
186 """
187 (setq oracle-now \(Self.now + r.days * 86400) oracle-randoms (list \(r.random)))
188 (goto-char (point-min)) (re-search-forward "^:ID: +\(r.id)$") (org-back-to-heading)
189 (org-fc-review-update-data
190 (org-fc-position :name "\(r.position)" :card (org-fc-card :id "\(r.id)" :file (org-fc-file :path "/cards.org") :algo (org-fc-algo-sm2)))
191 '\(r.rating.rawValue) 3.25)
192 """
193 }.joined(separator: "\n")
194 let theirs = try EmacsOracle.evaluate(start, Self.form("(progn \(calls) (list (buffer-substring-no-properties (point-min) (point-max))))"), prelude: Self.prelude(history: history.path))
195 let theirHistory = try String(contentsOf: history, encoding: .utf8)
196 var ours = start
197 var ourHistory = ""
198 for r in Self.ratings {
199 let now = Self.now + r.days * 86400
200 let card = Flashcards.cards(in: ours).first { $0.id == r.id }!
201 let position = card.positions.first { $0.name == r.position }!
202 ourHistory += Flashcards.historyLine(at: Date(timeIntervalSince1970: now), path: "/cards.org", id: r.id, position: position, rating: r.rating, seconds: 3.25)
203 let result = Self.run(RateFlashcard(card: r.id, position: r.position, rating: r.rating, random: r.random), on: "Cards", in: ours, now: now)
204 #expect(result.failed == nil)
205 ours = result.text
206 }
207 #expect(ourHistory.split(separator: "\n").count == Self.ratings.count)
208 #expect(ours != start)
209 #expect(ours == theirs.first, "\(theirs.first ?? "")")
210 #expect(ourHistory == theirHistory)
211 }
212
213 /// `org-fc-update` on a cloze card given new holes, `org-fc-suspend-card` and
214 /// `org-fc-unsuspend-card`.
215 @Test(.enabled(if: enabled)) func updatingAndSuspendingMatchOrgFc() throws {
216 var start = try Self.initialized()
217 start = start.replacingOccurrences(of: "sat on the {{mat}@1}", with: "sat on the {{mat}@1} by the {{door}{where}}")
218 let form = """
219 (progn
220 (goto-char (point-min)) (re-search-forward "^\\\\* Animals") (org-fc-update)
221 (goto-char (point-min)) (re-search-forward "^\\\\*\\\\* Notes") (org-fc-suspend-card)
222 (goto-char (point-min)) (re-search-forward "^\\\\* Capital") (org-fc-suspend-card)
223 (goto-char (point-min)) (re-search-forward "^\\\\* Capital") (org-fc-unsuspend-card)
224 (list (buffer-substring-no-properties (point-min) (point-max))))
225 """
226 let theirs = try EmacsOracle.evaluate(start, Self.form(form), prelude: Self.prelude())
227 var ours = Self.run(UpdateFlashcard(), on: "Animals", in: start).text
228 ours = Self.run(SuspendFlashcard(), on: "Notes", in: ours).text
229 ours = Self.run(SuspendFlashcard(), on: "Capital", in: ours).text
230 ours = Self.run(SuspendFlashcard(suspend: false), on: "Capital", in: ours).text
231 #expect(ours.contains("{{door}{where}@2}") && ours.contains(":suspended:fc:german:"))
232 #expect(ours == theirs.first, "\(theirs.first ?? "")")
233 }
234
235 /// The positions a review shows: org-fc's own filters (`org-fc-index-filter-due` and the
236 /// sibling burying) over cards whose positions `org-fc-review-data-parse` reads, against
237 /// `Flashcards.due` over the cards orgstar reads.
238 @Test(.enabled(if: enabled)) func dueCardsMatchOrgFc() throws {
239 var text = try Self.initialized()
240 // Some positions due later, one card suspended.
241 for (id, position, rating) in [("id-1", "front", Flashcards.Rating.easy), ("id-4", "0", .good), ("id-5", "1", .easy), ("id-2", "front", .easy)] {
242 text = Self.run(RateFlashcard(card: id, position: position, rating: rating, random: 0.5), on: "Cards", in: text).text
243 }
244 text = Self.run(SuspendFlashcard(), on: "Context", in: text).text
245 let now = Self.now + 3600
246 let form = """
247 (let (cards)
248 (org-fc-map-cards
249 (lambda ()
250 ;; As org-fc's indexer, only headings with review data.
251 (when-let* ((_ (org-fc-review-data-position))
252 (card (org-fc-card :id (org-id-get) :type (intern (org-entry-get nil "FC_TYPE"))
253 :cloze-type (let ((c (org-entry-get nil "FC_CLOZE_TYPE"))) (and c (intern c)))
254 :suspended (and (org-fc-suspended-entry-p) t) :algo (org-fc-algo-sm2)))
255 (data (org-fc-review-data-parse '(position ease box interval due))))
256 (oset card positions
257 (mapcar (lambda (row) (org-fc-position :card card :name (car row) :due (parse-iso8601-time-string (plist-get (cdr row) 'due)))) (oref data rows)))
258 (push card cards))))
259 (setq cards (nreverse cards))
260 (cl-letf (((symbol-function 'current-time) (lambda () (seconds-to-time \(now)))))
261 (dolist (filter org-fc-review-card-filters) (setq cards (funcall filter cards))))
262 (mapcan (lambda (card) (mapcar (lambda (pos) (concat (oref card id) " " (oref pos name))) (oref card positions))) cards))
263 """
264 let theirs = try EmacsOracle.evaluate(text, form, prelude: Self.prelude())
265 let ours = Flashcards.due(Flashcards.cards(in: text).map { (path: "", card: $0) }, at: Date(timeIntervalSince1970: now), shuffle: false)
266 .map { "\($0.card.id) \($0.position)" }
267 #expect(ours.count >= 5 && !ours.contains { $0.hasPrefix("id-1 ") } && !ours.contains { $0.hasPrefix("id-8 ") })
268 #expect(ours == theirs)
269 }
270}
Tests/OrgCoreTests/FlashcardTests.swift added +206 · view
@@ -0,0 +1,206 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5struct FlashcardTests {
6 static let now = Date(timeIntervalSince1970: 1_795_000_000.25)
7
8 static func run(_ command: any OrgCommand, _ text: String, caret: Int = 0, now: Date = now, answers: [String: String] = [:]) -> (text: String, failed: String?) {
9 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: now, answers: answers)
10 switch command.run(in: context) {
11 case .commit(let result):
12 var new = text
13 for edit in result.edits.sorted(by: { $0.range.lowerBound > $1.range.lowerBound }) { new = edit.apply(to: new) }
14 return (new, nil)
15 case .failed(let message): return (text, message)
16 case .prompt(let prompt): return (text, "prompt \(prompt.key)")
17 default: return (text, "other")
18 }
19 }
20
21 /// What `org-fc-type-normal-init` and `org-fc-type-cloze-init` wrote in Emacs 31.1 with
22 /// Org 9.8.7 and org-fc at fce1cb2, the clock at 1795000000.25.
23 @Test func makesCardsAsOrgFcDoes() {
24 let text = "* Q :x:\n\nans\n* Cloze\nThe {{cat}{animal}} sat on {{mat}}.\n** Back\nb\n"
25 var result = Self.run(MakeFlashcard(.normal) { "the-id" }, text)
26 #expect(result.failed == nil)
27 let cloze = (result.text as NSString).range(of: "* Cloze").location
28 #expect(Self.run(MakeFlashcard(.cloze) { "the-id" }, result.text, caret: cloze).failed == "prompt cloze-type")
29 result = Self.run(MakeFlashcard(.cloze) { "the-id" }, result.text, caret: cloze, answers: ["cloze-type": "deletion"])
30 #expect(result.failed == nil)
31 #expect(result.text == """
32 * Q :fc:x:
33 :PROPERTIES:
34 :FC_CREATED: 2026-11-18T11:06:40Z
35 :FC_TYPE: normal
36 :FC_ALGO: sm2
37 :ID: the-id
38 :END:
39 :REVIEW_DATA:
40 | position | ease | box | interval | due |
41 |----------+------+-----+----------+----------------------|
42 | front | 2.50 | 0 | 0.00 | 2026-11-18T11:06:40Z |
43 :END:
44
45 ans
46 * Cloze :fc:
47 :PROPERTIES:
48 :FC_CREATED: 2026-11-18T11:06:40Z
49 :FC_TYPE: cloze
50 :FC_ALGO: sm2
51 :ID: the-id
52 :FC_CLOZE_MAX: 1
53 :FC_CLOZE_TYPE: deletion
54 :END:
55 :REVIEW_DATA:
56 | position | ease | box | interval | due |
57 |----------+------+-----+----------+----------------------|
58 | 0 | 2.50 | 0 | 0.00 | 2026-11-18T11:06:40Z |
59 | 1 | 2.50 | 0 | 0.00 | 2026-11-18T11:06:40Z |
60 :END:
61 The {{cat}{animal}@0} sat on {{mat}@1}.
62 ** Back
63 b
64
65 """)
66 #expect(Self.run(MakeFlashcard(.normal), result.text).failed == "Headline is already a flashcard")
67 }
68
69 @Test func sm2FollowsOrgFc() {
70 let sm2 = Flashcards.SM2()
71 func next(_ ease: String, _ box: String, _ interval: String, _ rating: Flashcards.Rating, random: Double = 0.5) -> [String] {
72 let row = sm2.next(["ease": ease, "box": box, "interval": interval], rating: rating, now: Self.now, random: random)
73 return [row["ease"]!, row["box"]!, row["interval"]!]
74 }
75 // Learning boxes keep the ease and take fixed intervals.
76 #expect(next("2.50", "0", "0.00", .good) == ["2.50", "1", "0.01"])
77 #expect(next("2.50", "0", "0.00", .easy) == ["2.50", "2", "1.00"])
78 #expect(next("2.50", "1", "0.01", .again) == ["2.50", "0", "0.00"])
79 #expect(next("2.50", "2", "1.00", .good) == ["2.50", "3", "6.00"])
80 // Then the ease changes, and the interval is ease times the last, fuzzed.
81 #expect(next("2.50", "3", "6.00", .good, random: 0.5) == ["2.50", "4", "15.00"])
82 #expect(next("2.50", "3", "6.00", .hard, random: 0) == ["2.35", "4", "12.69"])
83 #expect(next("2.50", "3", "6.00", .easy, random: 1) == ["2.65", "4", "17.49"])
84 #expect(next("1.40", "5", "20.00", .again) == ["1.30", "0", "0.00"])
85 #expect(next("4.95", "5", "20.00", .easy) == ["5.00", "6", "100.00"])
86 #expect(sm2.next(["ease": "2.50", "box": "1", "interval": "0.01"], rating: .good, now: Self.now, random: 0)["due"] == "2026-11-19T11:06:40Z")
87 }
88
89 static let deck = """
90 * Normal :fc:
91 :PROPERTIES:
92 :FC_CREATED: 2026-11-01T00:00:00Z
93 :FC_TYPE: normal
94 :FC_ALGO: sm2
95 :ID: n
96 :END:
97 :REVIEW_DATA:
98 | position | ease | box | interval | due |
99 |----------+------+-----+----------+----------------------|
100 | front | 2.50 | 0 | 0.00 | 2026-11-18T00:00:00Z |
101 :END:
102 Answer text
103 * Double :fc:
104 :PROPERTIES:
105 :FC_TYPE: double
106 :ID: d
107 :END:
108 :REVIEW_DATA:
109 | position | ease | box | interval | due |
110 |----------+------+-----+----------+----------------------|
111 | front | 2.50 | 0 | 0.00 | 2026-11-19T00:00:00Z |
112 | back | 2.50 | 0 | 0.00 | 2026-11-18T00:00:00Z |
113 :END:
114 Hund
115 * Cloze {{one}@0} :fc:
116 :PROPERTIES:
117 :FC_TYPE: cloze
118 :FC_CLOZE_TYPE: enumeration
119 :ID: c
120 :END:
121 :REVIEW_DATA:
122 | position | ease | box | interval | due |
123 |----------+------+-----+----------+----------------------|
124 | 0 | 2.50 | 0 | 0.00 | 2026-11-18T00:00:00Z |
125 | 1 | 2.50 | 0 | 0.00 | 2026-11-18T00:00:00Z |
126 | 2 | 2.50 | 0 | 0.00 | 2026-12-30T00:00:00Z |
127 :END:
128 {{two}{hint}@1} and {{three}@2}, not {{four}}.
129 ** More
130 extra
131 * Suspended :suspended:fc:
132 :PROPERTIES:
133 :FC_TYPE: normal
134 :ID: s
135 :END:
136 :REVIEW_DATA:
137 | position | ease | box | interval | due |
138 |----------+------+-----+----------+----------------------|
139 | front | 2.50 | 0 | 0.00 | 2026-11-18T00:00:00Z |
140 :END:
141 * No drawer :fc:
142 :PROPERTIES:
143 :ID: x
144 :END:
145 """
146
147 @Test func readsCardsAndDuePositions() {
148 let cards = Flashcards.cards(in: Self.deck)
149 #expect(cards.map(\.id) == ["n", "d", "c", "s"])
150 #expect(cards[0].positions.map(\.name) == ["front"] && cards[0].positions[0].ease == 2.5 && cards[0].body == "Answer text")
151 #expect(cards[2].clozeType == .enumeration && cards[2].children == "** More\nextra")
152 #expect(cards[3].suspended)
153 let due = Flashcards.due(cards.map { (path: "/a.org", card: $0) }, at: Self.now, shuffle: false).map { "\($0.card.id) \($0.position)" }
154 // One position of the double card (the first due), every due one of the enumeration.
155 #expect(due == ["n front", "d back", "c 0", "c 1"])
156 #expect(Flashcards.dueCount(cards, at: Self.now) == 4)
157 #expect(Flashcards.dueCount(cards, at: Date(timeIntervalSince1970: 0)) == 0)
158 var generator = SeededGenerator(state: testSeed(7))
159 let shuffled = Flashcards.due(cards.map { (path: "/a.org", card: $0) }, at: Self.now, using: &generator).map { "\($0.card.id) \($0.position)" }
160 #expect(Set(shuffled) == Set(due))
161 #expect(shuffled.firstIndex(of: "c 0")! < shuffled.firstIndex(of: "c 1")!)
162 }
163
164 @Test func facesHideWhatOrgFcHides() throws {
165 let cards = Flashcards.cards(in: Self.deck)
166 let normal = try #require(Flashcards.face(cards[0], position: "front"))
167 #expect(normal.front == .init(title: "Normal", text: "") && normal.back.text == "Answer text")
168 let back = try #require(Flashcards.face(cards[1], position: "back"))
169 #expect(back.front.title == nil && back.front.text == "Hund" && back.back.title == "Double")
170 let first = try #require(Flashcards.face(cards[2], position: "1"))
171 #expect(first.front.title == "Cloze one" && first.front.text == "[...hint] and ..., not {{four}}.")
172 #expect(first.back.text == "two and ..., not {{four}}.\n\n** More\nextra")
173 let marked = ("Cloze one\n" + first.back.text) as NSString
174 #expect(marked.substring(with: NSRange(first.back.marks[0])) == "two")
175 var context = cards[2]
176 context.clozeType = .context
177 #expect(Flashcards.face(context, position: "0")?.front.title == "Cloze [...]")
178 #expect(Flashcards.face(context, position: "0")?.front.text == "two and ..., not {{four}}.")
179 context.clozeType = .single
180 #expect(Flashcards.face(context, position: "2")?.front.text == "... and [...], not {{four}}.")
181 #expect(Flashcards.face(cards[2], position: "9") == nil)
182 }
183
184 @Test func textInputComparesTheFirstLine() {
185 let text = "* Q :fc:\n:PROPERTIES:\n:FC_TYPE: text-input\n:ID: t\n:END:\n:REVIEW_DATA:\n| position | due |\n|-+-|\n| front | 2026-11-18T00:00:00Z |\n:END:\nThe *answer* here\nmore\n"
186 let card = Flashcards.cards(in: text)[0]
187 #expect(card.answerLine == "The *answer* here")
188 #expect(Flashcards.face(card, position: "front")?.expected == "answer")
189 #expect(Self.run(MakeFlashcard(.textInput), "* Q\n** Child\n").failed == "The card has no answer line")
190 }
191
192 @Test func historyLinesAsOrgFcWritesThem() {
193 let position = Flashcards.Position(name: "front", values: ["ease": "2.50", "box": "1", "interval": "0.01"])
194 #expect(Flashcards.historyLine(at: Self.now, path: "/n/a.org", id: "x", position: position, rating: .hard, seconds: 4.567)
195 == "2026-11-18T11:06:40Z\t/n/a.org\tx\tfront\t2.50\t1\t0.01\thard\t4.57\tsm2-v1\n")
196 }
197
198 @Test func ratingFindsTheCardByID() {
199 let rated = Self.run(RateFlashcard(card: "d", position: "back", rating: .easy, random: 0.5), Self.deck)
200 #expect(rated.failed == nil)
201 let card = Flashcards.cards(in: rated.text).first { $0.id == "d" }!
202 #expect(card.positions[1].values["box"] == "2" && card.positions[1].values["due"] == "2026-11-19T11:06:40Z")
203 #expect(Self.run(RateFlashcard(card: "gone", position: "front", rating: .good), Self.deck).failed == "The card is no longer in the file")
204 #expect(Self.run(RateFlashcard(card: "n", position: "back", rating: .good), Self.deck).failed == "No review data row found for this position")
205 }
206}
docs/manual/guide/07-agenda.org +1 · view
@@ -734,6 +734,7 @@ On the Mac, orgstar's widgets go on the desktop and in Notification Center: righ
734734| Today | Small, medium and large | The date, the open count, and what's left of today, as on iOS. |
735735| Up Next | Small | The next entry's time or status and title, or the agenda when nothing is left today. |
736736| Habits | Small, medium and large | Each habit's consistency graph, as on iOS. |
737| Flashcards | Small | How many flashcards are due; clicking it opens Review Flashcards. See [[file:16-flashcards.org][Flashcards]]. |
737738
738739Click a row in Today, the Up Next widget or a habit to show that entry in orgstar; click elsewhere to open the agenda. The widgets read the next seven days of the agenda and the habits, which the app writes to =~/Library/Application Support/Orgstar/Widgets= (in the Mac App Store version, =~/Library/Group Containers/group.sh.krz.orgstar/Widgets=) when files, edits or settings change and every hour while it runs; see [[file:14-ios.org][iOS]] for what they show and leave out.
739740
docs/manual/guide/13-configuration.org +2 · view
@@ -229,6 +229,7 @@ These settings have no control in the Settings window. Some are in the View menu
229229| =notes-package=, =denote-directory=, =denote-file-type=, =denote-prompts=, =denote-silo-directories=, =denote-sequence-scheme=, =denote-journal-directory=, =denote-journal-keyword=, =denote-journal-interval=, =denote-journal-title-format= | |
230230| =org-attach-id-dir=, =org-attach-use-inheritance= | |
231231| =org-cite-global-bibliography= | |
232| =org-fc-review-history-file= | |
232233| =org-yank-image-save-method=, =org-yank-dnd-method= | |
233234| =org-crypt-tag-matcher=, =org-crypt-use-before-save-magic= | |
234235| =org-agenda-start-on-weekday= | |
@@ -302,6 +303,7 @@ A key you remove from the file goes back to its default. A key that isn't in the
302303| =org-attach-id-dir= | string | ="data/"= | The folder ID-based attachment folders go in, relative to the org file's folder unless absolute. See [[file:04-outlines.org][Outlines]]. Mirrors =org-attach-id-dir=. |
303304| =org-attach-use-inheritance= | string | ="selective"= | Whether attachment folders come from an ancestor's =DIR= or =ID=: =selective=, ="t"= or ="nil"=. Mirrors =org-attach-use-inheritance=. |
304305| =org-cite-global-bibliography= | string | =""= | Bibliography files, =.bib= or CSL-JSON =.json=, that every file's citations use after its own =#+bibliography:= files, separated by =:=. =~= is your home folder. Insert Citation…, key completion, following citations and export read them. See [[file:09-links.org][Links]]. Mirrors =org-cite-global-bibliography=. |
306| =org-fc-review-history-file= | string | =""= | The file flashcard ratings are added to, in org-fc's format; relative to the configuration folder unless absolute, =~= for your home folder; empty for =org-fc-reviews.tsv= in the configuration folder. See [[file:16-flashcards.org][Flashcards]]. Mirrors =org-fc-review-history-file=. |
305307| =org-yank-image-save-method= | string | ="attach"= | Where a pasted image goes: =attach= for the entry's attachment folder, or a folder, relative to the org file's folder unless absolute. See [[file:09-links.org][Links]]. Mirrors =org-yank-image-save-method=. |
306308| =org-yank-dnd-method= | string | ="ask"= | What dropping files on the editor does: =ask=, =attach=, =open= or =file-link=. See [[file:09-links.org][Links]]. Mirrors =org-yank-dnd-method=. |
307309| =org-crypt-tag-matcher= | string | ="crypt"= | The tag Encrypt Tagged Entries… encrypts. A single tag. See [[file:04-outlines.org][Outlines]]. Mirrors =org-crypt-tag-matcher=. |
docs/manual/guide/14-ios.org +5 −1 · view
@@ -290,7 +290,7 @@ See [[file:07-agenda.org][The agenda]] for the rows, the views and matches, and
290290
291291** Widgets
292292
293orgstar has four widgets. Add them as any widget: touch and hold the Home Screen or the Lock Screen, and choose orgstar in the widget gallery.
293orgstar has five widgets. Add them as any widget: touch and hold the Home Screen or the Lock Screen, and choose orgstar in the widget gallery.
294294
295295| Widget | Sizes | Shows |
296296|--------+----------------------------------------------+---------------------------------------------------------------------------------------------|
@@ -298,6 +298,7 @@ orgstar has four widgets. Add them as any widget: touch and hold the Home Screen
298298| Up Next | Rectangular, inline and circular (Lock Screen) | The next entry's time or status and title (rectangular, inline), or the count of open entries today (circular, and inline when nothing is left) |
299299| Habits | Small, medium and large (Home Screen) | Each habit (=STYLE: habit=) in your agenda files that isn't done, with its consistency graph, as the agenda draws it: the last week (small, 3 habits), or the last three weeks and the next one (medium, 4 habits; large, 9), and how many were done today. |
300300| Capture | Circular and rectangular (Lock Screen) | A button that opens the capture sheet with the template you choose when you edit the widget, or the first template. |
301| Flashcards | Small (Home Screen), circular and inline (Lock Screen) | How many flashcards are due; tapping it starts a review. See [[file:16-flashcards.org][Flashcards]]. |
301302
302303What's left of today is today's entries and calendar events that aren't done, without timed ones that have ended (or started, when they have no end), followed by the overdue entries. The open count is today's entries not done, overdue ones included, without calendar events. The widgets use the theme's colours for the status, the keyword, the priority and the category.
303304
@@ -328,6 +329,7 @@ The widgets and the Live Activity open the app with these links, which also work
328329|----------------------------------------+--------------------------------------------|
329330| =orgstar://agenda= | The Agenda tab |
330331| =orgstar://clock= | The entry of the running clock |
332| =orgstar://review= | Review Flashcards |
331333| ~orgstar://entry?path=/path/file.org&offset=N~ | The file in the reader, at offset N |
332334
333335* Apple Watch
@@ -338,6 +340,8 @@ The watch app shows today's agenda from your iPhone, marks entries done, shows a
338340- Capture :: dictate or scribble text, then Done. It goes to orgstar on iPhone, which opens the capture sheet with it as =%i=, with the first template, as text from the share sheet does; see Capture below.
339341- Overdue, then today :: as the agenda lists them, with the time or status, the title and the keyword. Keywords are red when open, blue for work under way (NEXT and the like), yellow for work on hold (WAIT and the like), green when done and grey when cancelled; an overdue status is red and one due soon orange. Tap an open TODO entry to mark it done: it takes its sequence's first done keyword, as the agenda's Done does. The entry shows done at once; the iPhone changes the file, unless the heading changed since the agenda was sent.
340342
343- Flashcards :: when normal or double flashcards are due, Review /n/ cards shows each one's front, then with Show Answer its back and Again, Hard, Good and Easy. The iPhone writes the rating to the card's file. See [[file:16-flashcards.org][Flashcards]].
344
341345What the watch asks for runs on your iPhone, which iOS wakes for it when orgstar isn't open; while the iPhone is out of reach, the requests wait and run when it is back.
342346
343347** Complications
docs/manual/guide/15-alongside-emacs.org +1 · view
@@ -300,3 +300,4 @@ Other:
300300- org-crypt works with symmetric encryption only (=org-crypt-key= nil); public keys aren't supported. =org-crypt-tag-matcher= is a single tag. =org-crypt-use-before-save-magic= is a setting in =config.toml= rather than a function to call; with it, entries stay decrypted in the editor after a save, where Emacs's buffer holds the messages, and a file whose entries can't be encrypted isn't saved, where Emacs asks for the passphrase. Emacs Import doesn't read the call. =org-crypt-disable-auto-save= has no counterpart: orgstar keeps no auto-save files.
301301- EasyPG's =.gpg= files are read and written with a passphrase only (symmetric); files encrypted to public keys aren't supported. orgstar keeps no passphrase cache beyond the open file; =epa-file-cache-passphrase-for-symmetric-encryption= has no counterpart.
302302- When TODO dependencies refuse a change on a =COMMENT= heading, the heading keeps =COMMENT=. Org removes it before the check and doesn't put it back.
303- org-fc: only the default SM2 algorithm and parameters, review over every folder, no dashboard, audio or vocab cards, and a text-input answer compared as a whole; see Differences from org-fc in [[file:16-flashcards.org][Flashcards]].
docs/manual/guide/16-flashcards.org added +121 · view
@@ -0,0 +1,121 @@
1#+TITLE: Flashcards
2#+DESCRIPTION: Spaced repetition with org-fc's cards: making cards, reviewing them on the Mac, iPhone, iPad and Apple Watch, and the due count widget.
3#+LEDE: orgstar reviews flashcards written in org-fc's format, so the same cards and their schedule work in Emacs.
4
5* Overview
6
7A flashcard is a heading. orgstar reads and writes the format of [[https://github.com/l3kn/org-fc][org-fc]], an Emacs package, so a card made in either one can be reviewed in the other, and a review in either one moves the card's schedule for both. A card is a heading with:
8
9- the tag =fc=;
10- the properties =FC_CREATED= (when it was made), =FC_TYPE= (its type), =FC_ALGO= (=sm2=), and an =ID=;
11- a =REVIEW_DATA= drawer after the property drawer, with a table row for each side or hole that is reviewed (a /position/): its ease, box, interval in days and when it is next due.
12
13#+begin_src org
14,* Capital of France :fc:
15:PROPERTIES:
16:FC_CREATED: 2026-11-18T11:06:40Z
17:FC_TYPE: normal
18:FC_ALGO: sm2
19:ID: 0F3C2A1E-6B8D-4E3A-9B4F-2D1C0A9E8B7F
20:END:
21:REVIEW_DATA:
22| position | ease | box | interval | due |
23|----------+------+-----+----------+----------------------|
24| front | 2.50 | 0 | 0.00 | 2026-11-18T11:06:40Z |
25:END:
26Paris
27#+end_src
28
29Times are in UTC, as org-fc writes them. You don't write any of this by hand: the commands below add it to a heading.
30
31* Making cards
32
33Put the caret in a heading and run one of these commands from the command palette (=⇧⌘P=) on the Mac, or Commands in the editor on iOS. Each does what the org-fc command of the same name does.
34
35| Command | org-fc | The card |
36|------------------------------+---------------------------------+----------------------------------------------------------------------------------------------|
37| Make Normal Flashcard | =org-fc-type-normal-init= | The heading is the question, the text under it the answer. One position, =front=. |
38| Make Double Flashcard | =org-fc-type-double-init= | Reviewed both ways: the heading asks for the text, and the text for the heading. Positions =front= and =back=. |
39| Make Cloze Flashcard… | =org-fc-type-cloze-init= | Holes in the text, each reviewed on its own. Asks for the cloze type. |
40| Make Text-Input Flashcard | =org-fc-type-text-input-init= | You type the answer, which is compared with the first line of the text. One position. |
41| Update Flashcard | =org-fc-update= | A cloze card's new holes get numbers and review data; holes removed lose theirs. |
42| Suspend Flashcard | =org-fc-suspend-card= | Tags the card =suspended=, which leaves it out of reviews. |
43| Unsuspend Flashcard | =org-fc-unsuspend-card= | Removes the =suspended= tag. |
44
45A heading that is already a card is refused, and so is a text-input card with nothing to compare with (a heading followed directly by a subheading).
46
47** The back of a card
48
49A subheading titled =Back= holds the answer instead of the text under the heading. With one, the front of a normal card shows the heading and its text, and the back adds the =Back= subheading. A double card's back position shows the =Back= text as the question.
50
51#+begin_src org
52,* Two sided :fc:
53...
54Front text
55,** Back
56Back text
57#+end_src
58
59** Cloze holes
60
61A hole is ={{text}}=, or ={{text}{hint}}= with a hint shown while it is hidden. Make Cloze Flashcard… and Update Flashcard number the holes: ={{text}@0}=, ={{text}{hint}@1}=. Holes may contain LaTeX between =$= signs. The cloze type decides which other holes are hidden while one is reviewed:
62
63| Type | While one hole is reviewed | Positions reviewed in one session |
64|-------------+---------------------------------------------------------+-----------------------------------|
65| deletion | the other holes show | one |
66| enumeration | the holes before it show, the ones after it are hidden | every due one |
67| context | the holes next to it show, the others are hidden | one |
68| single | every other hole is hidden | every due one |
69
70A hidden hole shows as =...=; the one being reviewed as =[...]=, or =[...hint]=.
71
72* Reviewing
73
74Review Flashcards shows the positions due across all your folders, one at a time, in random order (=org-fc-review= with =org-fc-shuffle-positions=). As in org-fc, suspended cards are left out, and of a normal or double card, or a deletion or context cloze card, only one position is shown per review.
75
76- On the Mac: Window ▸ Review Flashcards, or Review Flashcards in the command palette.
77- On iPhone and iPad: Review Flashcards in the agenda's Views menu or in Commands, Go ▸ Review Flashcards in the iPad menu bar, or the Flashcards widget.
78
79Each card shows its front. Show Answer flips it; a text-input card has a field for your answer and Check instead, then shows whether it matched. Then rate how well you knew it:
80
81| Button | Key on the Mac | Means |
82|--------+----------------+---------------------------|
83| Again | =a= | You didn't know it |
84| Hard | =h= | You knew it with effort |
85| Good | =g= | You knew it |
86| Easy | =e= | You knew it at once |
87
88Return also shows the answer. A card rated Again comes back at the end of the review. The menu at the top of the card has Open in Editor, which shows the card's heading, and Suspend Card, which tags it =suspended= and takes its other positions out of the review.
89
90Rating writes the position's new row into the card's =REVIEW_DATA= table. In a file that is open, the change is an edit like any other, which Undo takes back; a file that isn't open is saved at once.
91
92** Scheduling
93
94orgstar schedules as org-fc does by default (=org-fc-algorithm= =sm2-v1=, a variant of SM-2):
95
96- A new position starts in box 0 with ease 2.50, due at once.
97- Again sends a position back to box 0. Every other rating moves it up one box; Easy in box 0 moves it straight to box 2.
98- Boxes 0 to 3 have fixed intervals: 0, 0.01, 1 and 6 days.
99- From box 2 on, each rating changes the ease, by −0.30 (Again), −0.15 (Hard), 0 (Good) or +0.15 (Easy), kept between 1.30 and 5.00.
100- From box 4 on, the interval is the ease times the last interval, multiplied by a random factor between 0.9 and 1.1 so that cards made together don't stay together.
101
102** The review history
103
104Each rating is also added as a line to the review history, in the tab-separated format org-fc writes to =org-fc-review-history-file=: the time, the file, the card's ID, the position, its ease, box and interval before the rating, the rating, the seconds the card was shown, and =sm2-v1=. orgstar writes it to =org-fc-reviews.tsv= in the configuration folder; set =org-fc-review-history-file= in =config.toml= to use another file, such as the one Emacs writes (see [[file:13-configuration.org][Configuration]]). The history is only written; orgstar doesn't show statistics from it.
105
106* Widgets and Apple Watch
107
108The Flashcards widget shows how many positions are due, counting as a review would, and goes up by itself as cards fall due. It comes in small on the Home Screen and the Mac desktop, and circular and inline on the Lock Screen. Tapping it starts a review. Like the other widgets it needs orgstar+, and it counts what the app last wrote: when files or edits change while orgstar is open and when you return to it. See [[file:14-ios.org][iPhone and iPad]].
109
110The watch app reviews normal and double cards. When any are due, its list has Review /n/ cards above today's agenda: tap it for the first card's front, Show Answer for the back, then Again, Hard, Good or Easy. The iPhone writes the rating to the card's file, as a review on the iPhone does. The watch gets up to 30 due positions with the agenda; cloze and text-input cards are left to the iPhone and the Mac.
111
112Reviewing cards is free. The widget and the watch app need orgstar+, as all widgets and the watch app do.
113
114* Differences from org-fc
115
116- Only org-fc's default SM2 algorithm with its default parameters is used. Cards with =FC_ALGO= set to another algorithm (=fsrs=, =noop=) are refused when rated; the =FC_SM2_*= properties that change the parameters for a card or a subtree are not read, and =org-fc-algorithm= =sm2-v2= is not supported.
117- Review covers every folder you added; there are no review contexts (=org-fc-custom-contexts=), filters, =org-fc-directories= or =org-fc-review-early=.
118- The card is shown on a review screen, not in the file: drawers and planning lines are hidden, the rest shows as written. The =noheading= and =notitle= tags, =org-fc-drawer-whitelist= and LaTeX previews in cards are not supported.
119- A text-input answer is compared as a whole, not character by character as =org-fc-diff= does.
120- There is no dashboard, no audio (=org-fc-audio=), no vocab cards, no =org-fc-cloze-dwim= and no Edit/Skip during a review; Open in Editor leaves the review where it was.
121- Unsuspend Flashcard acts on the card the caret is in, from any of its subheadings, as Suspend Flashcard does; org-fc's acts on the heading at point.
docs/manual/index.org +1 · view
@@ -36,6 +36,7 @@ reminders, export and tangling.
363613. [[file:guide/13-configuration.org][Configuration]]
373714. [[file:guide/14-ios.org][iPhone and iPad]]
383815. [[file:guide/15-alongside-emacs.org][Working alongside Emacs and other tools]]
3916. [[file:guide/16-flashcards.org][Flashcards]]
3940
4041* Principles
4142
l10n/Localizable.xcstrings +1370 · view
@@ -1820,6 +1820,40 @@
18201820 }
18211821 }
18221822 },
1823 "%lld cards due": {
1824 "localizations": {
1825 "de": {
1826 "stringUnit": {
1827 "state": "translated",
1828 "value": "%lld Karten fällig"
1829 }
1830 },
1831 "es": {
1832 "stringUnit": {
1833 "state": "translated",
1834 "value": "%lld tarjetas pendientes"
1835 }
1836 },
1837 "fr": {
1838 "stringUnit": {
1839 "state": "translated",
1840 "value": "%lld fiches à réviser"
1841 }
1842 },
1843 "ja": {
1844 "stringUnit": {
1845 "state": "translated",
1846 "value": "復習 %lld 枚"
1847 }
1848 },
1849 "pt-BR": {
1850 "stringUnit": {
1851 "state": "translated",
1852 "value": "%lld cartões pendentes"
1853 }
1854 }
1855 }
1856 },
18231857 "%lld columns": {
18241858 "localizations": {
18251859 "de": {
@@ -1955,6 +1989,40 @@
19551989 }
19561990 }
19571991 },
1992 "%lld left": {
1993 "localizations": {
1994 "de": {
1995 "stringUnit": {
1996 "state": "translated",
1997 "value": "Noch %lld"
1998 }
1999 },
2000 "es": {
2001 "stringUnit": {
2002 "state": "translated",
2003 "value": "Quedan %lld"
2004 }
2005 },
2006 "fr": {
2007 "stringUnit": {
2008 "state": "translated",
2009 "value": "%lld restantes"
2010 }
2011 },
2012 "ja": {
2013 "stringUnit": {
2014 "state": "translated",
2015 "value": "残り %lld"
2016 }
2017 },
2018 "pt-BR": {
2019 "stringUnit": {
2020 "state": "translated",
2021 "value": "Faltam %lld"
2022 }
2023 }
2024 }
2025 },
19582026 "%lld lines, %lld words, %lld chars": {
19592027 "localizations": {
19602028 "de": {
@@ -2916,6 +2984,40 @@
29162984 }
29172985 }
29182986 },
2987 "%lld reviewed. Nothing else is due.": {
2988 "localizations": {
2989 "de": {
2990 "stringUnit": {
2991 "state": "translated",
2992 "value": "%lld wiederholt. Sonst ist nichts fällig."
2993 }
2994 },
2995 "es": {
2996 "stringUnit": {
2997 "state": "translated",
2998 "value": "%lld repasadas. No queda nada pendiente."
2999 }
3000 },
3001 "fr": {
3002 "stringUnit": {
3003 "state": "translated",
3004 "value": "%lld révisées. Plus rien à réviser."
3005 }
3006 },
3007 "ja": {
3008 "stringUnit": {
3009 "state": "translated",
3010 "value": "%lld 枚を復習しました。ほかに復習するものはありません。"
3011 }
3012 },
3013 "pt-BR": {
3014 "stringUnit": {
3015 "state": "translated",
3016 "value": "%lld revisados. Nada mais pendente."
3017 }
3018 }
3019 }
3020 },
29193021 "%lld selected": {
29203022 "localizations": {
29213023 "de": {
@@ -5019,6 +5121,40 @@
50195121 }
50205122 }
50215123 },
5124 "Again": {
5125 "localizations": {
5126 "de": {
5127 "stringUnit": {
5128 "state": "translated",
5129 "value": "Nochmal"
5130 }
5131 },
5132 "es": {
5133 "stringUnit": {
5134 "state": "translated",
5135 "value": "Otra vez"
5136 }
5137 },
5138 "fr": {
5139 "stringUnit": {
5140 "state": "translated",
5141 "value": "À revoir"
5142 }
5143 },
5144 "ja": {
5145 "stringUnit": {
5146 "state": "translated",
5147 "value": "もう一度"
5148 }
5149 },
5150 "pt-BR": {
5151 "stringUnit": {
5152 "state": "translated",
5153 "value": "De novo"
5154 }
5155 }
5156 }
5157 },
50225158 "Agenda": {
50235159 "comment": "Command title",
50245160 "localizations": {
@@ -8350,6 +8486,41 @@
83508486 }
83518487 }
83528488 },
8489 "Can't add to the review history: %@": {
8490 "comment": "Flashcard review",
8491 "localizations": {
8492 "de": {
8493 "stringUnit": {
8494 "state": "translated",
8495 "value": "Kann nicht zum Wiederholungsverlauf hinzufügen: %@"
8496 }
8497 },
8498 "es": {
8499 "stringUnit": {
8500 "state": "translated",
8501 "value": "No se puede añadir al historial de repasos: %@"
8502 }
8503 },
8504 "fr": {
8505 "stringUnit": {
8506 "state": "translated",
8507 "value": "Impossible d'ajouter à l'historique des révisions : %@"
8508 }
8509 },
8510 "ja": {
8511 "stringUnit": {
8512 "state": "translated",
8513 "value": "復習履歴に追加できません: %@"
8514 }
8515 },
8516 "pt-BR": {
8517 "stringUnit": {
8518 "state": "translated",
8519 "value": "Não é possível adicionar ao histórico de revisões: %@"
8520 }
8521 }
8522 }
8523 },
83538524 "Can't continue %@: it isn't in “%@” on this device yet.": {
83548525 "comment": "Handoff from another device",
83558526 "localizations": {
@@ -9489,6 +9660,40 @@
94899660 }
94909661 }
94919662 },
9663 "Card Actions": {
9664 "localizations": {
9665 "de": {
9666 "stringUnit": {
9667 "state": "translated",
9668 "value": "Kartenaktionen"
9669 }
9670 },
9671 "es": {
9672 "stringUnit": {
9673 "state": "translated",
9674 "value": "Acciones de la tarjeta"
9675 }
9676 },
9677 "fr": {
9678 "stringUnit": {
9679 "state": "translated",
9680 "value": "Actions de la fiche"
9681 }
9682 },
9683 "ja": {
9684 "stringUnit": {
9685 "state": "translated",
9686 "value": "カードの操作"
9687 }
9688 },
9689 "pt-BR": {
9690 "stringUnit": {
9691 "state": "translated",
9692 "value": "Ações do Cartão"
9693 }
9694 }
9695 }
9696 },
94929697 "Categories": {
94939698 "localizations": {
94949699 "de": {
@@ -9659,6 +9864,40 @@
96599864 }
96609865 }
96619866 },
9867 "Check": {
9868 "localizations": {
9869 "de": {
9870 "stringUnit": {
9871 "state": "translated",
9872 "value": "Prüfen"
9873 }
9874 },
9875 "es": {
9876 "stringUnit": {
9877 "state": "translated",
9878 "value": "Comprobar"
9879 }
9880 },
9881 "fr": {
9882 "stringUnit": {
9883 "state": "translated",
9884 "value": "Vérifier"
9885 }
9886 },
9887 "ja": {
9888 "stringUnit": {
9889 "state": "translated",
9890 "value": "確認"
9891 }
9892 },
9893 "pt-BR": {
9894 "stringUnit": {
9895 "state": "translated",
9896 "value": "Verificar"
9897 }
9898 }
9899 }
9900 },
96629901 "Check Again": {
96639902 "comment": "Lint All Folders: runs the checks again",
96649903 "localizations": {
@@ -12970,6 +13209,40 @@
1297013209 }
1297113210 }
1297213211 },
13212 "Correct": {
13213 "localizations": {
13214 "de": {
13215 "stringUnit": {
13216 "state": "translated",
13217 "value": "Richtig"
13218 }
13219 },
13220 "es": {
13221 "stringUnit": {
13222 "state": "translated",
13223 "value": "Correcto"
13224 }
13225 },
13226 "fr": {
13227 "stringUnit": {
13228 "state": "translated",
13229 "value": "Correct"
13230 }
13231 },
13232 "ja": {
13233 "stringUnit": {
13234 "state": "translated",
13235 "value": "正解"
13236 }
13237 },
13238 "pt-BR": {
13239 "stringUnit": {
13240 "state": "translated",
13241 "value": "Correto"
13242 }
13243 }
13244 }
13245 },
1297313246 "Couldn't Add Folder": {
1297413247 "comment": "Error alert title",
1297513248 "localizations": {
@@ -16046,6 +16319,40 @@
1604616319 }
1604716320 }
1604816321 },
16322 "Easy": {
16323 "localizations": {
16324 "de": {
16325 "stringUnit": {
16326 "state": "translated",
16327 "value": "Leicht"
16328 }
16329 },
16330 "es": {
16331 "stringUnit": {
16332 "state": "translated",
16333 "value": "Fácil"
16334 }
16335 },
16336 "fr": {
16337 "stringUnit": {
16338 "state": "translated",
16339 "value": "Facile"
16340 }
16341 },
16342 "ja": {
16343 "stringUnit": {
16344 "state": "translated",
16345 "value": "簡単"
16346 }
16347 },
16348 "pt-BR": {
16349 "stringUnit": {
16350 "state": "translated",
16351 "value": "Fácil"
16352 }
16353 }
16354 }
16355 },
1604916356 "Edit": {
1605016357 "localizations": {
1605116358 "de": {
@@ -17899,6 +18206,40 @@
1789918206 }
1790018207 }
1790118208 },
18209 "Expected: %@": {
18210 "localizations": {
18211 "de": {
18212 "stringUnit": {
18213 "state": "translated",
18214 "value": "Erwartet: %@"
18215 }
18216 },
18217 "es": {
18218 "stringUnit": {
18219 "state": "translated",
18220 "value": "Esperado: %@"
18221 }
18222 },
18223 "fr": {
18224 "stringUnit": {
18225 "state": "translated",
18226 "value": "Attendu : %@"
18227 }
18228 },
18229 "ja": {
18230 "stringUnit": {
18231 "state": "translated",
18232 "value": "正答: %@"
18233 }
18234 },
18235 "pt-BR": {
18236 "stringUnit": {
18237 "state": "translated",
18238 "value": "Esperado: %@"
18239 }
18240 }
18241 }
18242 },
1790218243 "Export": {
1790318244 "localizations": {
1790418245 "de": {
@@ -20171,6 +20512,74 @@
2017120512 }
2017220513 }
2017320514 },
20515 "Flashcards": {
20516 "localizations": {
20517 "de": {
20518 "stringUnit": {
20519 "state": "translated",
20520 "value": "Lernkarten"
20521 }
20522 },
20523 "es": {
20524 "stringUnit": {
20525 "state": "translated",
20526 "value": "Tarjetas"
20527 }
20528 },
20529 "fr": {
20530 "stringUnit": {
20531 "state": "translated",
20532 "value": "Fiches"
20533 }
20534 },
20535 "ja": {
20536 "stringUnit": {
20537 "state": "translated",
20538 "value": "フラッシュカード"
20539 }
20540 },
20541 "pt-BR": {
20542 "stringUnit": {
20543 "state": "translated",
20544 "value": "Flashcards"
20545 }
20546 }
20547 }
20548 },
20549 "Flashcards are headings tagged fc, in org-fc's format. Make one with Make Normal Flashcard or another Make Flashcard command.": {
20550 "localizations": {
20551 "de": {
20552 "stringUnit": {
20553 "state": "translated",
20554 "value": "Lernkarten sind Überschriften mit dem Tag fc im Format von org-fc. Erstelle eine mit „Normale Lernkarte erstellen“ oder einem anderen Befehl zum Erstellen von Lernkarten."
20555 }
20556 },
20557 "es": {
20558 "stringUnit": {
20559 "state": "translated",
20560 "value": "Las tarjetas son encabezados con la etiqueta fc, en el formato de org-fc. Crea una con Crear tarjeta normal u otra orden para crear tarjetas."
20561 }
20562 },
20563 "fr": {
20564 "stringUnit": {
20565 "state": "translated",
20566 "value": "Les fiches sont des titres portant l'étiquette fc, au format d'org-fc. Créez-en une avec Créer une fiche normale ou une autre commande de création de fiche."
20567 }
20568 },
20569 "ja": {
20570 "stringUnit": {
20571 "state": "translated",
20572 "value": "フラッシュカードは、タグ fc の付いた見出しで、org-fc の形式です。「通常のフラッシュカードにする」などのコマンドで作成します。"
20573 }
20574 },
20575 "pt-BR": {
20576 "stringUnit": {
20577 "state": "translated",
20578 "value": "Flashcards são títulos com a etiqueta fc, no formato do org-fc. Crie um com Criar Flashcard Normal ou outro comando de criar flashcard."
20579 }
20580 }
20581 }
20582 },
2017420583 "Fold": {
2017520584 "comment": "Key bar button",
2017620585 "localizations": {
@@ -21412,6 +21821,40 @@
2141221821 }
2141321822 }
2141421823 },
21824 "Good": {
21825 "localizations": {
21826 "de": {
21827 "stringUnit": {
21828 "state": "translated",
21829 "value": "Gut"
21830 }
21831 },
21832 "es": {
21833 "stringUnit": {
21834 "state": "translated",
21835 "value": "Bien"
21836 }
21837 },
21838 "fr": {
21839 "stringUnit": {
21840 "state": "translated",
21841 "value": "Bien"
21842 }
21843 },
21844 "ja": {
21845 "stringUnit": {
21846 "state": "translated",
21847 "value": "普通"
21848 }
21849 },
21850 "pt-BR": {
21851 "stringUnit": {
21852 "state": "translated",
21853 "value": "Bom"
21854 }
21855 }
21856 }
21857 },
2141521858 "Goto:": {
2141621859 "comment": "Echo area prompt for a refile target to go to",
2141721860 "localizations": {
@@ -21687,6 +22130,40 @@
2168722130 }
2168822131 }
2168922132 },
22133 "Hard": {
22134 "localizations": {
22135 "de": {
22136 "stringUnit": {
22137 "state": "translated",
22138 "value": "Schwer"
22139 }
22140 },
22141 "es": {
22142 "stringUnit": {
22143 "state": "translated",
22144 "value": "Difícil"
22145 }
22146 },
22147 "fr": {
22148 "stringUnit": {
22149 "state": "translated",
22150 "value": "Difficile"
22151 }
22152 },
22153 "ja": {
22154 "stringUnit": {
22155 "state": "translated",
22156 "value": "難しい"
22157 }
22158 },
22159 "pt-BR": {
22160 "stringUnit": {
22161 "state": "translated",
22162 "value": "Difícil"
22163 }
22164 }
22165 }
22166 },
2169022167 "Have its letters in order, best first": {
2169122168 "localizations": {
2169222169 "de": {
@@ -22338,6 +22815,40 @@
2233822815 }
2233922816 }
2234022817 },
22818 "How many flashcards are due for review.": {
22819 "localizations": {
22820 "de": {
22821 "stringUnit": {
22822 "state": "translated",
22823 "value": "Wie viele Lernkarten zur Wiederholung fällig sind."
22824 }
22825 },
22826 "es": {
22827 "stringUnit": {
22828 "state": "translated",
22829 "value": "Cuántas tarjetas hay pendientes de repaso."
22830 }
22831 },
22832 "fr": {
22833 "stringUnit": {
22834 "state": "translated",
22835 "value": "Le nombre de fiches à réviser."
22836 }
22837 },
22838 "ja": {
22839 "stringUnit": {
22840 "state": "translated",
22841 "value": "復習するフラッシュカードの枚数。"
22842 }
22843 },
22844 "pt-BR": {
22845 "stringUnit": {
22846 "state": "translated",
22847 "value": "Quantos flashcards estão pendentes de revisão."
22848 }
22849 }
22850 }
22851 },
2234122852 "Ignore case when the search is lower case": {
2234222853 "comment": "Replace in Files: case-fold-search",
2234322854 "localizations": {
@@ -26799,6 +27310,146 @@
2679927310 }
2680027311 }
2680127312 },
27313 "Make Cloze Flashcard…": {
27314 "comment": "Command title",
27315 "localizations": {
27316 "de": {
27317 "stringUnit": {
27318 "state": "translated",
27319 "value": "Lückentext-Lernkarte erstellen…"
27320 }
27321 },
27322 "es": {
27323 "stringUnit": {
27324 "state": "translated",
27325 "value": "Crear tarjeta de huecos…"
27326 }
27327 },
27328 "fr": {
27329 "stringUnit": {
27330 "state": "translated",
27331 "value": "Créer une fiche à trous…"
27332 }
27333 },
27334 "ja": {
27335 "stringUnit": {
27336 "state": "translated",
27337 "value": "穴埋めフラッシュカードにする…"
27338 }
27339 },
27340 "pt-BR": {
27341 "stringUnit": {
27342 "state": "translated",
27343 "value": "Criar Flashcard de Lacunas…"
27344 }
27345 }
27346 }
27347 },
27348 "Make Double Flashcard": {
27349 "comment": "Command title",
27350 "localizations": {
27351 "de": {
27352 "stringUnit": {
27353 "state": "translated",
27354 "value": "Doppelseitige Lernkarte erstellen"
27355 }
27356 },
27357 "es": {
27358 "stringUnit": {
27359 "state": "translated",
27360 "value": "Crear tarjeta doble"
27361 }
27362 },
27363 "fr": {
27364 "stringUnit": {
27365 "state": "translated",
27366 "value": "Créer une fiche double"
27367 }
27368 },
27369 "ja": {
27370 "stringUnit": {
27371 "state": "translated",
27372 "value": "両面フラッシュカードにする"
27373 }
27374 },
27375 "pt-BR": {
27376 "stringUnit": {
27377 "state": "translated",
27378 "value": "Criar Flashcard Duplo"
27379 }
27380 }
27381 }
27382 },
27383 "Make Normal Flashcard": {
27384 "comment": "Command title",
27385 "localizations": {
27386 "de": {
27387 "stringUnit": {
27388 "state": "translated",
27389 "value": "Normale Lernkarte erstellen"
27390 }
27391 },
27392 "es": {
27393 "stringUnit": {
27394 "state": "translated",
27395 "value": "Crear tarjeta normal"
27396 }
27397 },
27398 "fr": {
27399 "stringUnit": {
27400 "state": "translated",
27401 "value": "Créer une fiche normale"
27402 }
27403 },
27404 "ja": {
27405 "stringUnit": {
27406 "state": "translated",
27407 "value": "通常のフラッシュカードにする"
27408 }
27409 },
27410 "pt-BR": {
27411 "stringUnit": {
27412 "state": "translated",
27413 "value": "Criar Flashcard Normal"
27414 }
27415 }
27416 }
27417 },
27418 "Make Text-Input Flashcard": {
27419 "comment": "Command title",
27420 "localizations": {
27421 "de": {
27422 "stringUnit": {
27423 "state": "translated",
27424 "value": "Eingabe-Lernkarte erstellen"
27425 }
27426 },
27427 "es": {
27428 "stringUnit": {
27429 "state": "translated",
27430 "value": "Crear tarjeta de respuesta escrita"
27431 }
27432 },
27433 "fr": {
27434 "stringUnit": {
27435 "state": "translated",
27436 "value": "Créer une fiche à saisie"
27437 }
27438 },
27439 "ja": {
27440 "stringUnit": {
27441 "state": "translated",
27442 "value": "入力式フラッシュカードにする"
27443 }
27444 },
27445 "pt-BR": {
27446 "stringUnit": {
27447 "state": "translated",
27448 "value": "Criar Flashcard de Digitação"
27449 }
27450 }
27451 }
27452 },
2680227453 "Makes notes.org in a folder you choose or make in iCloud Drive and adds the folder": {
2680327454 "localizations": {
2680427455 "de": {
@@ -30180,6 +30831,40 @@
3018030831 }
3018130832 }
3018230833 },
30834 "No Cards Due": {
30835 "localizations": {
30836 "de": {
30837 "stringUnit": {
30838 "state": "translated",
30839 "value": "Keine Karten fällig"
30840 }
30841 },
30842 "es": {
30843 "stringUnit": {
30844 "state": "translated",
30845 "value": "No hay tarjetas pendientes"
30846 }
30847 },
30848 "fr": {
30849 "stringUnit": {
30850 "state": "translated",
30851 "value": "Aucune fiche à réviser"
30852 }
30853 },
30854 "ja": {
30855 "stringUnit": {
30856 "state": "translated",
30857 "value": "復習するカードはありません"
30858 }
30859 },
30860 "pt-BR": {
30861 "stringUnit": {
30862 "state": "translated",
30863 "value": "Nenhum cartão pendente"
30864 }
30865 }
30866 }
30867 },
3018330868 "No Clocked Time": {
3018430869 "localizations": {
3018530870 "de": {
@@ -32167,6 +32852,40 @@
3216732852 }
3216832853 }
3216932854 },
32855 "Not quite": {
32856 "localizations": {
32857 "de": {
32858 "stringUnit": {
32859 "state": "translated",
32860 "value": "Nicht ganz"
32861 }
32862 },
32863 "es": {
32864 "stringUnit": {
32865 "state": "translated",
32866 "value": "No del todo"
32867 }
32868 },
32869 "fr": {
32870 "stringUnit": {
32871 "state": "translated",
32872 "value": "Pas tout à fait"
32873 }
32874 },
32875 "ja": {
32876 "stringUnit": {
32877 "state": "translated",
32878 "value": "惜しい"
32879 }
32880 },
32881 "pt-BR": {
32882 "stringUnit": {
32883 "state": "translated",
32884 "value": "Não exatamente"
32885 }
32886 }
32887 }
32888 },
3217032889 "Not recalculated": {
3217132890 "localizations": {
3217232891 "de": {
@@ -32304,6 +33023,74 @@
3230433023 }
3230533024 }
3230633025 },
33026 "Nothing due": {
33027 "localizations": {
33028 "de": {
33029 "stringUnit": {
33030 "state": "translated",
33031 "value": "Nichts fällig"
33032 }
33033 },
33034 "es": {
33035 "stringUnit": {
33036 "state": "translated",
33037 "value": "Nada pendiente"
33038 }
33039 },
33040 "fr": {
33041 "stringUnit": {
33042 "state": "translated",
33043 "value": "Rien à réviser"
33044 }
33045 },
33046 "ja": {
33047 "stringUnit": {
33048 "state": "translated",
33049 "value": "復習なし"
33050 }
33051 },
33052 "pt-BR": {
33053 "stringUnit": {
33054 "state": "translated",
33055 "value": "Nada pendente"
33056 }
33057 }
33058 }
33059 },
33060 "Nothing else is due.": {
33061 "localizations": {
33062 "de": {
33063 "stringUnit": {
33064 "state": "translated",
33065 "value": "Sonst ist nichts fällig."
33066 }
33067 },
33068 "es": {
33069 "stringUnit": {
33070 "state": "translated",
33071 "value": "No queda nada pendiente."
33072 }
33073 },
33074 "fr": {
33075 "stringUnit": {
33076 "state": "translated",
33077 "value": "Plus rien à réviser."
33078 }
33079 },
33080 "ja": {
33081 "stringUnit": {
33082 "state": "translated",
33083 "value": "ほかに復習するものはありません。"
33084 }
33085 },
33086 "pt-BR": {
33087 "stringUnit": {
33088 "state": "translated",
33089 "value": "Nada mais pendente."
33090 }
33091 }
33092 }
33093 },
3230733094 "Nothing in the agenda files matches this view.": {
3230833095 "localizations": {
3230933096 "de": {
@@ -33742,6 +34529,40 @@
3374234529 }
3374334530 }
3374434531 },
34532 "Open in Editor": {
34533 "localizations": {
34534 "de": {
34535 "stringUnit": {
34536 "state": "translated",
34537 "value": "Im Editor öffnen"
34538 }
34539 },
34540 "es": {
34541 "stringUnit": {
34542 "state": "translated",
34543 "value": "Abrir en el editor"
34544 }
34545 },
34546 "fr": {
34547 "stringUnit": {
34548 "state": "translated",
34549 "value": "Ouvrir dans l'éditeur"
34550 }
34551 },
34552 "ja": {
34553 "stringUnit": {
34554 "state": "translated",
34555 "value": "エディタで開く"
34556 }
34557 },
34558 "pt-BR": {
34559 "stringUnit": {
34560 "state": "translated",
34561 "value": "Abrir no Editor"
34562 }
34563 }
34564 }
34565 },
3374534566 "Open in File": {
3374634567 "localizations": {
3374734568 "de": {
@@ -33844,6 +34665,40 @@
3384434665 }
3384534666 }
3384634667 },
34668 "Open orgstar to count your cards here.": {
34669 "localizations": {
34670 "de": {
34671 "stringUnit": {
34672 "state": "translated",
34673 "value": "Öffne orgstar, um hier deine Karten zu zählen."
34674 }
34675 },
34676 "es": {
34677 "stringUnit": {
34678 "state": "translated",
34679 "value": "Abre orgstar para contar aquí tus tarjetas."
34680 }
34681 },
34682 "fr": {
34683 "stringUnit": {
34684 "state": "translated",
34685 "value": "Ouvrez orgstar pour compter vos fiches ici."
34686 }
34687 },
34688 "ja": {
34689 "stringUnit": {
34690 "state": "translated",
34691 "value": "ここでカードを数えるには、orgstarを開いてください。"
34692 }
34693 },
34694 "pt-BR": {
34695 "stringUnit": {
34696 "state": "translated",
34697 "value": "Abra o orgstar para contar seus cartões aqui."
34698 }
34699 }
34700 }
34701 },
3384734702 "Open orgstar to show your agenda here.": {
3384834703 "localizations": {
3384934704 "de": {
@@ -40014,6 +40869,143 @@
4001440869 }
4001540870 }
4001640871 },
40872 "Review": {
40873 "localizations": {
40874 "de": {
40875 "stringUnit": {
40876 "state": "translated",
40877 "value": "Wiederholen"
40878 }
40879 },
40880 "es": {
40881 "stringUnit": {
40882 "state": "translated",
40883 "value": "Repaso"
40884 }
40885 },
40886 "fr": {
40887 "stringUnit": {
40888 "state": "translated",
40889 "value": "Révision"
40890 }
40891 },
40892 "ja": {
40893 "stringUnit": {
40894 "state": "translated",
40895 "value": "復習"
40896 }
40897 },
40898 "pt-BR": {
40899 "stringUnit": {
40900 "state": "translated",
40901 "value": "Revisão"
40902 }
40903 }
40904 }
40905 },
40906 "Review %lld cards": {
40907 "localizations": {
40908 "de": {
40909 "stringUnit": {
40910 "state": "translated",
40911 "value": "%lld Karten wiederholen"
40912 }
40913 },
40914 "es": {
40915 "stringUnit": {
40916 "state": "translated",
40917 "value": "Repasar %lld tarjetas"
40918 }
40919 },
40920 "fr": {
40921 "stringUnit": {
40922 "state": "translated",
40923 "value": "Réviser %lld fiches"
40924 }
40925 },
40926 "ja": {
40927 "stringUnit": {
40928 "state": "translated",
40929 "value": "%lld 枚を復習"
40930 }
40931 },
40932 "pt-BR": {
40933 "stringUnit": {
40934 "state": "translated",
40935 "value": "Revisar %lld cartões"
40936 }
40937 }
40938 }
40939 },
40940 "Review Done": {
40941 "localizations": {
40942 "de": {
40943 "stringUnit": {
40944 "state": "translated",
40945 "value": "Wiederholung fertig"
40946 }
40947 },
40948 "es": {
40949 "stringUnit": {
40950 "state": "translated",
40951 "value": "Repaso terminado"
40952 }
40953 },
40954 "fr": {
40955 "stringUnit": {
40956 "state": "translated",
40957 "value": "Révision terminée"
40958 }
40959 },
40960 "ja": {
40961 "stringUnit": {
40962 "state": "translated",
40963 "value": "復習完了"
40964 }
40965 },
40966 "pt-BR": {
40967 "stringUnit": {
40968 "state": "translated",
40969 "value": "Revisão concluída"
40970 }
40971 }
40972 }
40973 },
40974 "Review Flashcards": {
40975 "comment": "Command title",
40976 "localizations": {
40977 "de": {
40978 "stringUnit": {
40979 "state": "translated",
40980 "value": "Lernkarten wiederholen"
40981 }
40982 },
40983 "es": {
40984 "stringUnit": {
40985 "state": "translated",
40986 "value": "Repasar tarjetas"
40987 }
40988 },
40989 "fr": {
40990 "stringUnit": {
40991 "state": "translated",
40992 "value": "Réviser les fiches"
40993 }
40994 },
40995 "ja": {
40996 "stringUnit": {
40997 "state": "translated",
40998 "value": "フラッシュカードを復習"
40999 }
41000 },
41001 "pt-BR": {
41002 "stringUnit": {
41003 "state": "translated",
41004 "value": "Revisar Flashcards"
41005 }
41006 }
41007 }
41008 },
4001741009 "Right Option": {
4001841010 "localizations": {
4001941011 "de": {
@@ -42903,6 +43895,40 @@
4290343895 }
4290443896 }
4290543897 },
43898 "Show Answer": {
43899 "localizations": {
43900 "de": {
43901 "stringUnit": {
43902 "state": "translated",
43903 "value": "Antwort zeigen"
43904 }
43905 },
43906 "es": {
43907 "stringUnit": {
43908 "state": "translated",
43909 "value": "Mostrar respuesta"
43910 }
43911 },
43912 "fr": {
43913 "stringUnit": {
43914 "state": "translated",
43915 "value": "Afficher la réponse"
43916 }
43917 },
43918 "ja": {
43919 "stringUnit": {
43920 "state": "translated",
43921 "value": "答えを表示"
43922 }
43923 },
43924 "pt-BR": {
43925 "stringUnit": {
43926 "state": "translated",
43927 "value": "Mostrar Resposta"
43928 }
43929 }
43930 }
43931 },
4290643932 "Show Attachment Folder": {
4290743933 "comment": "Command title",
4290843934 "localizations": {
@@ -45001,6 +46027,40 @@
4500146027 }
4500246028 }
4500346029 },
46030 "Start Again": {
46031 "localizations": {
46032 "de": {
46033 "stringUnit": {
46034 "state": "translated",
46035 "value": "Neu beginnen"
46036 }
46037 },
46038 "es": {
46039 "stringUnit": {
46040 "state": "translated",
46041 "value": "Empezar de nuevo"
46042 }
46043 },
46044 "fr": {
46045 "stringUnit": {
46046 "state": "translated",
46047 "value": "Recommencer"
46048 }
46049 },
46050 "ja": {
46051 "stringUnit": {
46052 "state": "translated",
46053 "value": "最初からやり直す"
46054 }
46055 },
46056 "pt-BR": {
46057 "stringUnit": {
46058 "state": "translated",
46059 "value": "Recomeçar"
46060 }
46061 }
46062 }
46063 },
4500446064 "Start Macro or Insert Counter": {
4500546065 "comment": "Command title",
4500646066 "localizations": {
@@ -46076,6 +47136,75 @@
4607647136 }
4607747137 }
4607847138 },
47139 "Suspend Card": {
47140 "localizations": {
47141 "de": {
47142 "stringUnit": {
47143 "state": "translated",
47144 "value": "Karte aussetzen"
47145 }
47146 },
47147 "es": {
47148 "stringUnit": {
47149 "state": "translated",
47150 "value": "Suspender tarjeta"
47151 }
47152 },
47153 "fr": {
47154 "stringUnit": {
47155 "state": "translated",
47156 "value": "Suspendre la fiche"
47157 }
47158 },
47159 "ja": {
47160 "stringUnit": {
47161 "state": "translated",
47162 "value": "カードを保留"
47163 }
47164 },
47165 "pt-BR": {
47166 "stringUnit": {
47167 "state": "translated",
47168 "value": "Suspender Cartão"
47169 }
47170 }
47171 }
47172 },
47173 "Suspend Flashcard": {
47174 "comment": "Command title",
47175 "localizations": {
47176 "de": {
47177 "stringUnit": {
47178 "state": "translated",
47179 "value": "Lernkarte aussetzen"
47180 }
47181 },
47182 "es": {
47183 "stringUnit": {
47184 "state": "translated",
47185 "value": "Suspender tarjeta"
47186 }
47187 },
47188 "fr": {
47189 "stringUnit": {
47190 "state": "translated",
47191 "value": "Suspendre la fiche"
47192 }
47193 },
47194 "ja": {
47195 "stringUnit": {
47196 "state": "translated",
47197 "value": "フラッシュカードを保留"
47198 }
47199 },
47200 "pt-BR": {
47201 "stringUnit": {
47202 "state": "translated",
47203 "value": "Suspender Flashcard"
47204 }
47205 }
47206 }
47207 },
4607947208 "Switch to Buffer…": {
4608047209 "comment": "Command title",
4608147210 "localizations": {
@@ -47930,6 +49059,41 @@
4793049059 }
4793149060 }
4793249061 },
49062 "The card changed; it was skipped.": {
49063 "comment": "Flashcard review",
49064 "localizations": {
49065 "de": {
49066 "stringUnit": {
49067 "state": "translated",
49068 "value": "Die Karte hat sich geändert und wurde übersprungen."
49069 }
49070 },
49071 "es": {
49072 "stringUnit": {
49073 "state": "translated",
49074 "value": "La tarjeta cambió y se omitió."
49075 }
49076 },
49077 "fr": {
49078 "stringUnit": {
49079 "state": "translated",
49080 "value": "La fiche a changé ; elle a été ignorée."
49081 }
49082 },
49083 "ja": {
49084 "stringUnit": {
49085 "state": "translated",
49086 "value": "カードが変更されたため、スキップしました。"
49087 }
49088 },
49089 "pt-BR": {
49090 "stringUnit": {
49091 "state": "translated",
49092 "value": "O cartão mudou e foi pulado."
49093 }
49094 }
49095 }
49096 },
4793349097 "The clipboard is empty": {
4793449098 "localizations": {
4793549099 "de": {
@@ -50924,6 +52088,41 @@
5092452088 }
5092552089 }
5092652090 },
52091 "Unsuspend Flashcard": {
52092 "comment": "Command title",
52093 "localizations": {
52094 "de": {
52095 "stringUnit": {
52096 "state": "translated",
52097 "value": "Lernkarte fortsetzen"
52098 }
52099 },
52100 "es": {
52101 "stringUnit": {
52102 "state": "translated",
52103 "value": "Reanudar tarjeta"
52104 }
52105 },
52106 "fr": {
52107 "stringUnit": {
52108 "state": "translated",
52109 "value": "Reprendre la fiche"
52110 }
52111 },
52112 "ja": {
52113 "stringUnit": {
52114 "state": "translated",
52115 "value": "フラッシュカードの保留を解除"
52116 }
52117 },
52118 "pt-BR": {
52119 "stringUnit": {
52120 "state": "translated",
52121 "value": "Retomar Flashcard"
52122 }
52123 }
52124 }
52125 },
5092752126 "Until %@": {
5092852127 "localizations": {
5092952128 "de": {
@@ -51062,6 +52261,41 @@
5106252261 }
5106352262 }
5106452263 },
52264 "Update Flashcard": {
52265 "comment": "Command title",
52266 "localizations": {
52267 "de": {
52268 "stringUnit": {
52269 "state": "translated",
52270 "value": "Lernkarte aktualisieren"
52271 }
52272 },
52273 "es": {
52274 "stringUnit": {
52275 "state": "translated",
52276 "value": "Actualizar tarjeta"
52277 }
52278 },
52279 "fr": {
52280 "stringUnit": {
52281 "state": "translated",
52282 "value": "Mettre à jour la fiche"
52283 }
52284 },
52285 "ja": {
52286 "stringUnit": {
52287 "state": "translated",
52288 "value": "フラッシュカードを更新"
52289 }
52290 },
52291 "pt-BR": {
52292 "stringUnit": {
52293 "state": "translated",
52294 "value": "Atualizar Flashcard"
52295 }
52296 }
52297 }
52298 },
5106552299 "Update at Point": {
5106652300 "comment": "Command title",
5106752301 "localizations": {
@@ -52604,6 +53838,74 @@
5260453838 }
5260553839 }
5260653840 },
53841 "Your Answer": {
53842 "localizations": {
53843 "de": {
53844 "stringUnit": {
53845 "state": "translated",
53846 "value": "Deine Antwort"
53847 }
53848 },
53849 "es": {
53850 "stringUnit": {
53851 "state": "translated",
53852 "value": "Tu respuesta"
53853 }
53854 },
53855 "fr": {
53856 "stringUnit": {
53857 "state": "translated",
53858 "value": "Votre réponse"
53859 }
53860 },
53861 "ja": {
53862 "stringUnit": {
53863 "state": "translated",
53864 "value": "あなたの答え"
53865 }
53866 },
53867 "pt-BR": {
53868 "stringUnit": {
53869 "state": "translated",
53870 "value": "Sua Resposta"
53871 }
53872 }
53873 }
53874 },
53875 "Your answer: %@": {
53876 "localizations": {
53877 "de": {
53878 "stringUnit": {
53879 "state": "translated",
53880 "value": "Deine Antwort: %@"
53881 }
53882 },
53883 "es": {
53884 "stringUnit": {
53885 "state": "translated",
53886 "value": "Tu respuesta: %@"
53887 }
53888 },
53889 "fr": {
53890 "stringUnit": {
53891 "state": "translated",
53892 "value": "Votre réponse : %@"
53893 }
53894 },
53895 "ja": {
53896 "stringUnit": {
53897 "state": "translated",
53898 "value": "あなたの答え: %@"
53899 }
53900 },
53901 "pt-BR": {
53902 "stringUnit": {
53903 "state": "translated",
53904 "value": "Sua resposta: %@"
53905 }
53906 }
53907 }
53908 },
5260753909 "Your capture templates, from the app, the share sheet, widgets and the watch.": {
5260853910 "localizations": {
5260953911 "de": {
@@ -53269,6 +54571,40 @@
5326954571 }
5327054572 }
5327154573 },
54574 "cards": {
54575 "localizations": {
54576 "de": {
54577 "stringUnit": {
54578 "state": "translated",
54579 "value": "Karten"
54580 }
54581 },
54582 "es": {
54583 "stringUnit": {
54584 "state": "translated",
54585 "value": "tarjetas"
54586 }
54587 },
54588 "fr": {
54589 "stringUnit": {
54590 "state": "translated",
54591 "value": "fiches"
54592 }
54593 },
54594 "ja": {
54595 "stringUnit": {
54596 "state": "translated",
54597 "value": "枚"
54598 }
54599 },
54600 "pt-BR": {
54601 "stringUnit": {
54602 "state": "translated",
54603 "value": "cartões"
54604 }
54605 }
54606 }
54607 },
5327254608 "case folding past ASCII": {
5327354609 "localizations": {
5327454610 "de": {
@@ -54217,6 +55553,40 @@
5421755553 }
5421855554 }
5421955555 },
55556 "due for review": {
55557 "localizations": {
55558 "de": {
55559 "stringUnit": {
55560 "state": "translated",
55561 "value": "zur Wiederholung fällig"
55562 }
55563 },
55564 "es": {
55565 "stringUnit": {
55566 "state": "translated",
55567 "value": "pendientes de repaso"
55568 }
55569 },
55570 "fr": {
55571 "stringUnit": {
55572 "state": "translated",
55573 "value": "à réviser"
55574 }
55575 },
55576 "ja": {
55577 "stringUnit": {
55578 "state": "translated",
55579 "value": "枚が復習待ち"
55580 }
55581 },
55582 "pt-BR": {
55583 "stringUnit": {
55584 "state": "translated",
55585 "value": "pendentes de revisão"
55586 }
55587 }
55588 }
55589 },
5422055590 "duration size": {
5422155591 "localizations": {
5422255592 "de": {
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