22 lines
608 B
Swift
22 lines
608 B
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// SwiftUI face of the AppKit code pane; all the work happens in `CodeEditorController`.
|
|
struct CodeEditorView: NSViewRepresentable {
|
|
var configuration: CodeEditorConfiguration
|
|
var actions: CodeEditorActions
|
|
|
|
func makeCoordinator() -> CodeEditorController {
|
|
CodeEditorController()
|
|
}
|
|
|
|
func makeNSView(context: Context) -> NSScrollView {
|
|
context.coordinator.scrollView
|
|
}
|
|
|
|
func updateNSView(_ view: NSScrollView, context: Context) {
|
|
context.coordinator.actions = actions
|
|
context.coordinator.apply(configuration)
|
|
}
|
|
}
|