Sources/Orgstar/EditorWindowView.swift

d6defe0dc0a9a2097c50011a25c810644b5ffaef
orgstar/Sources/Orgstar/EditorWindowView.swift

45 lines · 1873 bytes

 1import OrgApp
 2import SwiftUI
 3
 4/// A window of panes alone, as a second Emacs frame: no sidebar or search. It opens on the
 5/// buffer the focused pane showed, and its panes leave the session when it closes.
 6struct EditorWindowView: View {
 7    let session: DocumentSession
 8    let commands: AppCommands
 9    let clock: ClockModel
10    @AppStorage("showTabBar") private var showTabBar = false
11    @State private var window: WindowModel?
12
13    var body: some View {
14        Group {
15            if let window {
16                PaneLayoutView(layout: window.layout, window: window) { pane in
17                    PaneCell(pane: pane, window: window, session: session, commands: commands, showTabBar: showTabBar) { commands.run($0) }
18                }
19                .safeAreaInset(edge: .bottom, spacing: 0) {
20                    VStack(spacing: 0) {
21                        ModeLine(session: session, commands: commands, clock: clock) { commands.run($0) }
22                        EchoArea(commands: commands)
23                    }
24                }
25            }
26        }
27        .navigationTitle(window?.focusedPane.path.map(session.bufferName) ?? "orgstar")
28        .onAppear {
29            guard window == nil else { return }
30            let pane = session.makePane()
31            if let path = session.focused.path { session.open(path, in: pane) }
32            let model = WindowModel(session: session, pane: pane)
33            window = model
34            commands.store.windows.append(model)
35            model.focus(pane.id)
36        }
37        .onDisappear {
38            guard let model = window else { return }
39            for id in model.layout.panes { commands.store.releasePane(id) }
40            model.closeAll()
41            commands.store.windows.removeAll { $0 === model }
42            if let main = commands.store.windows.first { main.focus(main.focused) }
43        }
44    }
45}
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