mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +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 UIKit
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Runestone
|
import Runestone
|
||||||
|
import TreeSitterBashRunestone
|
||||||
|
|
||||||
struct TextViewController: UIViewRepresentable {
|
struct TextViewController: UIViewRepresentable {
|
||||||
@Binding var text: String
|
@Binding var text: String
|
||||||
|
|
||||||
func makeUIView(context: Context) -> TextView {
|
func makeUIView(context: Context) -> TextView {
|
||||||
|
let languageMode = TreeSitterLanguageMode(language: .bash)
|
||||||
let textView = TextView()
|
let textView = TextView()
|
||||||
|
setTextViewState(on: textView)
|
||||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
textView.backgroundColor = .systemBackground
|
textView.backgroundColor = .systemBackground
|
||||||
return textView
|
return textView
|
||||||
@@ -23,4 +26,14 @@ struct TextViewController: UIViewRepresentable {
|
|||||||
func updateUIView(_ textView: TextView, context: Context) {
|
func updateUIView(_ textView: TextView, context: Context) {
|
||||||
textView.text = text
|
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