@@ -52,6 +52,9 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
5252 /// Whether lines wrap to the width of the editor
5353 public var wrapLines : Bool
5454
55+ /// Whether or not text view is editable by user
56+ public var isEditable : Bool
57+
5558 /// Filters used when applying edits..
5659 internal var textFilters : [ TextFormation . Filter ] = [ ]
5760
@@ -81,7 +84,8 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
8184 editorOverscroll: Double ,
8285 useThemeBackground: Bool ,
8386 highlightProvider: HighlightProviding ? = nil ,
84- contentInsets: NSEdgeInsets ? = nil
87+ contentInsets: NSEdgeInsets ? = nil ,
88+ isEditable: Bool
8589 ) {
8690 self . text = text
8791 self . language = language
@@ -94,6 +98,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
9498 self . useThemeBackground = useThemeBackground
9599 self . highlightProvider = highlightProvider
96100 self . contentInsets = contentInsets
101+ self . isEditable = isEditable
97102 super. init ( nibName: nil , bundle: nil )
98103 }
99104
@@ -123,6 +128,11 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
123128 rulerView. drawSeparator = false
124129 rulerView. baselineOffset = baselineOffset
125130 rulerView. font = NSFont . monospacedDigitSystemFont ( ofSize: 9.5 , weight: . regular)
131+
132+ if self . isEditable == false {
133+ rulerView. selectedLineTextColor = nil
134+ }
135+
126136 scrollView. verticalRulerView = rulerView
127137 scrollView. rulersVisible = true
128138
@@ -135,11 +145,13 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
135145 textView. selectionBackgroundColor = theme. selection
136146 textView. selectedLineHighlightColor = theme. lineHighlight
137147 textView. string = self . text. wrappedValue
148+ textView. isEditable = self . isEditable
138149 textView. widthTracksTextView = self . wrapLines
139150 textView. highlightSelectedLine = true
140151 textView. allowsUndo = true
141152 textView. setupMenus ( )
142153 textView. delegate = self
154+ textView. highlightSelectedLine = self . isEditable
143155
144156 scrollView. documentView = textView
145157
@@ -223,10 +235,13 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
223235 textView? . insertionPointColor = theme. insertionPoint
224236 textView? . selectionBackgroundColor = theme. selection
225237 textView? . selectedLineHighlightColor = theme. lineHighlight
238+ textView? . isEditable = isEditable
239+ textView. highlightSelectedLine = isEditable
226240
227241 rulerView? . backgroundColor = useThemeBackground ? theme. background : . clear
228242 rulerView? . separatorColor = theme. invisibles
229243 rulerView? . baselineOffset = baselineOffset
244+ rulerView. highlightSelectedLine = isEditable
230245
231246 if let scrollView = view as? NSScrollView {
232247 scrollView. drawsBackground = useThemeBackground
0 commit comments