@@ -33,6 +33,9 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
33
33
highlighter? . invalidate ( )
34
34
} }
35
35
36
+ /// Whether the code editor should use the theme background color or be transparent
37
+ public var useThemeBackground : Bool
38
+
36
39
/// The number of spaces to use for a `tab '\t'` character
37
40
public var tabWidth : Int
38
41
@@ -63,7 +66,8 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
63
66
tabWidth: Int ,
64
67
wrapLines: Bool ,
65
68
cursorPosition: Published < ( Int , Int ) > . Publisher ? = nil ,
66
- editorOverscroll: Double
69
+ editorOverscroll: Double ,
70
+ useThemeBackground: Bool
67
71
) {
68
72
self . text = text
69
73
self . language = language
@@ -73,6 +77,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
73
77
self . wrapLines = wrapLines
74
78
self . cursorPosition = cursorPosition
75
79
self . editorOverscroll = editorOverscroll
80
+ self . useThemeBackground = useThemeBackground
76
81
super. init ( nibName: nil , bundle: nil )
77
82
}
78
83
@@ -89,9 +94,10 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
89
94
scrollView. translatesAutoresizingMaskIntoConstraints = false
90
95
scrollView. hasVerticalScroller = true
91
96
scrollView. documentView = textView
97
+ scrollView. drawsBackground = useThemeBackground
92
98
93
99
rulerView = STLineNumberRulerView ( textView: textView, scrollView: scrollView)
94
- rulerView. backgroundColor = theme. background
100
+ rulerView. backgroundColor = useThemeBackground ? theme. background : . clear
95
101
rulerView. textColor = . systemGray
96
102
rulerView. drawSeparator = false
97
103
rulerView. baselineOffset = baselineOffset
@@ -102,7 +108,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
102
108
textView. defaultParagraphStyle = self . paragraphStyle
103
109
textView. font = self . font
104
110
textView. textColor = theme. text
105
- textView. backgroundColor = theme. background
111
+ textView. backgroundColor = useThemeBackground ? theme. background : . clear
106
112
textView. insertionPointColor = theme. insertionPoint
107
113
textView. insertionPointWidth = 1.0
108
114
textView. selectionBackgroundColor = theme. selection
@@ -207,16 +213,17 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
207
213
}
208
214
209
215
textView? . textColor = theme. text
210
- textView? . backgroundColor = theme. background
216
+ textView. backgroundColor = useThemeBackground ? theme. background : . clear
211
217
textView? . insertionPointColor = theme. insertionPoint
212
218
textView? . selectionBackgroundColor = theme. selection
213
219
textView? . selectedLineHighlightColor = theme. lineHighlight
214
220
215
- rulerView? . backgroundColor = theme. background
221
+ rulerView? . backgroundColor = useThemeBackground ? theme. background : . clear
216
222
rulerView? . separatorColor = theme. invisibles
217
223
rulerView? . baselineOffset = baselineOffset
218
224
219
- ( view as? NSScrollView ) ? . backgroundColor = theme. background
225
+ ( view as? NSScrollView ) ? . drawsBackground = useThemeBackground
226
+ ( view as? NSScrollView ) ? . backgroundColor = useThemeBackground ? theme. background : . clear
220
227
( view as? NSScrollView ) ? . contentView. contentInsets. bottom = bottomContentInsets
221
228
222
229
setStandardAttributes ( )
0 commit comments