Sources/Orgstar/OrgstarApp.swift

ef12a61bb325e9e2127b71376fc4bd6410bf41cb
orgstar/Sources/Orgstar/OrgstarApp.swift

41 lines · 1453 bytes

 1import OrgApp
 2import SwiftUI
 3
 4/// Window-level requests the menu bar makes.
 5@MainActor
 6@Observable
 7final class AppCommands {
 8    var showingQuickOpen = false
 9    var showingFolderPicker = false
10    var focusSearch = false
11}
12
13@main
14struct OrgstarApp: App {
15    @State private var workspace = Result { try WorkspaceModel(directory: WorkspaceModel.defaultDirectory) }
16    @State private var commands = AppCommands()
17
18    var body: some Scene {
19        Window("Orgstar", id: "main") {
20            switch workspace {
21            case .success(let model):
22                ContentView(workspace: model, commands: commands)
23            case .failure(let error):
24                ContentUnavailableView("Can't open the index", systemImage: "exclamationmark.triangle", description: Text(error.localizedDescription))
25            }
26        }
27        .defaultSize(width: 1280, height: 860)
28        .commands {
29            CommandGroup(after: .newItem) {
30                Button("Add Folder…") { commands.showingFolderPicker = true }
31                    .keyboardShortcut("o", modifiers: [.command, .shift])
32                Button("Quick Open…") { commands.showingQuickOpen = true }
33                    .keyboardShortcut("p")
34            }
35            CommandGroup(after: .textEditing) {
36                Button("Search Notes") { commands.focusSearch = true }
37                    .keyboardShortcut("f", modifiers: [.command, .shift])
38            }
39        }
40    }
41}
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