added syntax highlighting - and a new runtime error :cry

This commit is contained in:
neon443
2025-06-21 12:50:28 +01:00
parent cf5feaacc2
commit 5fafc52913

View File

@@ -9,12 +9,15 @@ import Foundation
import UIKit
import SwiftUI
import Runestone
import TreeSitterBashRunestone
struct TextViewController: UIViewRepresentable {
@Binding var text: String
func makeUIView(context: Context) -> TextView {
let languageMode = TreeSitterLanguageMode(language: .bash)
let textView = TextView()
setTextViewState(on: textView)
textView.translatesAutoresizingMaskIntoConstraints = false
textView.backgroundColor = .systemBackground
return textView
@@ -23,4 +26,14 @@ struct TextViewController: UIViewRepresentable {
func updateUIView(_ textView: TextView, context: Context) {
textView.text = text
}
private func setTextViewState(on textView: TextView) {
DispatchQueue.global(qos: .userInitiated).async {
let text = self.text
let state = TextViewState(text: text, language: .bash)
DispatchQueue.main.async {
textView.setState(state)
}
}
}
}