### setUp Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/treesitterclient Sets up the TreeSitterClient with a text view and code language. ```APIDOC ## setUp(textView: TextView, codeLanguage: CodeLanguage) ### Description Set up the client with a text view and language. ### Method setUp ### Parameters #### Path Parameters - **textView** (TextView) - Required - The text view to associate with the client. - **codeLanguage** (CodeLanguage) - Required - The code language for syntax parsing. ``` -------------------------------- ### showReformattingGuide Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/peripherals-swift.struct/showreformattingguide Controls the visibility of the reformatting guide. Set to true to display the guide, and false to hide it. ```APIDOC ## showReformattingGuide ### Description Whether to show the reformatting guide. ### Type `Bool` ### Usage ```swift var showReformattingGuide: Bool ``` ``` -------------------------------- ### start Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/start Represents the starting position of a cursor or selection. ```APIDOC ## start ### Description An instance property that defines the starting point of a cursor or selection. ### Type `Position` ``` -------------------------------- ### setUp(textView:codeLanguage:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/treesitterclient/setup%28textview%3Acodelanguage%3A%29 Sets up the TreeSitterClient with a text view and the desired code language for parsing. ```APIDOC ## setUp(textView:codeLanguage:) ### Description Set up the client with a text view and language. ### Method `@MainActor func setUp(textView: TextView, codeLanguage: CodeLanguage)` ### Parameters #### Path Parameters - **textView** (TextView) - Required - The text view to use as a data source. A weak reference will be kept for the lifetime of this object. - **codeLanguage** (CodeLanguage) - Required - The language to use for parsing. ``` -------------------------------- ### setUp(textView:codeLanguage:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/highlightproviding/setup%28textview%3Acodelanguage%3A%29 Initializes the highlight provider with a data source (TextView) and the programming language to be used for syntax highlighting. ```APIDOC ## setUp(textView:codeLanguage:) ### Description Called once to set up the highlight provider with a data source and language. ### Method func setUp(textView: TextView, codeLanguage: CodeLanguage) ### Parameters #### Path Parameters - **textView** (TextView) - Required - The text view to use as a text source. - **codeLanguage** (CodeLanguage) - Required - The language that should be used by the highlighter. ``` -------------------------------- ### Setup Highlight Provider Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/highlightproviding Called once to set up the highlight provider with a data source and language. This method is required for initialization. ```swift func setUp(textView: TextView, codeLanguage: CodeLanguage) ``` -------------------------------- ### String Capture Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/string Demonstrates the basic syntax for string capture. Ensure JavaScript is enabled in your browser. ```swift case string ``` -------------------------------- ### Async Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifier/async Demonstrates the use of 'async' within a case statement. ```swift case async ``` -------------------------------- ### Keyword Return Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/keywordreturn Demonstrates a basic case for keyword return. Ensure JavaScript is enabled for full content rendering. ```swift case keywordReturn ``` -------------------------------- ### Case Comment Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/comment Demonstrates a basic comment structure for case handling. ```text case comment ``` -------------------------------- ### CaptureName.function Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/function Illustrates the basic 'case function' syntax. ```swift case function ``` -------------------------------- ### Initialize CursorPosition with Start and End Positions Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition Initializes a CursorPosition with a starting Position and an optional ending Position. This allows for defining a selection with explicit start and end points. ```swift init(start: Position, end: Position?) ``` -------------------------------- ### Initialize Highlight Provider with setUp Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/highlightproviding/setup%28textview%3Acodelanguage%3A%29 Call this method once to set up the highlight provider. It requires a TextView for text sourcing and a CodeLanguage to determine the syntax highlighting rules. ```swift @MainActor func setUp( textView: TextView, codeLanguage: CodeLanguage ) ``` -------------------------------- ### startFold(rangeStart:newDepth:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/linefoldproviderlineinfo/startfold%28rangestart%3Anewdepth%3A%29 Initiates a fold operation starting at a specified range with a given depth. ```APIDOC ## startFold(rangeStart:newDepth:) ### Description Initiates a fold operation starting at a specified range with a given depth. ### Method This is a method signature, not an HTTP endpoint. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift startFold(rangeStart: 10, newDepth: 2) ``` ### Response This method does not return a value in the provided documentation. ``` -------------------------------- ### Float Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/float Demonstrates the 'float' case for CaptureName. This is a basic representation. ```swift case float ``` -------------------------------- ### Get Documentation String Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codesuggestionentry/documentation Access the documentation string for the current page. This property is required. ```swift var documentation: String? { get } ``` -------------------------------- ### Toggle Reformatting Guide Visibility Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/showreformattingguide Use this Boolean property to toggle the visibility of the reformatting guide in the editor. It is an instance property and requires the @MainActor context. ```swift @MainActor var showReformattingGuide: Bool { get } ``` -------------------------------- ### Create a Basic TextViewCoordinator Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcoordinators Create a class that conforms to the TextViewCoordinator protocol. Implement the prepareCoordinator method to perform initial setup, such as keeping a weak reference to the TextViewController or adding a text storage delegate. ```swift class MyCoordinator { func prepareCoordinator(controller: TextViewController) { // Do any setup, such as keeping a (weak) reference to the controller or adding a text storage delegate. } } ``` -------------------------------- ### Show Reformatting Guide Property Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/peripherals-swift.struct/showreformattingguide Controls whether the reformatting guide is displayed. This is a boolean property. ```swift var showReformattingGuide: Bool ``` -------------------------------- ### Include Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/include Demonstrates the basic syntax for the 'include' case within CaptureName. This is a fundamental building block for including external content or logic. ```swift case include ``` -------------------------------- ### Peripherals Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/peripherals-swift.struct Initializes a new Peripherals configuration with specified settings for gutter, minimap, reformatting guide, folding ribbon, invisible characters, and warning characters. ```APIDOC ## init(showGutter: Bool, showMinimap: Bool, showReformattingGuide: Bool, showFoldingRibbon: Bool, invisibleCharactersConfiguration: InvisibleCharactersConfiguration, warningCharacters: Set) ### Description Initializes a new `Peripherals` configuration. ### Parameters - **showGutter** (Bool) - Whether to show the gutter. - **showMinimap** (Bool) - Whether to show the minimap. - **showReformattingGuide** (Bool) - Whether to show the reformatting guide. - **showFoldingRibbon** (Bool) - Whether to show the folding ribbon. Only available if `showGutter` is `true`. - **invisibleCharactersConfiguration** (InvisibleCharactersConfiguration) - Configuration for drawing invisible characters. - **warningCharacters** (Set) - Indicates characters that the user may not have meant to insert. ``` -------------------------------- ### Prepare Coordinator with TextViewController Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/combinecoordinator/preparecoordinator%28controller%3A%29 Use this method to install delegates, modify the text view or controller, or capture the text view for later use. The controller parameter can be held as a weak reference. ```swift func prepareCoordinator(controller: TextViewController) ``` -------------------------------- ### Initialize SourceEditorConfiguration.Peripherals Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/peripherals-swift.struct/init%28showgutter%3Ashowminimap%3Ashowreformattingguide%3Ashowfoldingribbon%3Ainvisiblecharactersconfiguration%3Awarningcharacters%3A%29 Use this initializer to configure the visibility of the gutter, minimap, reformatting guide, and folding ribbon. It also allows setting custom configurations for invisible characters and warning characters. ```swift init( showGutter: Bool = true, showMinimap: Bool = true, showReformattingGuide: Bool = false, showFoldingRibbon: Bool = true, invisibleCharactersConfiguration: InvisibleCharactersConfiguration = .empty, warningCharacters: Set = [] ) ``` -------------------------------- ### CaptureModifier Documentation Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifier/documentation This snippet shows a basic documentation case for CaptureModifier. ```markdown case documentation ``` -------------------------------- ### CursorPosition Initializers Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition Initializers for creating a CursorPosition instance. You can initialize with line and column, a range, or start and end positions. ```APIDOC ## Initializers ### `init(from: any Decoder) throws` Initializes a CursorPosition from a decoder. ### `init(line: Int, column: Int)` Initialize a cursor position with line and column numbers. ### `init(range: NSRange)` Initialize a cursor position with a specified range. ### `init(start: Position, end: Position?)` Initialize a cursor position with start and optional end positions. ``` -------------------------------- ### Keyword Syntax Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/keyword This snippet shows the basic syntax for a keyword in CaptureName. No specific setup or imports are required. ```plaintext case keyword ``` -------------------------------- ### Boolean Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/boolean This snippet demonstrates the 'boolean' case for CaptureName. No specific setup is required. ```swift case boolean ``` -------------------------------- ### Get reformatAtColumn Property Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/reformatatcolumn This property returns the column at which the reformatting guide is shown. It is marked with @MainActor, indicating it must be accessed on the main thread. ```swift @MainActor var reformatAtColumn: Int { get } ``` -------------------------------- ### CaptureName.type Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/type Illustrates the basic syntax for defining a case within CaptureName.type. This is a fundamental building block for type matching. ```swift case type ``` -------------------------------- ### prepareCoordinator(controller:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/combinecoordinator/preparecoordinator%28controller%3A%29 Called when an instance of `TextViewController` is available. Use this method to install any delegates, perform any modifications on the text view or controller, or capture the text view for later use in your app. ```APIDOC ## prepareCoordinator(controller:) ### Description Called when an instance of `TextViewController` is available. Use this method to install any delegates, perform any modifications on the text view or controller, or capture the text view for later use in your app. ### Method func prepareCoordinator(controller: TextViewController) ### Parameters #### Path Parameters - **controller** (TextViewController) - The text controller. This is safe to keep a weak reference to, as long as it is dereferenced when `destroy()` is called. ``` -------------------------------- ### init(textView:theme:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/minimapview/init%28textview%3Atheme%3A%29 Creates a minimap view with the text view to track, and an initial theme. ```APIDOC ## init(textView:theme:) ### Description Creates a minimap view with the text view to track, and an initial theme. ### Parameters #### textView The text view to match contents with. #### theme The theme for the minimap to use. ``` -------------------------------- ### init() Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/combinecoordinator/init%28%29 Initializes the coordinator. ```APIDOC ## init() ### Description Initializes the coordinator. ### Method init() ### Endpoint N/A (Initializer) ### Parameters None ### Request Example ```swift init() ``` ### Response N/A (Initializer) ``` -------------------------------- ### Alignment Guide Functions Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/view-implementations Defines custom alignment guides for horizontal and vertical alignment within a view hierarchy. ```APIDOC ## alignmentGuide(HorizontalAlignment, computeValue: (ViewDimensions) -> CGFloat) -> some View ### Description Defines a horizontal alignment guide for the view. ### Parameters - **computeValue** ((ViewDimensions) -> CGFloat) - A closure that computes the alignment value based on view dimensions. ## alignmentGuide(VerticalAlignment, computeValue: (ViewDimensions) -> CGFloat) -> some View ### Description Defines a vertical alignment guide for the view. ### Parameters - **computeValue** ((ViewDimensions) -> CGFloat) - A closure that computes the alignment value based on view dimensions. ``` -------------------------------- ### Find Start of Line Method Signature Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codeedittextview/textview/findstartofline%28containing%3A%29 This is the method signature for findStartOfLine(containing:). It takes an integer location and returns an integer representing the start of the line. ```swift func findStartOfLine(containing location: Int) -> Int ``` -------------------------------- ### help(_:) Instance Method Signature Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/help%28_%3A%29-7jl9i This is the signature for the `help(_:)` instance method. It takes a `LocalizedStringKey` and returns a `View`. ```swift nonisolated func help(_ textKey: LocalizedStringKey) -> some View ``` -------------------------------- ### Conditional Capture Name Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/conditional This is an example of a conditional capture name. ```regex case conditional ``` -------------------------------- ### init(font:textColor:selectedTextColor:controller:delegate:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/gutterview/init%28font%3Atextcolor%3Aselectedtextcolor%3Acontroller%3Adelegate%3A%29 Initializes a new instance of GutterView with specified font, colors, controller, and delegate. ```APIDOC ## init(font:textColor:selectedTextColor:controller:delegate:) ### Description Initializes a new instance of GutterView. ### Parameters #### Path Parameters - **font** (NSFont) - The font to be used for the gutter. - **textColor** (NSColor) - The default text color for gutter elements. - **selectedTextColor** (NSColor?) - The text color for selected gutter elements. Optional. - **controller** (TextViewController) - The text view controller managing the text. - **delegate** (GutterViewDelegate?) - The delegate for the GutterView. Optional, defaults to nil. ``` -------------------------------- ### Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/invisiblecharactersconfiguration/init%28showspaces%3Ashowtabs%3Ashowlineendings%3A%29 Initializes the configuration for displaying invisible characters. ```APIDOC ## init(showSpaces:showTabs:showLineEndings:) ### Description Initializes the configuration for displaying invisible characters, allowing control over the visibility of spaces, tabs, and line endings. ### Method Initializer ### Parameters #### Query Parameters - **showSpaces** (Bool) - Required - Determines if spaces should be displayed. - **showTabs** (Bool) - Required - Determines if tabs should be displayed. - **showLineEndings** (Bool) - Required - Determines if line endings should be displayed. ``` -------------------------------- ### OptionSet Initializers Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifierset/optionset-implementations Provides information on how to initialize OptionSet types. ```APIDOC ## Initializers ### `init()` Initializes a new instance of the OptionSet. ``` -------------------------------- ### AppKit TextViewController Initialization Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorview Shows how to initialize and configure the `TextViewController` for AppKit applications, including setting initial text, language, appearance, behavior, and integrating with coordinators and delegates. ```APIDOC ## AppKit TextViewController ### Description This section demonstrates the initialization of `TextViewController` for AppKit, which is the underlying text view controller for the source editor. It allows for detailed configuration of the editor's appearance, behavior, and integration with other functionalities. ### Initialization ```swift var theme = EditorTheme(...) var font = NSFont.monospacedSystemFont(ofSize: 11, weight: .regular) var indentOption = .spaces(count: 4) var editorOverscroll = 0.3 var showMinimap = true let editorController = TextViewController( string: "let x = 10;", language: .swift, config: SourceEditorConfiguration( appearance: .init(theme: theme, font: font), behavior: .init(indentOption: indentOption), layout: .init(editorOverscroll: editorOverscroll), peripherals: .init(showMinimap: showMinimap) ), cursorPositions: [CursorPosition(line: 0, column: 0)], highlightProviders: [], // Use the tree-sitter syntax highlighting provider by default undoManager: nil, coordinators: [], // Optionally inject editing behavior or other plugins. completionDelegate: nil, // Provide code suggestions while typing via a delegate object. jumpToDefinitionDelegate // Allow users to perform the 'jump to definition' using a delegate object. ) ``` ### Adding to View Hierarchy ```swift final class MyController: NSViewController { override func loadView() { super.loadView() let editorController: TextViewController = /**/ addChild(editorController) view.addSubview(editorController.view) editorController.view.viewDidMoveToSuperview() } } ``` For more AppKit API options, see the documentation on `TextViewController`. ``` -------------------------------- ### findStartOfLine(containing:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codeedittextview/textview/findstartofline%28containing%3A%29 This method returns the starting index of the line that contains the given `location`. ```APIDOC ## findStartOfLine(containing:) ### Description Finds the starting location of the line containing the specified location. ### Method Signature ```swift func findStartOfLine(containing location: Int) -> Int ``` ### Parameters #### Path Parameters - **location** (Int) - Required - The location within the text to find the start of its line. ``` -------------------------------- ### init(hex:alpha:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/swiftuicore/color/init%28hex%3Aalpha%3A%29-15u06 Initializes a `Color` from an Int (e.g.: `0x1D2E3F`) and an optional alpha value. ```APIDOC ## init(hex:alpha:) ### Description Initializes a `Color` from an Int (e.g.: `0x1D2E3F`) and an optional alpha value. ### Parameters #### Parameters - **hex** (Int) - Description: An Int of a HEX representation of a color (format: `0x1D2E3F`) - **alpha** (Double) - Description: A Double indicating the alpha value from `0.0` to `1.0` (default: `1.0`) ``` -------------------------------- ### CursorPosition Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/init%28start%3Aend%3A%29 Initializes a new instance of CursorPosition with a starting position and an optional ending position. ```APIDOC ## init(start:end:) ### Description Initializes a new instance of CursorPosition with a starting position and an optional ending position. ### Parameters #### Path Parameters - **start** (Position) - Required - The starting position of the cursor. - **end** (Position?) - Optional - The ending position of the cursor. If not provided, it defaults to the start position. ``` -------------------------------- ### Initialize SourceEditorConfiguration Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration Creates a new configuration object with specified appearance, behavior, layout, and peripherals. ```swift init(appearance: Appearance, behavior: Behavior, layout: Layout, peripherals: Peripherals) ``` -------------------------------- ### Get warningCharacters Set Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/warningcharacters Access the set of warning characters. This property is read-only and main-actor isolated. ```swift @MainActor var warningCharacters: Set { get } ``` -------------------------------- ### init(line:column:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/position/init%28line%3Acolumn%3A%29 Initializes a new instance of CursorPosition.Position with the specified line and column numbers. ```APIDOC ## init(line:column:) ### Description Initializes a new instance of CursorPosition.Position with the specified line and column numbers. ### Parameters #### Path Parameters - **line** (Int) - Required - The line number for the cursor position. - **column** (Int) - Required - The column number for the cursor position. ``` -------------------------------- ### Get EditorTheme Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/theme Access the current EditorTheme used for syntax highlighting. This property is main-actor isolated. ```swift @MainActor var theme: EditorTheme { get } ``` -------------------------------- ### Get Current Cursor Positions Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/cursorpositions Access the current cursor positions. The positions are ordered by their location. ```swift @MainActor var cursorPositions: [CursorPosition] { get } ``` -------------------------------- ### Get Empty Invisible Characters Configuration Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/invisiblecharactersconfiguration Provides a default, empty configuration for invisible characters. ```swift static var empty: InvisibleCharactersConfiguration ``` -------------------------------- ### Instance Methods Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/minimapview/textselectionmanagerdelegate-implementations Methods for managing display and calculating line heights. ```APIDOC ## Instance Methods ### `estimatedLineHeight()` - **Returns**: `CGFloat` - **Description**: Calculates and returns the estimated height of a single line of text. ``` ```APIDOC ### `setNeedsDisplay()` - **Description**: Invalidates the current view, prompting a redraw of the minimap and text selection. ``` -------------------------------- ### Initializers Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifierset/setalgebra-implementations Initializers for creating SetAlgebra instances. ```APIDOC ## Initializers ### `init(S)` Initializes a new instance of the SetAlgebra type from another SetAlgebra. ### `init(arrayLiteral: Self.Element...)` Initializes a new instance of the SetAlgebra type from a variadic array of elements. ``` -------------------------------- ### init(from:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/position/init%28from%3A%29 Initializes a CursorPosition.Position instance from a decoder. This method is inherited from the Decodable protocol. ```APIDOC ## init(from:) ### Description Initializes a `CursorPosition.Position` instance from a decoder. This method is inherited from the `Decodable` protocol. ### Signature ```swift init(from decoder: any Decoder) throws ``` ### Parameters * `decoder` - The decoder to read data from. ``` -------------------------------- ### help(_:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/help%28_%3A%29-84b2q Adds a help button to the view that presents the given text in a popover. ```APIDOC ## help(_:) ### Description Adds a help button to the view that presents the given text in a popover. ### Method func help(_ text: S) -> some View where S : StringProtocol ### Parameters #### Path Parameters - **text** (S) - The text to display in the help popover. It must conform to the StringProtocol. ### Availability - iOS 14.0+ - macOS 11.0+ - tvOS 14.0+ - watchOS 7.0+ ``` -------------------------------- ### Get Invisible Characters Configuration Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/invisiblecharactersconfiguration Access the configuration for drawing invisible characters. See `InvisibleCharactersConfiguration` for more details. ```swift @MainActor var invisibleCharactersConfiguration: InvisibleCharactersConfiguration { get } ``` -------------------------------- ### Get Default Line Height of NSFont Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/appkit/nsfont/lineheight Access the default line height of a font. This property is read-only. ```swift var lineHeight: Double { get } ``` -------------------------------- ### GutterView Initializers Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/gutterview Initializers for creating a GutterView instance. ```APIDOC ## Initializers ### `init(configuration: borrowing SourceEditorConfiguration, controller: TextViewController, delegate: GutterViewDelegate?)` Initializes a GutterView with a configuration, text view controller, and an optional delegate. ### `init(font: NSFont, textColor: NSColor, selectedTextColor: NSColor?, controller: TextViewController, delegate: GutterViewDelegate?)` Initializes a GutterView with specific font and color properties, a text view controller, and an optional delegate. ``` -------------------------------- ### help(_:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/help%28_%3A%29-7jl9i This instance method, inherited from `View.help(_:)`, allows you to attach help text to a view. It is available on iOS 14.0+, macOS 11.0+, tvOS 14.0+, and watchOS 7.0+. ```APIDOC ## help(_:) ### Description Attaches help text to a view. ### Method `func help(_ textKey: LocalizedStringKey) -> some View` ### Parameters - **textKey** (LocalizedStringKey) - The localized string key for the help text. ### Availability - iOS 14.0+ - macOS 11.0+ - tvOS 14.0+ - watchOS 7.0+ ``` -------------------------------- ### Instance Property: font Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/font The font property allows you to get the NSFont object used in the textView. It is a read-only property. ```APIDOC ## Instance Property: font ### Description The font to use in the `textView` ### Signature ```swift @MainActor var font: NSFont { get } ``` ### Usage This property is accessible to retrieve the current font settings of the text view. ``` -------------------------------- ### init(hex:alpha:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/swiftuicore/color/init%28hex%3Aalpha%3A%29-8yjdz Initializes a `Color` from a HEX String (e.g.: `#1D2E3F`) and an optional alpha value. ```APIDOC ## init(hex:alpha:) ### Description Initializes a `Color` from a HEX String (e.g.: `#1D2E3F`) and an optional alpha value. ### Parameters `hex` (String) - A String of a HEX representation of a color (format: `#1D2E3F`) `alpha` (Double) - A Double indicating the alpha value from `0.0` to `1.0` (defaults to 1.0) ``` -------------------------------- ### Get Text View Font Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/font Retrieves the NSFont currently used by the text view. This property is main-actor isolated. ```swift @MainActor var font: NSFont { get } ``` -------------------------------- ### Initializer: init(appearance:behavior:layout:peripherals:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/init%28appearance%3Abehavior%3Alayout%3Aperipherals%3A%29 Creates a new SourceEditorConfiguration object, allowing customization of the editor's appearance, behavior, layout, and peripherals. ```APIDOC ## Initializer: init(appearance:behavior:layout:peripherals:) ### Description Create a new configuration object. ### Parameters `appearance` (Appearance) - Required - Configure the appearance of the editor. Font, theme, line height, etc. `behavior` (Behavior) - Optional - Default: .init() - Configure the behavior of the editor. Indentation, edit-ability, select-ability, etc. `layout` (Layout) - Optional - Default: .init() - Configure the layout of the editor. Content insets, etc. `peripherals` (Peripherals) - Optional - Default: .init() - Configure enabled features on the editor. Gutter (line numbers), minimap, etc. ``` -------------------------------- ### LineFoldProviderLineInfo Enumeration Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/linefoldproviderlineinfo Defines the LineFoldProviderLineInfo enumeration. Use this to represent the start or end of a fold, specifying the range and new depth. ```swift enum LineFoldProviderLineInfo ``` -------------------------------- ### startFold Method Signature Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/linefoldproviderlineinfo/startfold%28rangestart%3Anewdepth%3A%29 Defines the signature for the startFold method, which takes a range start integer and a new depth integer. ```swift case startFold( rangeStart: Int, newDepth: Int ) ``` -------------------------------- ### init(from:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/init%28from%3A%29 Initializes a CursorPosition instance from a decoder. This method is inherited from the Decodable protocol. ```APIDOC ## init(from:) ### Description Initializes a CursorPosition instance from a decoder. This method is inherited from the Decodable protocol. ### Signature ```swift init(from decoder: any Decoder) throws ``` ### Parameters * `decoder` - The decoder to read data from. ``` -------------------------------- ### makeNSViewController(context:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/makensviewcontroller%28context%3A%29 Creates and returns a TextViewController instance. ```APIDOC ## Instance Method # makeNSViewController(context:) Inherited from `NSViewControllerRepresentable.makeNSViewController(context:)`. ```swift @MainActor func makeNSViewController(context: Context) -> TextViewController ``` ``` -------------------------------- ### CursorPosition Instance Properties Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition Properties of the CursorPosition struct, including the start and end positions of the cursor and the overall selection range. ```APIDOC ## Instance Properties ### `let end: Position?` The end position of the cursor or selection. ### `let range: NSRange` The range of the selection within the document. ### `let start: Position` The start position of the cursor or selection. ``` -------------------------------- ### Declare Position Type Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/start Declares a variable 'start' of type 'Position'. This is a common pattern for initializing cursor or selection boundaries. ```typescript let start: Position ``` -------------------------------- ### SwiftUI Source Editor Usage Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorview Demonstrates how to create a SwiftUI Source Editor with customizable themes, fonts, behavior, layout, and peripherals. It also shows how to integrate custom editing behavior using TextViewCoordinators. ```APIDOC ## SwiftUI Source Editor ### Description This section shows how to use the `SourceEditor` SwiftUI view for creating a source code editor. It covers basic text binding, state management for editor properties like cursor and scroll position, and configuration options for appearance, behavior, and layout. ### Usage ```swift import CodeEditSourceEditor struct ContentView: View { @State var text = "let x = 1.0" // For large documents use a text storage object (avoids SwiftUI comparisons) // var text: NSTextStorage /// Automatically updates with cursor positions, scroll position, find panel text. /// Everything in this object is two-way, use it to update cursor positions, scroll position, etc. @State var editorState = SourceEditorState() /// Configure the editor's appearance, features, and editing behavior... @State var theme = EditorTheme(...) @State var font = NSFont.monospacedSystemFont(ofSize: 11, weight: .regular) @State var indentOption = .spaces(count: 4) @State var editorOverscroll = 0.3 @State var showMinimap = true /// *Powerful* customization options with text coordinators @State var autoCompleteCoordinator = AutoCompleteCoordinator() var body: some View { SourceEditor( $text, language: language, configuration: SourceEditorConfiguration( appearance: .init(theme: theme, font: font), behavior: .init(indentOption: indentOption), layout: .init(editorOverscroll: editorOverscroll), peripherals: .init(showMinimap: showMinimap) ), state: $editorState, coordinators: [autoCompleteCoordinator] ) } /// Autocompletes "Hello" to "Hello world!" whenever it's typed. class AutoCompleteCoordinator: TextViewCoordinator { func prepareCoordinator(controller: TextViewController) { } func textViewDidChangeText(controller: TextViewController) { for cursorPosition in controller.cursorPositions.reversed() where cursorPosition.range.location >= 5 { let location = cursorPosition.range.location let previousRange = NSRange(start: location - 5, end: location) let string = (controller.text as NSString).substring(with: previousRange) if string.lowercased() == "hello" { controller.textView.replaceCharacters(in: NSRange(location: location, length: 0), with: " world!") } } } } } ``` ``` -------------------------------- ### CursorPosition Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/init%28start%3Aend%3A%29 Initializes a CursorPosition with a mandatory start position and an optional end position. Use this to define a selection or range. ```swift init( start: Position, end: Position? ) ``` -------------------------------- ### Instance Property: documentation Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/jumptodefinitionlink/documentation This property holds documentation information for a code suggestion entry. It is an optional String. ```swift var documentation: String? ``` -------------------------------- ### leadingRange(in:within:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codeedittextview/textview/leadingrange%28in%3Awithin%3A%29 Finds the range of characters in a given range that match a specified character set, starting from the beginning of the range. ```APIDOC ## leadingRange(in:within:) ### Description This method returns the range of characters within a specified `NSRange` that belong to a given `CharacterSet`, starting from the beginning of the `NSRange`. ### Method Signature ```swift func leadingRange(in range: NSRange, within set: CharacterSet) -> NSRange? ``` ### Parameters #### Path Parameters - **range** (`NSRange`) - The range within which to search. - **set** (`CharacterSet`) - The set of characters to match. ### Returns - (`NSRange?`) - An `NSRange` representing the leading range of matching characters, or `nil` if no such range is found. ``` -------------------------------- ### SwiftUI help(_:) Method Signature Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/help%28_%3A%29-84b2q This is the signature for the help(_:) method, which takes a StringProtocol and returns some View. It is available on iOS 14.0+, macOS 11.0+, tvOS 14.0+, and watchOS 7.0+. ```swift nonisolated func help(_ text: S) -> some View where S : StringProtocol ``` -------------------------------- ### Variable Declaration Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifier Illustrates how CaptureModifier can differentiate between variable declarations. 'var a' is a regular variable, while 'let b' is a constant. ```swift var a = 1 let b = 1 ``` -------------------------------- ### help(_:) Method Signature Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/help%28_%3A%29-2m51d This is the signature for the help(_:) method. It takes Text as an argument and returns some View. Available on iOS 14.0+, macOS 11.0+, tvOS 14.0+, and watchOS 7.0+. ```swift nonisolated func help(_ text: Text) -> some View ``` -------------------------------- ### Close Suggestion Window Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/suggestioncontroller Provides a method to close the suggestion window. No specific setup is required beyond having an instance of SuggestionController. ```swift func close() ``` -------------------------------- ### Position Initializers Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/position Details the available initializers for creating a Position instance. ```APIDOC ## Initializers ### `init(from: any Decoder) throws` Initializes a Position instance from a Decoder. ### `init(line: Int, column: Int)` Initializes a Position instance with a specific line and column number. ``` -------------------------------- ### MinimapView Instance Methods Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/minimapview Lists essential instance methods for MinimapView, including hit testing, layout, mouse event handling, cursor rectangle resetting, and theme updating. ```swift func hitTest(NSPoint) -> NSView? ``` ```swift func layout() ``` ```swift func mouseDown(with: NSEvent) ``` ```swift func mouseDragged(with: NSEvent) ``` ```swift func resetCursorRects() ``` ```swift func setTheme(EditorTheme) ``` -------------------------------- ### Get Completion Trigger Characters Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codesuggestiondelegate/completiontriggercharacters%28%29-66zs9 Returns a set of characters that should trigger code completion. This is useful for configuring when suggestions appear. ```swift @MainActor func completionTriggerCharacters() -> Set ``` -------------------------------- ### isFlipped Property Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/gutterview/isflipped The gutter's y positions start at the top of the document and increase as it moves down the screen. This property indicates if this behavior is flipped. ```APIDOC ## isFlipped ### Description The gutter's y positions start at the top of the document and increase as it moves down the screen. ### Property `@MainActor override var isFlipped: Bool { get }` ``` -------------------------------- ### onChange(of:initial:_:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/onchange%28of%3Ainitial%3A_%3A%29-8mcfl This method allows you to observe changes in a specified value. When the value changes, the provided action closure is executed. It supports observing equatable values and has an optional `initial` parameter to determine if the action should run when the view is first loaded. ```APIDOC ## Instance Method # onChange(of:initial:_:) Inherited from `View.onChange(of:initial:_:)`. CodeEditSourceEditorSwiftUICoreiOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+ ```swift nonisolated func onChange( of value: V, initial: Bool = false, _ action: @escaping () -> Void ) -> some View where V : Equatable ``` ### Parameters - **value** (V): The equatable value to observe for changes. - **initial** (Bool): A boolean indicating whether the action should be executed when the view is initially loaded. Defaults to `false`. - **action** (@escaping () -> Void): The closure to execute when the `value` changes. ``` -------------------------------- ### Instance Method: substring(from:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/foundation/nsstring/substring%28from%3A%29 This method returns a substring starting from the given `NSRange` to the end of the string. It returns `nil` if the range is invalid. ```APIDOC ## Instance Method # substring(from:) Inherited from `TextStoring.substring(from:)`. ```swift func substring(from range: NSRange) -> String? ``` ### Parameters - **range** (`NSRange`) - The starting range for the substring. ``` -------------------------------- ### SourceEditor Instance Methods Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor Details the instance methods available for the SourceEditor, including methods for creating coordinators and managing the underlying NSViewController. ```APIDOC ## Instance Methods ### `func makeCoordinator() -> Coordinator` Creates a coordinator for the SourceEditor. ### `func makeNSViewController(context: Context) -> TextViewController` Creates the TextViewController for the SourceEditor. ### `func updateNSViewController(TextViewController, context: Context)` Updates the TextViewController when the SourceEditor's state changes. ``` -------------------------------- ### scenePadding(_:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/scenepadding%28_%3A%29 Applies padding to the view's edges, respecting the scene's safe area and layout guides. Defaults to all edges. ```APIDOC ## scenePadding(_:) ### Description Applies padding to the view's edges, respecting the scene's safe area and layout guides. Defaults to all edges. ### Method `func scenePadding(_ edges: Edge.Set = .all) -> some View` ### Parameters #### Path Parameters - **edges** (Edge.Set) - Optional - The set of edges to apply padding to. Defaults to `.all`. ### Inheritance Inherited from `View.scenePadding(_:)`. ### Availability CodeEditSourceEditorSwiftUICore iOS 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+ ``` -------------------------------- ### Initialize Invisible Characters Configuration Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/invisiblecharactersconfiguration Initializes the configuration with specific settings for showing spaces, tabs, and line endings. ```swift init(showSpaces: Bool, showTabs: Bool, showLineEndings: Bool) ``` -------------------------------- ### transition(_:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditor/transition%28_%3A%29 Applies a transition to a view. This method is inherited from the `View` protocol. ```APIDOC ## transition(_:) ### Description Applies a transition to a view. This method is inherited from the `View` protocol. ### Signature ```swift nonisolated func transition(_ t: AnyTransition) -> some View ``` ### Parameters - **t** (`AnyTransition`) - The transition to apply to the view. ### Returns Some `View` with the specified transition applied. ``` -------------------------------- ### Find Nodes at Location in TreeSitterClient Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/treesitterclient/nodesat%28location%3A%29-1pg9a Call this method to get all language nodes at a specific text location. It may throw a TreeSitterClient.Error. ```swift func nodesAt(location: Int) async throws -> [NodeResult] ``` -------------------------------- ### Get Tab Width Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/tabwidth Retrieves the current visual width of tab characters in the text view, measured in spaces. This is a read-only property. ```swift @MainActor var tabWidth: Int { get } ``` -------------------------------- ### Get editorOverscroll Value Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/editoroverscroll This property returns the overscroll value as a CGFloat. A value of 0.3 means 1/3 of the view's height. ```swift @MainActor var editorOverscroll: CGFloat { get } ``` -------------------------------- ### TextViewController Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller Initializes a new instance of TextViewController with specified parameters. ```APIDOC ## TextViewController Initializer ### Description Initializes a new instance of TextViewController with the provided string content, language, configuration, cursor positions, highlight providers, fold provider, undo manager, coordinators, completion delegate, and jump to definition delegate. ### Signature `init(string: String, language: CodeLanguage, configuration: SourceEditorConfiguration, cursorPositions: [CursorPosition], highlightProviders: [HighlightProviding], foldProvider: LineFoldProvider?, undoManager: CEUndoManager?, coordinators: [TextViewCoordinator], completionDelegate: CodeSuggestionDelegate?, jumpToDefinitionDelegate: JumpToDefinitionDelegate?)` ``` -------------------------------- ### Retrieve Text Attributes Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/attributesfor%28_%3A%29 Use this method to get styling attributes for a specific capture name. It's part of the ThemeAttributesProviding protocol. ```swift @MainActor func attributesFor(_ capture: CaptureName?) -> [NSAttributedString.Key : Any] ``` -------------------------------- ### TextViewController Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/init%28string%3Alanguage%3Aconfiguration%3Acursorpositions%3Ahighlightproviders%3Afoldprovider%3Aundomanager%3Acoordinators%3Acompletiondelegate%3Ajumptodefinitiondelegate%3A%29 Initializes a new instance of TextViewController with the specified string content, language, configuration, cursor positions, and optional providers/delegates. ```APIDOC ## init(string:language:configuration:cursorPositions:highlightProviders:foldProvider:undoManager:coordinators:completionDelegate:jumpToDefinitionDelegate:) ### Description Initializes a new instance of TextViewController. ### Parameters - **string** (String) - The initial text content for the editor. - **language** (CodeLanguage) - The programming language for syntax highlighting and other language-specific features. - **configuration** (SourceEditorConfiguration) - The configuration object for the source editor. - **cursorPositions** ([CursorPosition]) - An array of initial cursor positions. - **highlightProviders** ([HighlightProviding]) - An array of providers for syntax highlighting. Defaults to `[TreeSitterClient()]`. - **foldProvider** (LineFoldProvider?) - An optional provider for code folding. - **undoManager** (CEUndoManager?) - An optional undo manager for handling text edits. - **coordinators** ([TextViewCoordinator]) - An array of text view coordinators. - **completionDelegate** (CodeSuggestionDelegate?) - An optional delegate for code completion suggestions. - **jumpToDefinitionDelegate** (JumpToDefinitionDelegate?) - An optional delegate for handling jump-to-definition actions. ``` -------------------------------- ### Initialize SourceEditorConfiguration.Appearance Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/appearance-swift.struct/init%28theme%3Ausethemebackground%3Afont%3Alineheightmultiple%3Aletterspacing%3Awraplines%3Ausesystemcursor%3Atabwidth%3Abracketpairemphasis%3A%29 Use this initializer to create a new appearance configuration object for the Source Editor. Customize properties like theme, font, line height, letter spacing, line wrapping, system cursor usage, tab width, and bracket pair emphasis. ```swift init( theme: EditorTheme, useThemeBackground: Bool = true, font: NSFont, lineHeightMultiple: Double = 1.2, letterSpacing: Double = 1.0, wrapLines: Bool, useSystemCursor: Bool = true, tabWidth: Int = 4, bracketPairEmphasis: BracketPairEmphasis? = .flash ) ``` -------------------------------- ### Get the full text range Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codeedittextview/textview/fullrange Use this property to access the NSRange representing the entire content of the text view. It is a read-only property. ```swift var fullRange: NSRange { get } ``` -------------------------------- ### init(line:column:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/init%28line%3Acolumn%3A%29 Initializes a cursor position with the specified line and column. The range will be initialized to NSNotFound and updated later. ```APIDOC ## init(line:column:) ### Description Initialize a cursor position. ### Method Initializer ### Parameters #### Path Parameters - **line** (Int) - Required - The line of the cursor position, 1-indexed. - **column** (Int) - Required - The column of the cursor position, 1-indexed. ### Discussion When this initializer is used, `range` will be initialized to `NSNotFound`. The range value, however, be filled when updated by `SourceEditor` via a `Binding`, or when it appears in the `cursorPositions` array. ``` -------------------------------- ### CaptureName.typeAlternate Case Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturename/typealternate Demonstrates the basic syntax for the typeAlternate case within CaptureName. This is typically used for specific data type handling. ```swift case typeAlternate ``` -------------------------------- ### SourceEditorConfiguration.Peripherals Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/peripherals-swift.struct/init%28showgutter%3Ashowminimap%3Ashowreformattingguide%3Ashowfoldingribbon%3Ainvisiblecharactersconfiguration%3Awarningcharacters%3A%29 Initializes a SourceEditorConfiguration.Peripherals object with specified peripheral visibility and configuration settings. ```APIDOC ## init(showGutter:showMinimap:showReformattingGuide:showFoldingRibbon:invisibleCharactersConfiguration:warningCharacters:) ### Description Initializes a SourceEditorConfiguration.Peripherals object with specified peripheral visibility and configuration settings. ### Parameters - **showGutter** (Bool) - Optional - Controls the visibility of the gutter. - **showMinimap** (Bool) - Optional - Controls the visibility of the minimap. - **showReformattingGuide** (Bool) - Optional - Controls the visibility of the reformatting guide. - **showFoldingRibbon** (Bool) - Optional - Controls the visibility of the folding ribbon. - **invisibleCharactersConfiguration** (InvisibleCharactersConfiguration) - Optional - Configuration for displaying invisible characters. - **warningCharacters** (Set) - Optional - A set of characters to be treated as warnings. ### Default Values - showGutter: true - showMinimap: true - showReformattingGuide: false - showFoldingRibbon: true - invisibleCharactersConfiguration: .empty - warningCharacters: [] ### Code Example ```swift let config = SourceEditorConfiguration.Peripherals( showGutter: true, showMinimap: false, showReformattingGuide: true, showFoldingRibbon: false, invisibleCharactersConfiguration: .init(character: "•", color: .gray), warningCharacters: [0x200B] // Zero-width space ) ``` ``` -------------------------------- ### Deprecated Capture Modifier Example Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/capturemodifier/deprecated This snippet shows the syntax for a deprecated capture modifier. Ensure JavaScript is enabled for full page functionality. ```swift case deprecated ``` -------------------------------- ### Retrieve Attributes for Capture Name Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/themeattributesproviding/attributesfor%28_%3A%29 Use this method to get the attributed string properties for a specific capture group. It returns a dictionary of `NSAttributedString.Key` to `Any`. ```swift func attributesFor(_ capture: CaptureName?) -> [NSAttributedString.Key : Any] ``` -------------------------------- ### Initialize MinimapView Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/minimapview/init%28textview%3Atheme%3A%29 Creates a minimap view that tracks a given text view and uses a specified editor theme. Ensure this is called on the main actor. ```swift @MainActor init( textView: TextView, theme: EditorTheme ) ``` -------------------------------- ### Appearance Initializer Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/sourceeditorconfiguration/appearance-swift.struct Initializes a new appearance configuration object with specified settings for theme, font, line height, letter spacing, line wrapping, cursor style, tab width, and bracket pair emphasis. ```APIDOC ## init(theme: EditorTheme, useThemeBackground: Bool, font: NSFont, lineHeightMultiple: Double, letterSpacing: Double, wrapLines: Bool, useSystemCursor: Bool, tabWidth: Int, bracketPairEmphasis: BracketPairEmphasis?) ### Description Create a new appearance configuration object. ### Parameters - **theme** (EditorTheme) - The theme for syntax highlighting. - **useThemeBackground** (Bool) - Determines whether the editor uses the theme’s background color, or a transparent background color. - **font** (NSFont) - The default font. - **lineHeightMultiple** (Double) - The line height multiplier (e.g. `1.2`). - **letterSpacing** (Double) - The amount of space to use between letters, as a percent. Eg: `1.0` = no space, `1.5` = 1/2 a character’s width between characters, etc. Defaults to `1.0`. - **wrapLines** (Bool) - Whether lines wrap to the width of the editor. - **useSystemCursor** (Bool) - If true, uses the system cursor on `>=macOS 14`. - **tabWidth** (Int) - The visual tab width in number of spaces. - **bracketPairEmphasis** (BracketPairEmphasis?) - The type of highlight to use to highlight bracket pairs. See `BracketPairEmphasis` for more information. Defaults to `.flash`. ``` -------------------------------- ### Toggle Minimap Visibility Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/textviewcontroller/showminimap Access this property to get the current visibility state of the minimap. It is an instance property and must be accessed on the main actor. ```swift @MainActor var showMinimap: Bool { get } ``` -------------------------------- ### findNextOccurrenceOfCharacter(in:from:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/codeedittextview/textview/findnextoccurrenceofcharacter%28in%3Afrom%3A%29 Searches for the next character that belongs to the provided `CharacterSet` starting from the specified `location`. Returns the index of the found character or `nil` if no such character is found. ```APIDOC ## findNextOccurrenceOfCharacter(in:from:) ### Description Finds the next occurrence of a character from a given set starting from a specific location. ### Method Signature ```swift func findNextOccurrenceOfCharacter( in set: CharacterSet, from location: Int ) -> Int? ``` ### Parameters #### Path Parameters - **set** (CharacterSet) - Required - The set of characters to search for. - **location** (Int) - Required - The starting index for the search. ### Returns - **Int?** - The index of the next occurrence of a character from the set, or `nil` if no such character is found. ``` -------------------------------- ### CursorPosition init(from:) Source: https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor/cursorposition/init%28from%3A%29 Initializes a CursorPosition instance from a decoder. This is inherited from the Decodable protocol and is used when decoding data. ```swift init(from decoder: any Decoder) throws ```