mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added syntax highlighting - and a new runtime error :cry
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user