Sources/OrgApp/EditorPane.swift

30 lines · 1340 bytes

 1import Foundation
 2import OrgCore
 3import OrgPresentation
 4
 5/// One place a buffer shows, as a window shows a buffer in Emacs: which file, the buffers it
 6/// has shown (its tabs), and what the editor view in it follows. The session keeps these in
 7/// step with the buffers.
 8@MainActor
 9@Observable
10public final class EditorPane: Identifiable {
11    public let id = PaneID()
12    /// The file shown, nil for an empty pane.
13    public internal(set) var path: String?
14    /// Open files this pane has shown, in the order it first showed them: its tabs.
15    public internal(set) var shown: [String] = []
16    /// Files this pane has shown, most recent first.
17    public internal(set) var history: [String] = []
18    public internal(set) var outline: [OutlineEntry] = []
19    /// Bumped when the shown buffer settles after edits, and when a file opens here.
20    public internal(set) var editVersion = 0
21    public internal(set) var isDirty = false
22    /// The file isn't UTF-8, so it can't be edited or saved.
23    public internal(set) var isReadOnly = false
24    /// Set while the shown buffer and the file on disk conflict; says how to resolve it.
25    public internal(set) var conflict: String?
26    /// Bumped to ask the editor in this pane to reveal an offset.
27    public internal(set) var revealRequest: (offset: Int, id: Int)?
28
29    public init() {}
30}