### NeonPlugin Initialization Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/00-START-HERE.txt This example shows how to initialize the NeonPlugin with a default theme and the Swift language. This is the primary method for enabling syntax highlighting in STTextView. ```swift import STPluginNeon // Usage: NeonPlugin (main entry point) // Import: import STPluginNeon // Usage: textView.addPlugin(NeonPlugin(theme: .default, language: .swift)) ``` -------------------------------- ### NeonPlugin setUp Method (macOS) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md The setUp method is automatically called when the plugin is registered. It configures event listeners for text changes and viewport updates. ```swift public func setUp(context: any Context) ``` -------------------------------- ### SwiftUI Minimal Complete Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Provides an example of using the STTextView with the Neon plugin within a SwiftUI view. It demonstrates how to pass the plugin as part of the TextView initializer. ```swift import SwiftUI import STTextViewUI import STPluginNeon struct ContentView: View { @State private var text: AttributedString = "" var body: some View { STTextViewUI.TextView( text: $text, plugins: [NeonPlugin(theme: .default, language: .swift)] ) } } ``` -------------------------------- ### Theme Usage Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/types.md Shows how to create custom Theme.Colors and Theme.Fonts instances and use them to initialize a Theme and then a NeonPlugin. ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray ]) let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium) ]) let theme = Theme(colors: colors, fonts: fonts) let plugin = NeonPlugin(theme: theme, language: .swift) ``` -------------------------------- ### Initialize NeonPlugin with Default Theme Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Example of how to instantiate the NeonPlugin using the predefined default theme. ```swift let plugin = NeonPlugin(theme: .default, language: .swift) ``` -------------------------------- ### Plugin Setup on Main Thread Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/module-architecture.md Ensures that plugin setup and addition to the text view occurs on the main thread for thread safety. ```swift DispatchQueue.main.async { textView.addPlugin(plugin) } ``` -------------------------------- ### TokenName Usage Examples Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/types.md Demonstrates how to initialize and use the TokenName type. Examples include direct string literal assignment and explicit initialization. ```swift // String literal let tokenName: TokenName = "keyword" // Explicit initialization let tokenName2 = TokenName("comment") // Retrieve from theme let color = theme.color(forToken: "string") ``` -------------------------------- ### Create a Theme Instance Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Example of creating a Theme instance by defining colors and fonts for specific token types. This demonstrates how to populate the Theme.Colors and Theme.Fonts structs. ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen ]) let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) ]) let theme = Theme(colors: colors, fonts: fonts) ``` -------------------------------- ### Instantiate NeonPlugin Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/module-architecture.md Example of how to instantiate the NeonPlugin. This code works identically on both macOS and iOS due to the cross-platform abstraction. ```swift let plugin = NeonPlugin(theme: .default, language: .swift) // Works on macOS and iOS identically ``` -------------------------------- ### NeonPlugin setUp Method Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md Called automatically when the plugin is registered with a text view. Sets up event listeners for text changes and viewport updates. ```APIDOC ## setUp Method ### Description Called automatically when the plugin is registered with a text view. Sets up event listeners for text changes and viewport updates. ### Method `setUp(context: any Context)` ### Parameters #### Path Parameters - **context** (`any Context`) - Required - STPlugin context providing event callbacks and coordinator access. ### Behavior This method registers three event handlers: - `onWillChangeText`: Notifies the tree-sitter parser before text changes - `onDidChangeText`: Notifies the parser after text changes with delta information - `onDidLayoutViewport`: Updates viewport range for efficient highlighting of visible content ``` -------------------------------- ### macOS Minimal Complete Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Demonstrates how to set up an STTextView with the Neon plugin on macOS. This includes creating the text view, adding the plugin, and setting initial text content. ```swift import Cocoa import STTextView import STPluginNeon // Create text view let textView = STTextView() // Create and add plugin let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) // Set text content textView.textContentManager.insertText("func main() {}") ``` -------------------------------- ### Get Token Color Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Demonstrates how to use the color(forToken:) method to retrieve and print the color for a 'keyword' token. This is useful for dynamically styling code elements. ```swift if let keywordColor = theme.color(forToken: "keyword") { print("Keyword color: \(keywordColor)") } ``` -------------------------------- ### Complete Example: Custom Theme with Colors and Fonts Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Demonstrates creating a fully custom theme by defining both colors and fonts, then applying it to the NeonPlugin. Ensure the STPluginNeon import is present. ```swift import STPluginNeon // Define custom colors let colors = Theme.Colors(colors: [ "plain": NSColor(hexString: "#D4D4D4")!, "keyword": NSColor(hexString: "#569CD6")!, "comment": NSColor(hexString: "#6A9955")!, "string": NSColor(hexString: "#CE9178")!, "number": NSColor(hexString: "#B5CEA8")!, "operator": NSColor(hexString: "#D4D4D4")!, "function.call": NSColor(hexString: "#DCDCAA")!, "type": NSColor(hexString: "#4EC9B0")!, "variable": NSColor(hexString: "#9CDCFE")! ]) // Define custom fonts let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular), "string": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) ]) // Create theme let customTheme = Theme(colors: colors, fonts: fonts) // Use with plugin let plugin = NeonPlugin(theme: customTheme, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### Example Query File Syntax Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/module-architecture.md Demonstrates the S-expression syntax used in Tree-sitter query files for defining matching patterns. ```scheme ; highlights.scm - Example (keyword) @keyword (comment) @comment (string) @string ``` -------------------------------- ### iOS Minimal Complete Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Shows how to integrate the STTextView with the Neon plugin in an iOS application. This involves initializing the text view and adding the plugin. ```swift import UIKit import STTextViewUIKit import STPluginNeon // Create text view let textView = STTextView() // Create and add plugin let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### iOS/Catalyst UIColor+hex Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Shows the equivalent usage of the hex initializer for UIColor on iOS and Catalyst, demonstrating API consistency across platforms. ```swift // iOS let iosColor = UIColor(hexString: "#FF0000") // Pure red ``` -------------------------------- ### TokenName Usage Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/token-name.md Demonstrates how to create a custom theme and use TokenName to look up theme styles. ```APIDOC ## Usage Example ```swift import STPluginNeon // Creating a custom theme with TokenName let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen, "number": NSColor.systemOrange ]) let theme = Theme(colors: colors, fonts: Theme.Fonts(fonts: [:])) // Using TokenName to look up theme styles let commentColor = theme.color(forToken: TokenName("comment")) let stringColor = theme.color(forToken: "string") // String literal convenience ``` See also: [Theme](./theme.md), [NeonPlugin](./neon-plugin.md) ``` -------------------------------- ### NeonPlugin Methods Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Methods available on the NeonPlugin class for initialization and setup. ```APIDOC ## NeonPlugin ### Methods - `init(theme:language:)` - Parameters: - `theme`: Theme? - Optional theme to apply. - `language`: TreeSitterLanguage - The language for syntax highlighting. - Returns: Self - The initialized NeonPlugin instance. - `setUp(context:)` - Parameters: - `context`: Context - The context for setting up the plugin. - Returns: Void - `makeCoordinator(context:)` - Parameters: - `context`: CoordinatorContext - The context for creating the coordinator. - Returns: Coordinator - The created Coordinator instance. ``` -------------------------------- ### Theme Definition Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Demonstrates using the NSColor hex initializer within a theme definition structure, providing fallback colors in case of invalid hex strings. ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor(hexString: "#0066CC") ?? .blue, "comment": NSColor(hexString: "#888888") ?? .gray, "string": NSColor(hexString: "#00AA00") ?? .green, "error": NSColor(hexString: "#FF0000AA") ?? .red // With transparency ]) ``` -------------------------------- ### NeonPlugin Initialization and Usage Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/00-START-HERE.txt This snippet demonstrates the basic setup for adding the NeonPlugin to an STTextView. Ensure STTextView and STPluginNeon are imported. The plugin is initialized with a default theme and the Swift language, then added to the text view. ```swift import STTextView import STPluginNeon // Create text view let textView = STTextView() // Create and add highlighting plugin let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) // Done! Syntax highlighting is now active ``` -------------------------------- ### Add NeonPlugin to STTextView (macOS) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md Example of initializing and adding a NeonPlugin to an STTextView on macOS. Ensure STTextView and STPluginNeon are imported. ```swift import STTextView import STPluginNeon let textView = STTextView() let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### iOS Color Configuration Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/quick-start.md Example of how to define colors for the Neon plugin on iOS using UIColor and a hex string extension. Ensure UIKit is imported. ```swift import UIKit let iosColors = Theme.Colors(colors: [ "keyword": UIColor(hexString: "#0066CC")!, "comment": UIColor(hexString: "#888888")!, "string": UIColor(hexString: "#00AA00")! ]) ``` -------------------------------- ### Get Highlight Query URL Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/tree-sitter-language.md Obtain the URL to the highlights.scm query file for a language. This file contains rules used for semantic token highlighting. ```swift let language: TreeSitterLanguage = .swift if let queryURL = language.highlightQueryURL { let queryString = try String(contentsOf: queryURL, encoding: .utf8) // Use queryString to parse and highlight Swift code } ``` -------------------------------- ### NeonPlugin Integration in SwiftUI TextView (iOS/Catalyst) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md Example demonstrating how to integrate NeonPlugin into an STTextView within a SwiftUI view. The plugin is passed as part of the plugins array during TextView initialization. ```swift import SwiftUI import STTextViewUI import STPluginNeon struct ContentView: View { @State private var text: AttributedString = "" @State private var selection: NSRange? var body: some View { STTextViewUI.TextView( text: $text, selection: $selection, options: [.wrapLines, .highlightSelectedLine], plugins: [NeonPlugin(theme: .default, language: .swift)] ) .textViewFont(.monospacedDigitSystemFont(ofSize: 14, weight: .regular)) } } ``` -------------------------------- ### Initialize Theme Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/quick-start.md Create a custom theme for syntax highlighting, specifying colors and fonts. ```swift // With custom colors and fonts Theme(colors: customColors, fonts: customFonts) ``` -------------------------------- ### Common Token Names Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/token-name.md Examples of commonly used TokenName constants. ```APIDOC ## Common Token Names These are the standard token categories recognized by themes: ```swift let keyword: TokenName = "keyword" let comment: TokenName = "comment" let string: TokenName = "string" let number: TokenName = "number" let function_call: TokenName = "function.call" let type: TokenName = "type" let variable: TokenName = "variable" let operator: TokenName = "operator" let keyword_function: TokenName = "keyword.function" let keyword_return: TokenName = "keyword.return" let method: TokenName = "method" let parameter: TokenName = "parameter" let boolean: TokenName = "boolean" let include: TokenName = "include" let constructor: TokenName = "constructor" let builtin: TokenName = "variable.builtin" let text_literal: TokenName = "text.literal" let text_title: TokenName = "text.title" let punctuation_special: TokenName = "punctuation.special" let plain: TokenName = "plain" ``` ``` -------------------------------- ### 6-Digit RGB Hex Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Creates an NSColor from a 6-digit hexadecimal string. The '#' prefix is optional. ```swift let color = NSColor(hexString: "#FF0000") // Pure red let color2 = NSColor(hexString: "00FF00") // Pure green (no # prefix) ``` -------------------------------- ### Get Font for Token Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Retrieves the font associated with a specific semantic token name from the theme. ```APIDOC ## Get Font for Token ### Description Retrieves the font associated with a specific semantic token name from the theme. Returns `nil` if the token name is not found. ### Method `font(forToken tokenName: TokenName) -> NSFont?` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters - **tokenName** (TokenName) - Required - The semantic token category to look up ### Request Example ```swift if let keywordFont = theme.font(forToken: "keyword") { print("Keyword font: \(keywordFont)") } ``` ### Response #### Success Response (200) - **NSFont?** - The font for this token, or `nil` if not defined. #### Response Example ```json { "example": "NSFont.monospacedSystemFont(ofSize: 14, weight: .medium)" } ``` ``` -------------------------------- ### Get Color for Token Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Retrieves the color associated with a specific semantic token name from the theme. ```APIDOC ## Get Color for Token ### Description Retrieves the color associated with a specific semantic token name from the theme. Returns `nil` if the token name is not found. ### Method `color(forToken tokenName: TokenName) -> NSColor?` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters - **tokenName** (TokenName) - Required - The semantic token category to look up ### Request Example ```swift if let keywordColor = theme.color(forToken: "keyword") { print("Keyword color: \(keywordColor)") } ``` ### Response #### Success Response (200) - **NSColor?** - The color for this token, or `nil` if not defined. #### Response Example ```json { "example": "NSColor.systemBlue" } ``` ``` -------------------------------- ### Initialize Theme.Colors Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/quick-start.md Define theme colors either from a dictionary of token names to NSColor or by loading from an asset catalog. ```swift // From dictionary Theme.Colors(colors: ["keyword": .blue]) ``` ```swift // From asset catalog Theme.Colors(bundle: Bundle.module, name: "neon.plugin.default") ``` -------------------------------- ### Theme Constructor Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Initializes a Theme with specified colors and fonts. ```APIDOC ## Theme Constructor ### Description Initializes a Theme with specified colors and fonts. ### Signature ```swift public init(colors: Colors, fonts: Fonts) ``` ### Parameters #### Path Parameters - **colors** (Colors) - Required - Semantic token colors. - **fonts** (Fonts) - Required - Semantic token fonts. ``` -------------------------------- ### Coordinator Initialization Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/coordinator.md Initializes the Coordinator, setting up the Tree-sitter language parser, text view client, and Neon highlighter. This process includes applying default theme fonts and performing an initial parse and highlight pass. It must be called on the main thread. ```APIDOC ## Coordinator Initialization ### Description Initializes the Coordinator, setting up the Tree-sitter language parser, text view client, and Neon highlighter. This process includes applying default theme fonts and performing an initial parse and highlight pass. It must be called on the main thread. ### Method init ### Parameters #### Path Parameters - **textView** (STTextView) - Yes - The text view to highlight - **theme** (Theme) - Yes - Colors and fonts for tokens - **language** (TreeSitterLanguage) - Yes - Language parser to use ### Behavior 1. Creates a tree-sitter `Language` instance from the language parser 2. Initializes a `TreeSitterClient` that coordinates parsing with the text view's content manager 3. Sets up the tree-sitter invalidation handler to notify Neon of parse changes 4. Applies theme's default font to the text view 5. Creates a Neon `Highlighter` with an `STTextViewSystemInterface` adapter 6. Performs an initial full-document parse and highlighting pass **Note:** Marked with `@MainActor` — must be created and called from the main thread. ``` -------------------------------- ### 8-Digit RGBA Hex Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Creates an NSColor from an 8-digit hexadecimal string, including an alpha channel. The '#' prefix is optional. ```swift let color = NSColor(hexString: "#FF0000CC") // Red with 80% opacity (204/255 ≈ 0.8) ``` -------------------------------- ### Custom Theme Creation and TokenName Usage Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/token-name.md Demonstrates how to create a custom theme with specific colors for different TokenName categories and how to retrieve theme styles using TokenName instances. ```swift import STPluginNeon // Creating a custom theme with TokenName let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen, "number": NSColor.systemOrange ]) let theme = Theme(colors: colors, fonts: Theme.Fonts(fonts: [:])) // Using TokenName to look up theme styles let commentColor = theme.color(forToken: TokenName("comment")) let stringColor = theme.color(forToken: "string") // String literal convenience ``` -------------------------------- ### STPlugin Protocol Definition Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/module-architecture.md Defines the core STPlugin protocol, which must be conformed to by any plugin. It includes methods for setup and coordinator creation. ```swift public protocol STPlugin { func setUp(context: any Context) func makeCoordinator(context: CoordinatorContext) -> Coordinator } ``` -------------------------------- ### Theme.Colors Initializer with Dictionary Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Colors instance from a dictionary of token names to colors. This allows for direct programmatic definition of colors. ```APIDOC ## Theme.Colors(colors:) ### Description Creates a Colors instance from a dictionary of token names to colors. This allows for direct programmatic definition of colors. ### Method init ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **colors** (`[String: NSColor]`) - Required - Dictionary mapping token name strings to colors ### Request Example ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen, "number": NSColor.systemOrange ]) ``` ### Response #### Success Response None (Initializers do not return values in this context) #### Response Example None ``` -------------------------------- ### 3-Digit Shorthand Hex Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Creates an NSColor from a 3-digit hexadecimal shorthand string. The '#' prefix is optional. The format is automatically expanded to 6 digits. ```swift // Automatically expanded to 6-digit format let color = NSColor(hexString: "#F0A") // Equivalent to #FF00AA ``` -------------------------------- ### Initialize NeonPlugin Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/quick-start.md Initialize NeonPlugin with a default or custom theme and specify the language for syntax highlighting. ```swift // With theme and language NeonPlugin(theme: .default, language: .swift) ``` ```swift // Custom theme NeonPlugin(theme: customTheme, language: .python) ``` -------------------------------- ### Loading Query Files in Swift Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/module-architecture.md Illustrates how query files are loaded using the Tree-sitter query() method in Swift. ```swift language.highlightQueryURL → Tree-sitter .query() method → Query object ``` -------------------------------- ### Initialize NeonPlugin Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Instantiate NeonPlugin with a theme and language, then add it to an STTextView instance. ```swift let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### Standard Token Names Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/types.md Provides examples of common semantic token category names that can be used with the TokenName type. These can be directly assigned using string literals. ```swift let keyword: TokenName = "keyword" let comment: TokenName = "comment" let string: TokenName = "string" let number: TokenName = "number" let function_call: TokenName = "function.call" let type: TokenName = "type" let variable: TokenName = "variable" let operator: TokenName = "operator" let method: TokenName = "method" let parameter: TokenName = "parameter" ``` -------------------------------- ### Initialize Theme Fonts with Dictionary Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Create a font theme by providing a dictionary of token types to NSFont objects. This allows for granular control over the appearance of different code elements. ```swift public struct Theme.Fonts { public init(fonts: [String: NSFont]) public init(bundle: Bundle, name: String) } ``` ```swift let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .semibold), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular), "string": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular), "type": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "constructor": NSFont.monospacedSystemFont(ofSize: 14, weight: .bold) ]) ``` -------------------------------- ### Initialize Theme.Fonts with Bundle and Name Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Fonts instance using default font weights based on token semantics. The bundle parameter is currently unused. Use this for applying predefined font styles. ```swift public init(bundle: Bundle, name: String) ``` ```swift let fonts = Theme.Fonts(bundle: Bundle.module, name: "neon.plugin.default") ``` -------------------------------- ### Automatic Plugin and Coordinator Creation Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/types.md Demonstrates the automatic creation and addition of a NeonPlugin to a text view. Manual access to the coordinator is shown for advanced use cases. ```swift // Automatic creation via plugin let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) // To access coordinator (advanced usage) if let context = textView.context(for: NeonPlugin.self), let coordinator = context.coordinator as? Coordinator { // Access coordinator if needed _ = coordinator.highlighter } ``` -------------------------------- ### Configure Neon Plugin on iOS & Catalyst (UIKit) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Integrate the Neon plugin with STTextView for iOS and Catalyst applications using UIKit. This setup utilizes UIColor and UIFont. ```swift import UIKit import STTextViewUIKit import STPluginNeon let textView = STTextView() let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### Create Custom Theme Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Create a custom theme by providing custom colors and fonts. ```swift let theme = Theme(colors: customColors, fonts: customFonts) ``` -------------------------------- ### Theme Initialization Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Initializes a new Theme object with specified colors and fonts. This is used to create custom themes for syntax highlighting. ```APIDOC ## Theme Initialization ### Description Initializes a new `Theme` object with specified colors and fonts. This is used to create custom themes for syntax highlighting. ### Method `init(colors: Colors, fonts: Fonts)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen ]) let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) ]) let theme = Theme(colors: colors, fonts: fonts) ``` ### Response #### Success Response (200) None (initialization) #### Response Example None ``` -------------------------------- ### Alpha Override Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Creates an NSColor using a hexadecimal string and explicitly overriding the alpha value. This is useful when the hex string has an embedded alpha that needs to be ignored or modified. ```swift // Override the hex string's embedded alpha let color = NSColor(hexString: "#FF0000", alpha: 0.5) // Red with 50% opacity let color2 = NSColor(hexString: "#FF0000FF", alpha: 0.3) // Overrides FF with 0.3 ``` -------------------------------- ### Initialize Theme.Fonts Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/quick-start.md Define theme fonts either from a dictionary of token names to NSFont or by loading default weights from an asset catalog. ```swift // From dictionary Theme.Fonts(fonts: ["keyword": NSFont(...)]) ``` ```swift // Default weights Theme.Fonts(bundle: Bundle.module, name: "neon.plugin.default") ``` -------------------------------- ### Theme Initializer Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Initializes a new Theme with specified color and font mappings. Provide Theme.Colors and Theme.Fonts instances to define the theme's appearance. ```swift public init(colors: Colors, fonts: Fonts) ``` -------------------------------- ### 4-Digit Shorthand RGBA Hex Example Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/nscolor-hex.md Creates an NSColor from a 4-digit hexadecimal shorthand string, including an alpha channel. The '#' prefix is optional. The format is automatically expanded to 8 digits. ```swift // RGBA shorthand let color = NSColor(hexString: "#F0A8") // Equivalent to #FF00AA88 ``` -------------------------------- ### iOS Theme Colors Initialization Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Demonstrates initializing theme colors for iOS using UIColor. This is specific to the iOS implementation where UIColor replaces NSColor. ```swift let colors = Theme.Colors(colors: [ "keyword": UIColor.systemBlue, "comment": UIColor.systemGray ]) ``` -------------------------------- ### Get Locals Query URL for Scope Tracking Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/tree-sitter-language.md Retrieve the URL for the locals.scm query file, used for variable scope tracking and scope-aware highlighting. This is optional and not available for all languages. ```swift let language: TreeSitterLanguage = .swift if let localsURL = language.localsQueryURL { // Scope information available for advanced highlighting let localsString = try String(contentsOf: localsURL, encoding: .utf8) } ``` -------------------------------- ### Theme.Colors Methods Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Methods for initializing and retrieving colors. ```APIDOC ## Theme.Colors ### Methods - `init(colors:)` - Parameters: - `colors`: [String: NSColor] - A dictionary of token names to NSColors. - Returns: Self - `init(bundle:name:)` - Parameters: - `bundle`: Bundle - The bundle to load colors from. - `name`: String - The name of the color set. - Returns: Self - `color(forToken:)` - Parameters: - `token`: TokenName - The name of the token. - Returns: NSColor? - The NSColor for the token, if available. ``` -------------------------------- ### Theme.Fonts.init(fonts:) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Fonts instance from a dictionary of token names to fonts. This initializer allows direct control over which font is assigned to each token name. ```APIDOC ## Theme.Fonts.init(fonts:) ### Description Creates a Fonts instance from a dictionary of token names to fonts. ### Method `init(fonts: [String: NSFont])` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **fonts** (`[String: NSFont]`) - Required - Dictionary mapping token name strings to fonts. ### Request Example ```swift let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) ]) ``` ### Response #### Success Response An instance of `Theme.Fonts`. #### Response Example (Instance creation, no direct response object to display) ``` -------------------------------- ### Coordinator Initialization Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/coordinator.md Initializes the Coordinator with a text view, theme, and language parser. This process involves setting up Tree-sitter, applying theme fonts, and performing an initial parse. ```swift init(textView: STTextView, theme: Theme, language: TreeSitterLanguage) ``` -------------------------------- ### Theme Initializers Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Provides different ways to initialize a Theme object, either by providing colors and fonts directly or by loading them from a bundle. ```APIDOC ## Theme Initializers ### Description Provides different ways to initialize a Theme object, either by providing colors and fonts directly or by loading them from a bundle. ### Method `init(colors: Colors, fonts: Fonts)` ### Parameters - `colors` (Colors) - Required - The color scheme for the theme. - `fonts` (Fonts) - Required - The font settings for the theme. ### Method `init(bundle: Bundle, name: String)` ### Parameters - `bundle` (Bundle) - Required - The bundle to load theme resources from. - `name` (String) - Required - The name of the theme resources to load. ``` -------------------------------- ### NeonPlugin Constructor Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Initializes the NeonPlugin with optional theme and a required language parser. ```APIDOC ## NeonPlugin Constructor ### Description Initializes the NeonPlugin with optional theme and a required language parser. ### Signature ```swift public init(theme: Theme = .default, language: TreeSitterLanguage) ``` ### Parameters #### Path Parameters - **theme** (Theme) - Optional - Colors and fonts for tokens. Defaults to `.default`. - **language** (TreeSitterLanguage) - Required - Language parser to use. ``` -------------------------------- ### NeonPlugin Initializer Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Initializes the NeonPlugin with a specified theme and language. A default theme is used if none is provided. ```APIDOC ## NeonPlugin Initializer ### Description Initializes the NeonPlugin with a specified theme and language. A default theme is used if none is provided. ### Method `init(theme: Theme = .default, language: TreeSitterLanguage)` ### Parameters - `theme` (Theme) - Optional - The theme to apply to the text view. Defaults to `Theme.default`. - `language` (TreeSitterLanguage) - Required - The programming language to use for syntax highlighting. ``` -------------------------------- ### Theme.Fonts.init(bundle:name:) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Fonts instance with default font weights per token type. This initializer is useful for applying predefined font styles based on token semantics. ```APIDOC ## Theme.Fonts.init(bundle:name:) ### Description Creates a Fonts instance with default font weights per token type. ### Method `init(bundle: Bundle, name: String)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **bundle** (`Bundle`) - Required - Bundle (unused in current implementation). - **name** (`String`) - Required - Identifier for the font set. ### Request Example ```swift let fonts = Theme.Fonts(bundle: Bundle.module, name: "neon.plugin.default") ``` ### Response #### Success Response An instance of `Theme.Fonts` with default font weights assigned based on token semantics. #### Response Example (Instance creation, no direct response object to display) ``` -------------------------------- ### Create Custom Colors with Dictionary Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Initialize `Theme.Colors` using a dictionary mapping semantic token names to `NSColor` objects. This allows for fine-grained control over syntax highlighting colors. ```swift let colors = Theme.Colors(colors: [ "plain": NSColor.textColor, "keyword": NSColor.systemBlue, "comment": NSColor.systemGray, "string": NSColor.systemGreen, "number": NSColor.systemOrange, "boolean": NSColor.systemRed, "operator": NSColor.controlAccentColor, "function.call": NSColor.systemPurple, "method": NSColor.systemPurple, "type": NSColor.systemBrown, "variable": NSColor.labelColor, "variable.builtin": NSColor.systemCyan, "parameter": NSColor.systemYellow, "constructor": NSColor.systemPink, "include": NSColor.systemIndigo, "keyword.function": NSColor.systemBlue, "keyword.return": NSColor.systemBlue, "text.literal": NSColor.systemTeal, "text.title": NSColor.headerTextColor, "punctuation.special": NSColor.labelColor ]) ``` -------------------------------- ### Using TreeSitterLanguage in NeonPlugin Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/types.md Demonstrates how to initialize NeonPlugin with a specific language and iterate through all supported TreeSitterLanguages. Also shows how to check for locals query support. ```swift let plugin = NeonPlugin(theme: .default, language: .swift) // Iterate all languages for language in TreeSitterLanguage.allCases { print(language) } // Check for locals query support if TreeSitterLanguage.javascript.localsQueryURL != nil { print("Scope tracking available") } ``` -------------------------------- ### Use Hex Colors in SwiftUI Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/uicolor-hex.md Demonstrates how to use UIColor hex initializers within a SwiftUI view, particularly for syntax highlighting plugins. ```swift import SwiftUI import STPluginNeon struct MyEditorView: View { var body: some View { let colors = Theme.Colors(colors: [ "keyword": UIColor(hexString: "#4A90E2")!, "comment": UIColor(hexString: "#999999")! ]) STTextViewUI.TextView( text: .constant(AttributedString("print('hello')")), plugins: [ NeonPlugin( theme: Theme(colors: colors, fonts: Theme.Fonts(fonts: [:])), language: .python ) ] ) } } ``` -------------------------------- ### Neon Plugin Initialization with Custom Theme Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Initializes the NeonPlugin with a custom theme, defining specific colors and fonts for tokens. Add the plugin to a text view. ```swift let customTheme = Theme( colors: Theme.Colors(colors: [ "keyword": NSColor(hexString: "#0066CC")!, "comment": NSColor(hexString: "#888888")!, "string": NSColor(hexString: "#00AA00")! ]), fonts: Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium) ]) ) let plugin = NeonPlugin(theme: customTheme, language: .python) textView.addPlugin(plugin) ``` -------------------------------- ### Initialize Theme.Fonts with a Dictionary Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Fonts instance from a dictionary of token name strings to NSFont objects. Use this when you have specific font instances to assign. ```swift public init(fonts: [String: NSFont]) ``` ```swift let fonts = Theme.Fonts(fonts: [ "keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium), "comment": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) ]) ``` -------------------------------- ### Theme.Fonts Methods Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Methods for initializing and retrieving fonts. ```APIDOC ## Theme.Fonts ### Methods - `init(fonts:)` - Parameters: - `fonts`: [String: NSFont] - A dictionary of token names to NSFonts. - Returns: Self - `init(bundle:name:)` - Parameters: - `bundle`: Bundle - The bundle to load fonts from. - `name`: String - The name of the font set. - Returns: Self - `font(forToken:)` - Parameters: - `token`: TokenName - The name of the token. - Returns: NSFont? - The NSFont for the token, if available. ``` -------------------------------- ### Theme.Colors Initializers Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Initializes Theme.Colors either from a dictionary of NSColor objects or by loading from a bundle. ```APIDOC ## Theme.Colors Initializers ### Description Initializes Theme.Colors either from a dictionary of NSColor objects or by loading from a bundle. ### Method `init(colors: [String: NSColor])` ### Parameters - `colors` ([String: NSColor]) - Required - A dictionary mapping color names to NSColor objects. ### Method `init(bundle: Bundle, name: String)` ### Parameters - `bundle` (Bundle) - Required - The bundle to load color resources from. - `name` (String) - Required - The name of the color resources to load. ``` -------------------------------- ### Theme.Colors Constructor (Bundle) Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Initializes Theme.Colors by loading colors from a specified bundle and name. This is useful for loading predefined color themes. ```swift public init(bundle: Bundle, name: String) ``` -------------------------------- ### Initialize Colors from Asset Catalog Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Colors instance by loading colors from an asset catalog within a specified bundle. This is useful for managing colors externally and loading a predefined set of standard token colors. ```swift public init(bundle: Bundle, name: String) ``` ```swift let colors = Theme.Colors(bundle: Bundle.module, name: "neon.plugin.default") ``` -------------------------------- ### Minimal Neon Plugin Initialization Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Initializes the NeonPlugin with default theme and a specified language. Add the plugin to a text view. ```swift import STPluginNeon let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) ``` -------------------------------- ### Initialize NeonPlugin Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Instantiate NeonPlugin with a theme and language. This operation is safe to call synchronously from the main thread. ```swift // Safe to call from main thread synchronously let plugin = NeonPlugin(theme: .default, language: .swift) textView.addPlugin(plugin) // Synchronous setup ``` -------------------------------- ### Initialize Theme Fonts with Default Weights Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Initialize fonts using a bundle and name to apply default font weights defined by the plugin. Font size is inherited from the text view. ```swift let fonts = Theme.Fonts(bundle: Bundle.module, name: "neon.plugin.default") ``` -------------------------------- ### NeonPlugin Initializer Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md Initializes a NeonPlugin instance with an optional theme and a required language parser. ```APIDOC ## NeonPlugin Initializer ### Description Initializes a NeonPlugin instance with an optional theme and a required language parser. ### Method `init(theme: Theme = .default, language: TreeSitterLanguage)` ### Parameters #### Path Parameters - **theme** (`Theme`) - Optional - Theme containing colors and fonts for syntax tokens. Defaults to `.default`. - **language** (`TreeSitterLanguage`) - Required - Programming language parser to use for syntax highlighting. ### Returns Initialized `NeonPlugin` instance ready to be added to an STTextView. ### Request Example ```swift let plugin = NeonPlugin(theme: .default, language: .swift) ``` ``` -------------------------------- ### Configure Theme for Syntax Highlighting Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-overview.md Define a Theme with custom colors and fonts for syntax highlighting. Use Theme.default for a pre-configured theme. Platform-specific color and font types are used. ```swift public struct Theme { public let colors: Colors public let fonts: Fonts public init(colors: Colors, fonts: Fonts) public func color(forToken tokenName: TokenName) -> NSColor? // macOS public func color(forToken tokenName: TokenName) -> UIColor? // iOS public func font(forToken tokenName: TokenName) -> NSFont? // macOS public func font(forToken tokenName: TokenName) -> UIFont? // iOS } ``` -------------------------------- ### NeonPlugin makeCoordinator Method Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/neon-plugin.md Creates and returns the coordinator that manages syntax highlighting state. ```APIDOC ## makeCoordinator Method ### Description Creates and returns the coordinator that manages syntax highlighting state. ### Method `makeCoordinator(context: CoordinatorContext) -> Coordinator` ### Parameters #### Path Parameters - **context** (`CoordinatorContext`) - Required - Context containing the text view for the coordinator. ### Returns Configured `Coordinator` instance managing highlighting for this text view. ``` -------------------------------- ### Theme.Colors Initializer from Asset Catalog Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Creates a Colors instance by loading colors from an asset catalog within a specified bundle. This is useful for managing colors defined in Xcode asset catalogs. ```APIDOC ## Theme.Colors(bundle:name:) ### Description Creates a Colors instance by loading colors from an asset catalog. This is useful for managing colors defined in Xcode asset catalogs. ### Method init ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **bundle** (`Bundle`) - Required - Bundle containing the color assets - **name** (`String`) - Required - Asset catalog base name (e.g., "neon.plugin.default") ### Request Example ```swift let colors = Theme.Colors(bundle: Bundle.module, name: "neon.plugin.default") ``` ### Response #### Success Response None (Initializers do not return values in this context) #### Response Example None ``` -------------------------------- ### Create Custom Colors with Hex Strings Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Initialize `Theme.Colors` using a dictionary of hex color strings. This is a convenient way to define specific colors for syntax tokens. ```swift let colors = Theme.Colors(colors: [ "keyword": NSColor(hexString: "#0066CC")!, "comment": NSColor(hexString: "#888888")!, "string": NSColor(hexString: "#00AA00")!, "number": NSColor(hexString: "#FF6600")! ]) ``` -------------------------------- ### Initialize NeonPlugin with Default Theme Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Use the default theme and specify the language when initializing NeonPlugin. The default theme loads colors from the `neon.plugin.default` asset catalog and uses standard monospace fonts. ```swift let plugin = NeonPlugin(theme: .default, language: .python) ``` -------------------------------- ### NSColor+hex / UIColor+hex Methods Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Initializers for creating NSColor or UIColor from a hex string. ```APIDOC ## NSColor+hex / UIColor+hex ### Methods - `init?(hexString:alpha:)` - Parameters: - `hexString`: String - The hex color string (e.g., "#RRGGBB"). - `alpha`: Float? - Optional alpha value (0.0 to 1.0). - Returns: Self? - An initialized NSColor or UIColor, or nil if the hex string is invalid. ``` -------------------------------- ### Default Theme Configuration Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/theme.md Defines the default theme using pre-configured colors and fonts from the module's bundle. This is the primary way to initialize the theme for general use. ```swift extension Theme { public static let `default` = Theme( colors: Colors(bundle: Bundle.module, name: "neon.plugin.default"), fonts: Fonts(bundle: Bundle.module, name: "neon.plugin.default") ) } ``` -------------------------------- ### Initialize Theme Fonts with Custom Families Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/configuration.md Create a font theme by specifying custom font families and sizes for different token types. Falls back to monospaced or system fonts if custom fonts are not found. ```swift let monospaceFont = NSFont(name: "Monaco", size: 13) ?? NSFont.userMonospacedFont(ofSize: 13) let serifFont = NSFont(name: "Georgia", size: 13) ?? NSFont.systemFont(ofSize: 13) let fonts = Theme.Fonts(fonts: [ "plain": monospaceFont, "keyword": NSFont(name: "Monaco", size: 13, weight: .semibold) ?? monospaceFont, "comment": serifFont ]) ``` -------------------------------- ### Initialize UIColor from Hex String Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/api-reference/uicolor-hex.md Demonstrates how to initialize a UIColor from a hex string. Handles invalid hex formats by returning nil. Use optional binding to safely unwrap the color or provide a fallback. ```swift let invalidColor = UIColor(hexString: "GGGGGG") // nil (G not valid hex) let tooShort = UIColor(hexString: "#FF") // nil (must be 3, 4, 6, or 8 digits) let tooLong = UIColor(hexString: "#FFFFFFFFFF") // nil (too many digits) if let color = UIColor(hexString: "#FF0000") { // Use color } else { // Handle invalid hex string or use fallback let fallback = UIColor.systemRed } ``` -------------------------------- ### Coordinator Methods Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/INDEX.md Methods for updating viewport range and handling content changes. ```APIDOC ## Coordinator ### Methods - `updateViewportRange(_:)` - Parameters: - `range`: NSTextRange? - The text range to update. - Returns: Void - `willChangeContent(in:)` - Parameters: - `range`: NSRange - The range that will change. - Returns: Void - `didChangeContent(_:in:delta:limit:)` - Parameters: - `textContentManager`: NSTextContentManager - The text content manager. - `range`: NSRange - The range that changed. - `delta`: Int - The change in length. - `limit`: Int - The limit for the change. - Returns: Void ``` -------------------------------- ### Theme.Colors Constructor Source: https://github.com/krzyzanowskim/sttextview-plugin-neon/blob/main/_autodocs/README.md Constructs Theme.Colors using a dictionary of colors or from a bundle. ```APIDOC ## Theme.Colors Constructor ### Description Constructs Theme.Colors using a dictionary of colors or from a bundle. ### Signatures ```swift public init(colors: [String: NSColor]) public init(bundle: Bundle, name: String) ``` ### Parameters #### Path Parameters (for `init(colors: [String: NSColor])`) - **colors** ([String: NSColor]) - Required - A dictionary mapping color names to NSColor objects. #### Path Parameters (for `init(bundle: Bundle, name: String)`) - **bundle** (Bundle) - Required - The bundle to load resources from. - **name** (String) - Required - The name of the color resource. ```