@@ -33,6 +33,9 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
3333 highlighter? . invalidate ( )
3434 } }
3535
36+ /// Whether the code editor should use the theme background color or be transparent
37+ public var useThemeBackground : Bool
38+
3639 /// The number of spaces to use for a `tab '\t'` character
3740 public var tabWidth : Int
3841
@@ -63,7 +66,8 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
6366 tabWidth: Int ,
6467 wrapLines: Bool ,
6568 cursorPosition: Published < ( Int , Int ) > . Publisher ? = nil ,
66- editorOverscroll: Double
69+ editorOverscroll: Double ,
70+ useThemeBackground: Bool
6771 ) {
6872 self . text = text
6973 self . language = language
@@ -73,6 +77,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
7377 self . wrapLines = wrapLines
7478 self . cursorPosition = cursorPosition
7579 self . editorOverscroll = editorOverscroll
80+ self . useThemeBackground = useThemeBackground
7681 super. init ( nibName: nil , bundle: nil )
7782 }
7883
@@ -89,9 +94,10 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
8994 scrollView. translatesAutoresizingMaskIntoConstraints = false
9095 scrollView. hasVerticalScroller = true
9196 scrollView. documentView = textView
97+ scrollView. drawsBackground = useThemeBackground
9298
9399 rulerView = STLineNumberRulerView ( textView: textView, scrollView: scrollView)
94- rulerView. backgroundColor = theme. background
100+ rulerView. backgroundColor = useThemeBackground ? theme. background : . clear
95101 rulerView. textColor = . systemGray
96102 rulerView. drawSeparator = false
97103 rulerView. baselineOffset = baselineOffset
@@ -102,7 +108,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
102108 textView. defaultParagraphStyle = self . paragraphStyle
103109 textView. font = self . font
104110 textView. textColor = theme. text
105- textView. backgroundColor = theme. background
111+ textView. backgroundColor = useThemeBackground ? theme. background : . clear
106112 textView. insertionPointColor = theme. insertionPoint
107113 textView. insertionPointWidth = 1.0
108114 textView. selectionBackgroundColor = theme. selection
@@ -207,16 +213,17 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
207213 }
208214
209215 textView? . textColor = theme. text
210- textView? . backgroundColor = theme. background
216+ textView. backgroundColor = useThemeBackground ? theme. background : . clear
211217 textView? . insertionPointColor = theme. insertionPoint
212218 textView? . selectionBackgroundColor = theme. selection
213219 textView? . selectedLineHighlightColor = theme. lineHighlight
214220
215- rulerView? . backgroundColor = theme. background
221+ rulerView? . backgroundColor = useThemeBackground ? theme. background : . clear
216222 rulerView? . separatorColor = theme. invisibles
217223 rulerView? . baselineOffset = baselineOffset
218224
219- ( view as? NSScrollView ) ? . backgroundColor = theme. background
225+ ( view as? NSScrollView ) ? . drawsBackground = useThemeBackground
226+ ( view as? NSScrollView ) ? . backgroundColor = useThemeBackground ? theme. background : . clear
220227 ( view as? NSScrollView ) ? . contentView. contentInsets. bottom = bottomContentInsets
221228
222229 setStandardAttributes ( )
0 commit comments