Sources/Orgstar/LinkOpener.swift

02bd211f34ad3cc0aa94ba6eb19d312da340d818
orgstar/Sources/Orgstar/LinkOpener.swift

18 lines · 605 bytes

 1import AppKit
 2import OrgApp
 3import OrgCore
 4
 5/// Follows a link, handing addresses and files Orgstar doesn't edit to macOS.
 6@MainActor
 7enum LinkOpener {
 8    /// Returns a message when the link can't be followed.
 9    static func open(_ link: OrgLink, session: DocumentSession, workspace: WorkspaceModel) -> String? {
10        switch session.follow(link, workspace: workspace, isText: FileTypes.isText) {
11        case .shown: return nil
12        case .openExternally(let url):
13            NSWorkspace.shared.open(url)
14            return nil
15        case .message(let message): return message
16        }
17    }
18}
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