@@ -39,20 +39,22 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
3939 /// the default `TreeSitterClient` highlighter.
4040 /// - contentInsets: Insets to use to offset the content in the enclosing scroll view. Leave as `nil` to let the
4141 /// scroll view automatically adjust content insets.
42- /// - additionalTextInsets: An additional amount to inset the text of the editor by.
42+ /// - additionalTextInsets: A set of extra text insets to indent only *text* content. Does not effect
43+ /// decorations like the find panel.
4344 /// - isEditable: A Boolean value that controls whether the text view allows the user to edit text.
4445 /// - isSelectable: A Boolean value that controls whether the text view allows the user to select text. If this
4546 /// value is true, and `isEditable` is false, the editor is selectable but not editable.
4647 /// - letterSpacing: The amount of space to use between letters, as a percent. Eg: `1.0` = no space, `1.5` = 1/2 a
4748 /// character's width between characters, etc. Defaults to `1.0`
4849 /// - bracketPairEmphasis: The type of highlight to use to highlight bracket pairs.
4950 /// See `BracketPairHighlight` for more information. Defaults to `nil`
50- /// - useSystemCursor: If true, uses the system cursor on `>= macOS 14` .
51+ /// - useSystemCursor: Use the system cursor instead of the default line cursor. Only available after macOS 14.
5152 /// - undoManager: The undo manager for the text view. Defaults to `nil`, which will create a new CEUndoManager
5253 /// - coordinators: Any text coordinators for the view to use. See ``TextViewCoordinator`` for more information.
53- /// - showMinimap: Whether to show the minimap
54+ /// - showMinimap: Toggle the visibility of the minimap.
5455 /// - reformatAtColumn: The column to reformat at
5556 /// - showReformattingGuide: Whether to show the reformatting guide
57+ /// - showFoldingRibbon: Toggle the visibility of the line folding ribbon.
5658 public init (
5759 _ text: Binding < String > ,
5860 language: CodeLanguage ,
@@ -77,7 +79,8 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
7779 coordinators: [ any TextViewCoordinator ] = [ ] ,
7880 showMinimap: Bool ,
7981 reformatAtColumn: Int ,
80- showReformattingGuide: Bool
82+ showReformattingGuide: Bool ,
83+ showFoldingRibbon: Bool
8184 ) {
8285 self . text = . binding( text)
8386 self . language = language
@@ -107,6 +110,7 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
107110 self . showMinimap = showMinimap
108111 self . reformatAtColumn = reformatAtColumn
109112 self . showReformattingGuide = showReformattingGuide
113+ self . showFoldingRibbon = showFoldingRibbon
110114 }
111115
112116 /// Initializes a Text Editor
@@ -127,18 +131,22 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
127131 /// the default `TreeSitterClient` highlighter.
128132 /// - contentInsets: Insets to use to offset the content in the enclosing scroll view. Leave as `nil` to let the
129133 /// scroll view automatically adjust content insets.
134+ /// - additionalTextInsets: A set of extra text insets to indent only *text* content. Does not effect
135+ /// decorations like the find panel.
130136 /// - isEditable: A Boolean value that controls whether the text view allows the user to edit text.
131137 /// - isSelectable: A Boolean value that controls whether the text view allows the user to select text. If this
132138 /// value is true, and `isEditable` is false, the editor is selectable but not editable.
133139 /// - letterSpacing: The amount of space to use between letters, as a percent. Eg: `1.0` = no space, `1.5` = 1/2 a
134140 /// character's width between characters, etc. Defaults to `1.0`
135141 /// - bracketPairEmphasis: The type of highlight to use to highlight bracket pairs.
136142 /// See `BracketPairEmphasis` for more information. Defaults to `nil`
143+ /// - useSystemCursor: Use the system cursor instead of the default line cursor. Only available after macOS 14.
137144 /// - undoManager: The undo manager for the text view. Defaults to `nil`, which will create a new CEUndoManager
138145 /// - coordinators: Any text coordinators for the view to use. See ``TextViewCoordinator`` for more information.
139- /// - showMinimap: Whether to show the minimap
146+ /// - showMinimap: Toggle the visibility of the minimap.
140147 /// - reformatAtColumn: The column to reformat at
141148 /// - showReformattingGuide: Whether to show the reformatting guide
149+ /// - showFoldingRibbon: Toggle the visibility of the line folding ribbon.
142150 public init (
143151 _ text: NSTextStorage ,
144152 language: CodeLanguage ,
@@ -163,7 +171,8 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
163171 coordinators: [ any TextViewCoordinator ] = [ ] ,
164172 showMinimap: Bool ,
165173 reformatAtColumn: Int ,
166- showReformattingGuide: Bool
174+ showReformattingGuide: Bool ,
175+ showFoldingRibbon: Bool
167176 ) {
168177 self . text = . storage( text)
169178 self . language = language
@@ -193,6 +202,7 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
193202 self . showMinimap = showMinimap
194203 self . reformatAtColumn = reformatAtColumn
195204 self . showReformattingGuide = showReformattingGuide
205+ self . showFoldingRibbon = showFoldingRibbon
196206 }
197207
198208 package var text : TextAPI
@@ -219,6 +229,7 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
219229 package var showMinimap : Bool
220230 private var reformatAtColumn : Int
221231 private var showReformattingGuide : Bool
232+ package var showFoldingRibbon : Bool
222233
223234 public typealias NSViewControllerType = TextViewController
224235
@@ -247,7 +258,8 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
247258 coordinators: coordinators,
248259 showMinimap: showMinimap,
249260 reformatAtColumn: reformatAtColumn,
250- showReformattingGuide: showReformattingGuide
261+ showReformattingGuide: showReformattingGuide,
262+ showFoldingRibbon: showFoldingRibbon
251263 )
252264 switch text {
253265 case . binding( let binding) :
@@ -336,6 +348,7 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
336348 controller. contentInsets = contentInsets
337349 controller. additionalTextInsets = additionalTextInsets
338350 controller. showMinimap = showMinimap
351+ controller. showFoldingRibbon = showFoldingRibbon
339352
340353 if controller. indentOption != indentOption {
341354 controller. indentOption = indentOption
@@ -397,6 +410,7 @@ public struct CodeEditSourceEditor: NSViewControllerRepresentable {
397410 controller. showMinimap == showMinimap &&
398411 controller. reformatAtColumn == reformatAtColumn &&
399412 controller. showReformattingGuide == showReformattingGuide &&
413+ controller. showFoldingRibbon == showFoldingRibbon &&
400414 areHighlightProvidersEqual ( controller: controller, coordinator: coordinator)
401415 }
402416
0 commit comments