Sources/OrgPrograms/Programs.swift

2df4420ff51f7e97a9c06eacf814f64cdb5a4351
orgstar/Sources/OrgPrograms/Programs.swift

26 lines · 1146 bytes

 1#if os(macOS)
 2import Foundation
 3import OrgApp
 4import OrgCore
 5
 6/// Babel and Emacs as processes, for `DocumentSession.programs`.
 7public struct Programs: ProgramRunning {
 8    public init() {}
 9
10    public func runBabel(_ job: BabelJob, fileDirectory: URL) async throws -> BabelOutput {
11        // js in JavaScriptCore when node (or `:cmd`) isn't installed. A `:cmd` with arguments runs
12        // as written, since JavaScriptCore can't take node's options.
13        switch job.runner {
14        case .process(let executable, _), .session(_, let executable, _):
15            if !executable.contains(where: \.isWhitespace), !BabelRunner.installed(executable), let output = try await JavaScriptBlocks.run(job, directory: fileDirectory) { return output }
16        case .emacs:
17            break
18        }
19        return try await BabelRunner.run(job, fileDirectory: fileDirectory)
20    }
21
22    public func recalculateTable(text: String, directory: URL, table: Range<Int>, point: Int, form: String) async throws -> String {
23        try await EmacsRunner.recalculateTable(text: text, directory: directory, table: table, point: point, form: form)
24    }
25}
26#endif
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