### Starting LSP Server via WebSocket Proxy Source: https://pub.dev/packages/code_forge Command to start the LSP server using lsp-ws-proxy. Ensure you navigate to the correct directory and that the lsp-ws-proxy executable is available. ```bash cd /Downloads/lsp-ws-proxy_linux # Navigate to the directory where lsp-ws-proxy is located ./lsp-ws-proxy --listen 5656 -- basedpyright-langserver --stdio # Start the pyright language server on port 5656 ``` -------------------------------- ### Basic Editor Setup with Controllers Source: https://pub.dev/packages/code_forge Demonstrates how to initialize the CodeForge editor with optional controller instances for managing editor state and undo/redo functionality. ```dart class _EditorState extends State { final _controller = CodeForgeController(); final _undoController = UndoRedoController(); @override Widget build(BuildContext context) { return CodeForge( controller: _controller, // Optional controller for more features. undoController: _undoController, // Optional undo controller to control the undo-redo operations. ); } } ``` -------------------------------- ### Setup Dart LSP Configuration Source: https://pub.dev/packages/code_forge A function to set up the Dart LSP configuration using `LspStdioConfig.start`. This is intended to be used with a `FutureBuilder` to initialize the editor. ```dart Future setupDartLsp() async { return await LspStdioConfig.start( executable: 'dart', args: ['language-server', '--protocol=lsp'], workspacePath: '/path/to/your/project', languageId: 'dart', ); } ``` -------------------------------- ### Run flutter pub get Source: https://pub.dev/packages/code_forge After adding the dependency, run this command in your terminal to fetch the package. ```bash flutter pub get ``` -------------------------------- ### Configure CodeForge with WebSocket LSP Source: https://pub.dev/packages/code_forge Example of creating an LspSocketConfig for WebSocket-based LSP integration. Ensure the serverUrl, workspacePath, and languageId are correctly set for your LSP server. ```dart final lspConfig = LspSocketConfig( workspacePath: "/home/athul/Projects/lsp", languageId: "python", serverUrl: "ws://localhost:5656" ), ``` -------------------------------- ### Example pubspec.yaml Dependency Source: https://pub.dev/packages/code_forge/install This is an example of how the code_forge dependency will appear in your pubspec.yaml file after running `flutter pub add`. ```yaml dependencies: code_forge: ^9.9.0 ``` -------------------------------- ### Initialize CodeForgeWeb with LSP Configuration Source: https://pub.dev/packages/code_forge_web This example demonstrates how to initialize the CodeForgeWeb widget with LSP features enabled. It requires setting up a CodeForgeWebController with LspSocketConfig, specifying the workspace path, language ID, and the WebSocket URL for the LSP server. ```dart class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State { late final CodeForgeWebController controller; @override void initState() { super.initState(); controller = CodeForgeWebController( lspConfig: LspSocketConfig( workspacePath: "file:///workspace", // Virtual workspace name languageId: "dart", // Language id serverUrl: "ws://localhost:9000" // The LSP server url. ) ); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( body: SafeArea( child: CodeForgeWeb( // Working url of any file. fileUrl: "https://raw.githubusercontent.com/heckmon/code_forge/main/lib/code_forge/controller.dart", controller: controller, textStyle: GoogleFonts.jetBrainsMono(fontSize: 20), innerPadding: EdgeInsets.only(top: 10), ) ), ), ); } } ``` -------------------------------- ### Run Dart Language Server via WebSocket Source: https://pub.dev/packages/code_forge_web This command shows how to start a Dart language server using the lsp-ws-proxy package. It listens on all interfaces on port 9000 and forwards requests to the Dart language server. This server can then be connected to by the code_forge_web package. ```bash ./lsp-ws-proxy --listen 0.0.0.0:9000 -- dart language-server --protocol=lsp ``` -------------------------------- ### Configure LspClientCapabilities Source: https://pub.dev/packages/code_forge Pass LspClientCapabilities to LspSocketConfig or LspStdioConfig to enable specific LSP features during language server initialization. This example shows enabling semantic highlighting, code completion, hover info, and more. ```dart // Pass to LspSocketConfig or LspStdioConfig final lspConfig = LspSocketConfig( workspacePath: "/path/to/workspace", languageId: "dart", serverUrl: "ws://localhost:5656", capabilities: LspClientCapabilities( semanticHighlighting: true, // Semantic token highlighting codeCompletion: true, // Code completion suggestions hoverInfo: true, // Hover documentation codeAction: true, // Code actions and quick fixes signatureHelp: true, // Signature help documentColor: true, // Document color detection documentHighlight: true, // Symbol occurrence highlighting codeFolding: true, // Code folding ranges inlayHint: true, // Inlay hints goToDefinition: true, // Go to definition rename: true, // Symbol renaming ), ); ``` -------------------------------- ### Import code_forge_web in Dart Source: https://pub.dev/packages/code_forge_web/install Import the code_forge_web package into your Dart code to start using its functionalities. ```dart import 'package:code_forge_web/code_forge_web.dart'; ``` -------------------------------- ### Add External Code Snippets to Suggestions Source: https://pub.dev/packages/code_forge/changelog Allows adding external code snippets to suggestions using the `customCodeSnippets` parameter on the editor. This is useful for providing custom code examples within the suggestion list. ```dart Editor(customCodeSnippets: [...]); ``` -------------------------------- ### Initialize Python LSP Configuration Source: https://pub.dev/packages/code_forge Creates an asynchronous method to initialize the LSP configuration for Python using `LspStdioConfig.start`. This method handles potential errors during initialization. ```dart Future _initLsp() async { try { final config = await LspStdioConfig.start( executable: '/home/athul/.nvm/versions/node/v20.19.2/bin/basedpyright-langserver', args: ['--stdio'], workspacePath: '/home/athul/Projects/lsp', languageId: 'python', ); return config; } catch (e) { debugPrint('LSP Initialization failed: $e'); return null; } } ``` -------------------------------- ### Initialize Code Forge Editor with LSP Source: https://pub.dev/packages/code_forge/example Sets up the CodeForge widget with LSP configuration for Dart. Ensure the LSP server is correctly configured and accessible. ```dart import 'dart:io'; import 'package:example/finder.dart'; import 'package:path/path.dart' as p; import 'package:code_forge/code_forge.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:re_highlight/languages/dart.dart'; import 'package:re_highlight/styles/atom-one-dark-reasonable.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State { final undoController = UndoRedoController(); final absFilePath = p.join(Directory.current.path, "lib/example_code.dart"); CodeForgeController? codeController; Future getLsp() async { final absWorkspacePath = p.join(Directory.current.path, "lib"); final data = await LspStdioConfig.start( executable: "dart", args: ["language-server", "--protocol=lsp"], workspacePath: absWorkspacePath, languageId: "dart", ); return data; } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( floatingActionButton: FloatingActionButton( onPressed: () { codeController?.setGitDiffDecorations( addedRanges: [(1, 5), (10, 25)], removedRanges: [ ( afterLine: 29, content: 'final x = 10;\nfinal y = 20;\nprint("removed line");', ), ], ); codeController?.scrollToLine(30); }, ), body: SafeArea( child: FutureBuilder( future: getLsp(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } if (!snapshot.hasData) { return const Center(child: Text("Failed to load LSP")); } final lspConfig = snapshot.data!; if (codeController == null || codeController!.lspConfig != lspConfig) { codeController = CodeForgeController(lspConfig: lspConfig); } return CodeForge( undoController: undoController, language: langDart, editorTheme: atomOneDarkReasonableTheme, controller: codeController, textStyle: GoogleFonts.jetBrainsMono(), filePath: absFilePath, matchHighlightStyle: const MatchHighlightStyle( currentMatchStyle: TextStyle( backgroundColor: Color(0xFFFFA726), ), otherMatchStyle: TextStyle( backgroundColor: Color(0x55FFFF00), ), ), finderBuilder: (c, controller) => FindPanelView(controller: controller), customCodeSnippets: [ CustomCodeSnippet( label: 'if', value: 'if (condition) {\n \n}', cursorLocations: {4}, ), CustomCodeSnippet( label: 'if-else', value: 'if (condition) {\n \n} else {\n \n}', cursorLocations: {18, 31}, ), ], ); }, ), ), ), ); } } ``` -------------------------------- ### Initialize CodeForge Controller with LSP Config Source: https://pub.dev/packages/code_forge Shows how to pass the configured LspSocketConfig to the CodeForgeController and then use this controller when initializing the CodeForge widget. ```dart final _controller = CodeForgeController( lspConfig: lspConfig // Pass the LspConfig here. ) CodeForge( controller: _controller, // Pass the controller here. theme: anOldHopeTheme, filePath: "/home/athul/Projects/lsp/example.py" ), ``` -------------------------------- ### Integrate Dart LSP with FutureBuilder and CodeForge Source: https://pub.dev/packages/code_forge Demonstrates using `FutureBuilder` with `setupDartLsp` to initialize the LSP configuration for Dart. The configuration is then passed to `CodeForgeController`. ```dart // In your widget @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: SafeArea( child: FutureBuilder( future: setupDartLsp(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return CircularProgressIndicator(); } return CodeForge( language: langDart, textStyle: GoogleFonts.jetBrainsMono(), controller: CodeForgeController( lspConfig: snapshot.data ), filePath: '/path/to/your/file.dart', // Mandatory field ) }, ), ), ), ); } ``` -------------------------------- ### Integrate LSP Configuration with FutureBuilder Source: https://pub.dev/packages/code_forge Uses a `FutureBuilder` to asynchronously initialize the LSP configuration and pass it to the `CodeForgeController` widget. Displays a loading indicator while waiting for the configuration. ```dart @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: SafeArea( child: FutureBuilder( future: _initLsp(), // Call the async method to get the LSP config. builder: (context, snapshot) { if(snapshot.connectionState == ConnectionState.waiting) { return Center(child: CircularProgressIndicator()); } return CodeForge( editorTheme: anOldHopeTheme, controller: CodeForgeController( lspConfig: snapshot.data // Pass the config here. ), filePath: '/home/athul/Projects/lsp/example.py', textStyle: TextStyle(fontSize: 15, fontFamily: 'monospace'), ); } ), ) ), ); } ``` -------------------------------- ### Basic CodeForge Usage Source: https://pub.dev/packages/code_forge Demonstrates how to integrate CodeForge into a Flutter application. Import a theme and language from re_highlight for syntax highlighting and editor appearance. Defaults to Dart language and vs2015Theme. ```dart import 'package:flutter/material.dart'; import 'package:code_forge/code_forge.dart'; import 'package:re_highlight/languages/python.dart'; import 'package:re_highlight/styles/atom-one-dark.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: CodeForge( language: langPython, // Defaults to langDart editorTheme: atomOneDarkTheme, // Defaults to vs2015Theme ), ), ); } } ``` -------------------------------- ### Initialize CodeForgeWebController Source: https://pub.dev/packages/code_forge_web/example Initializes the controller for the CodeForgeWeb widget, configuring the Language Server Protocol (LSP) with workspace path, language ID, and server URL. ```dart controller = CodeForgeWebController( lspConfig: LspSocketConfig( workspacePath: "file:///workspace", languageId: "dart", serverUrl: "ws://localhost:9000", ), ); ``` -------------------------------- ### Configure CodeForge Feature Toggles and Behavior Source: https://pub.dev/packages/code_forge Demonstrates how to enable or disable various features of the `CodeForge` editor, such as folding, gutter, guidelines, suggestions, and keyboard suggestions. Also shows how to control behavior like read-only mode, auto-focus, and line wrapping. ```dart CodeForge( // Enable/disable features enableFolding: true, // Code folding enableGutter: true, // Line numbers enableGuideLines: true, // Indentation guides enableGutterDivider: false, // Gutter separator line enableSuggestions: true, // Autocomplete enableKeyboardSuggestions: true // Suggestions from the OS keyboard // Behavior readOnly: false, // Read-only mode autoFocus: true, // Auto-focus on mount lineWrap: false, // Line wrapping ) ``` -------------------------------- ### MatchHighlightStyle Configuration Source: https://pub.dev/packages/code_forge Defines the visual styling for highlighting matching text, such as search results or bracket pairs. ```APIDOC ### MatchHighlightStyle #### Description Specifies the visual styles for highlighting matching text elements, like search results or corresponding brackets. #### Parameters: - `currentMatchStyle` (TextStyle): The text style for the currently highlighted match. - `otherMatchStyle` (TextStyle): The text style for other, non-current matches. ``` -------------------------------- ### SuggestionStyle Constructor Source: https://pub.dev/packages/code_forge Defines the styling for suggestion popups, including shape, colors, and text appearance. ```dart SuggestionStyle( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), backgroundColor: Colors.grey[900]!, focusColor: Colors.blue.withOpacity(0.3), hoverColor: Colors.blue.withOpacity(0.1), splashColor: Colors.blue.withOpacity(0.2), textStyle: TextStyle(color: Colors.white), ) ``` -------------------------------- ### Customize CodeForge Editor Theme and Styling Source: https://pub.dev/packages/code_forge Shows how to customize the `CodeForge` editor's appearance by setting the `editorTheme`, `textStyle`, `aiCompletionTextStyle`, `selectionStyle`, `gutterStyle`, `suggestionStyle`, `hoverDetailsStyle`, and `matchHighlightStyle`. ```dart CodeForge( controller: controller, language: langDart, // Editor theme (syntax colors) editorTheme: vs2015Theme, // Text styling textStyle: GoogleFonts.jetBrainsMono(fontSize: 14), // AI Completion styling aiCompletionTextStyle: TextStyle( color: Colors.grey, // Change the color of the AI completion text fontStyle: FontStyle.italic, // Make the AI completion text italic ), // Selection & cursor selectionStyle: CodeSelectionStyle( cursorColor: Colors.white, selectionColor: Colors.blue.withOpacity(0.3), cursorBubbleColor: Colors.blue, ), // Gutter (line numbers & fold icons) gutterStyle: GutterStyle( lineNumberStyle: TextStyle(color: Colors.grey), backgroundColor: Color(0xFF1E1E1E), activeLineNumberColor: Colors.white, foldedIconColor: Colors.grey, unfoldedIconColor: Colors.grey, errorLineNumberColor: Colors.red, warningLineNumberColor: Colors.orange, ), // Suggestion popup suggestionStyle: SuggestionStyle( backgroundColor: Color(0xFF252526), textStyle: TextStyle(color: Colors.white), elevation: 8, ), // Hover documentation hoverDetailsStyle: HoverDetailsStyle( backgroundColor: Color(0xFF252526), textStyle: TextStyle(color: Colors.white), ), // Highlight matching text using [controller.findWord()] and [controller.findRegex()] matchHighlightStyle: const MatchHighlightStyle( currentMatchStyle: TextStyle( backgroundColor: Color(0xFFFFA726), ), otherMatchStyle: TextStyle( backgroundColor: Color(0x55FFFF00), ), ), ) ``` -------------------------------- ### SuggestionStyle Configuration Source: https://pub.dev/packages/code_forge Defines the visual styling for suggestion popups, such as code completion suggestions. ```APIDOC ### SuggestionStyle #### Description Sets the visual style for suggestion menus, like those used for code completion. #### Parameters: - `shape` (ShapeBorder): The shape of the suggestion menu. - `backgroundColor` (Color): The background color of the suggestion menu. - `focusColor` (Color): The background color when an item is focused. - `hoverColor` (Color): The background color when hovering over an item. - `splashColor` (Color): The splash color when an item is tapped or clicked. - `textStyle` (TextStyle): The text style for items in the suggestion menu. ``` -------------------------------- ### Finding LSP Executable Path Source: https://pub.dev/packages/code_forge Command to locate the path of an LSP server executable using the 'which' command. This is necessary for stdio-based LSP configuration. ```bash which basedpyright-langserver ``` -------------------------------- ### MatchHighlightStyle Configuration Source: https://pub.dev/packages/code_forge Specifies the text styles for highlighting search matches, differentiating between the current match and other matches. ```dart matchHighlightStyle: const MatchHighlightStyle( currentMatchStyle: TextStyle( backgroundColor: Color(0xFFFFA726), ), otherMatchStyle: TextStyle( backgroundColor: Color(0x55FFFF00), ), ), ``` -------------------------------- ### CodeForgeController API Overview Source: https://pub.dev/packages/code_forge This snippet outlines the various methods available in the CodeForgeController for text operations, selection management, line manipulation, folding, search, navigation, and LSP features. It serves as a reference for interacting with the editor's core functionalities. ```dart final controller = CodeForgeController(); // Text operations controller.text = 'Hello, World!'; String content = controller.text; controller.getLineText(int lineIndex); controller.insertText(String text, int line, int character); controller.insertAtCurrentCursor(String text); // Selection & modification controller.selection = TextSelection(baseOffset: 0, extentOffset: 5); controller.selectAll(); controller.copy(); controller.cut(); controller.paste(); // Line operations int lineCount = controller.lineCount; String line = controller.getLineText(0); int lineStart = controller.getLineStartOffset(0); controller.duplicateLine(); controller.moveLineDown(); controller.moveLineUp(); controller.backspace(); controller.delete(); // Folding controller.foldAll(); controller.unfoldAll(); controller.toggleFold(lineNumber); // Search & find controller.findWord(String word, matchCase: false, matchWholeWord: false); controller.findRegex(String pattern); controller.searchHighlights = [ SearchHighlight(start: 0, end: 5, color: Colors.yellow), ]; // Scroll navigation controller.scrollToLine(int line); // Inlay hints await controller.fetchInlayHints(int startLine, int startCharacter, int endLine, int endCharacter); controller.showInlayHints(); controller.hideInlayHints(); controller.setInlayHints(List hints); controller.clearInlayHints(); // Document colors await controller.fetchDocumentColors(); // Document highlights await controller.fetchDocumentHighlights(int line, int character); controller.clearDocumentHighlights(); // LSP features await controller.callSignatureHelp(); controller.getCodeAction(); // Editor decorations controller.setGitDiffDecorations( addedRanges: [(int startLine, int endLine), ...], removedRanges: [...], modifiedRanges: [...], addedColor: const Color(0xFF4CAF50), removedColor: const Color(0xFFE53935), modifiedColor: const Color(0xFF2196F3), ); controller.clearGitDiffDecorations(); controller.addLineDecoration(LineDecoration decoration); controller.addLineDecorations(List decorations); controller.removeLineDecoration(String id); controller.addGutterDecoration(GutterDecoration decoration); controller.addGutterDecorations(List decorations); controller.removeGutterDecoration(String id); controller.clearGutterDecorations(); // Ghost text (inline suggestions) controller.setGhostText(GhostText ghostText); controller.clearGhostText(); // File operations controller.saveFile(); // Navigation controller.pressLeftArrowKey(isShiftPressed: false); controller.pressRightArrowKey(isShiftPressed: false); controller.pressUpArrowKey(isShiftPressed: false); controller.pressDownArrowKey(isShiftPressed: false); controller.pressHomeKey(isShiftPressed: false); controller.pressEndKey(isShiftPressed: false); controller.pressDocumentHomeKey(isShiftPressed: false); controller.pressDocumentEndKey(isShiftPressed: false); controller.pressWordLeftArrowKey(isShiftPressed: false); controller.pressWordRightArrowKey(isShiftPressed: false); // Multi-cursor operations controller.addMultiCursor(int line, int character); controller.clearMultiCursor(); controller.backspaceAtAllCursors(); controller.insertAtAllCursors(String textToInsert); ``` -------------------------------- ### CodeSelectionStyle Constructor Source: https://pub.dev/packages/code_forge Configures the appearance of the cursor and text selection within the code editor. ```dart CodeSelectionStyle({ Color? cursorColor, Color selectionColor, Color cursorBubbleColor, }) ``` -------------------------------- ### Pubspec.yaml Dependency Entry Source: https://pub.dev/packages/code_forge_web/install This is how the code_forge_web dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: code_forge_web: ^2.9.0 ``` -------------------------------- ### CodeSelectionStyle Configuration Source: https://pub.dev/packages/code_forge Defines the visual styling for text selection and cursor appearance. ```APIDOC ### CodeSelectionStyle #### Description Customizes the visual appearance of text selections and cursors within the code editor. #### Parameters: - `cursorColor` (Color?): Color of the text cursor. - `selectionColor` (Color): Color of the selected text background. - `cursorBubbleColor` (Color): Color of the cursor's bubble background. ``` -------------------------------- ### HoverDetailsStyle Configuration Source: https://pub.dev/packages/code_forge Defines the visual styling for hover information popups, such as documentation tooltips. ```APIDOC ### HoverDetailsStyle #### Description Customizes the appearance of popups that display detailed information when hovering over code elements. #### Parameters: - `shape` (ShapeBorder): The shape of the hover details popup. - `backgroundColor` (Color): The background color of the popup. - `focusColor` (Color): The background color when an item is focused. - `hoverColor` (Color): The background color when hovering over an item. - `splashColor` (Color): The splash color when an item is tapped or clicked. - `textStyle` (TextStyle): The text style for content within the popup. ``` -------------------------------- ### GutterStyle Constructor Source: https://pub.dev/packages/code_forge Defines the visual styling for the gutter in the code editor, including line number appearance, background color, and folding icon properties. ```dart GutterStyle({ TextStyle? lineNumberStyle, Color? backgroundColor, double? gutterWidth, IconData foldedIcon, IconData unfoldedIcon, double? foldingIconSize, Color? foldedIconColor, Color? unfoldedIconColor, Color? activeLineNumberColor, Color? inactiveLineNumberColor, Color errorLineNumberColor, Color warningLineNumberColor, Color? foldedLineHighlightColor, }) ``` -------------------------------- ### GutterStyle Configuration Source: https://pub.dev/packages/code_forge Defines the visual styling for the editor's gutter, including line numbers and folding icons. ```APIDOC ### GutterStyle #### Description Configures the appearance of the gutter in the code editor, such as line number styling, background color, and icons for folding. #### Parameters: - `lineNumberStyle` (TextStyle?): Style for the line numbers. - `backgroundColor` (Color?): Background color of the gutter. - `gutterWidth` (double?): Width of the gutter. - `foldedIcon` (IconData): Icon to display for folded code blocks. - `unfoldedIcon` (IconData): Icon to display for unfolded code blocks. - `foldingIconSize` (double?): Size of the folding icons. - `foldedIconColor` (Color?): Color of the folded icon. - `unfoldedIconColor` (Color?): Color of the unfolded icon. - `activeLineNumberColor` (Color?): Color for the line number of the active line. - `inactiveLineNumberColor` (Color?): Color for inactive line numbers. - `errorLineNumberColor` (Color): Color for line numbers with errors. - `warningLineNumberColor` (Color): Color for line numbers with warnings. - `foldedLineHighlightColor` (Color?): Highlight color for folded lines. ``` -------------------------------- ### CodeForgeController API Source: https://pub.dev/packages/code_forge Provides methods for manipulating text, selections, lines, and editor features within the CodeForge environment. ```APIDOC ## CodeForgeController API ### Description This section outlines the core functionalities of the CodeForgeController for interacting with and manipulating code editor content. ### Methods and Properties: **Text Operations** - `text` (String): Get or set the entire text content. - `getLineText(int lineIndex)`: Retrieves the text of a specific line. - `insertText(String text, int line, int character)`: Inserts text at a specified line and character position. - `insertAtCurrentCursor(String text)`: Inserts text at the current cursor position. **Selection & Modification** - `selection` (TextSelection): Get or set the current text selection. - `selectAll()`: Selects all text in the editor. - `copy()`: Copies the selected text to the clipboard. - `cut()`: Cuts the selected text to the clipboard. - `paste()`: Pastes text from the clipboard at the current cursor position. **Line Operations** - `lineCount` (int): Returns the total number of lines in the document. - `getLineStartOffset(int line)`: Gets the starting character offset of a given line. - `duplicateLine()`: Duplicates the current line. - `moveLineDown()`: Moves the current line down. - `moveLineUp()`: Moves the current line up. - `backspace()`: Simulates a backspace key press. - `delete()`: Simulates a delete key press. **Folding** - `foldAll()`: Folds all collapsible code blocks. - `unfoldAll()`: Unfolds all folded code blocks. - `toggleFold(int lineNumber)`: Toggles the fold state of a specific line. **Search & Find** - `findWord(String word, {bool matchCase = false, bool matchWholeWord = false})`: Finds occurrences of a specific word. - `findRegex(String pattern)`: Finds occurrences using a regular expression. - `searchHighlights` (List): Manages visual highlights for search results. **Scroll Navigation** - `scrollToLine(int line)`: Scrolls the editor to a specific line. **Inlay Hints** - `fetchInlayHints(int startLine, int startCharacter, int endLine, int endCharacter)`: Fetches inlay hints for a given range. - `showInlayHints()`: Displays inlay hints. - `hideInlayHints()`: Hides inlay hints. - `setInlayHints(List hints)`: Sets the inlay hints to be displayed. - `clearInlayHints()`: Clears all displayed inlay hints. **Document Colors** - `fetchDocumentColors()`: Fetches the colors used in the document. **Document Highlights** - `fetchDocumentHighlights(int line, int character)`: Fetches highlights for a specific position. - `clearDocumentHighlights()`: Clears all document highlights. **LSP Features** - `callSignatureHelp()`: Invokes signature help for the current context. - `getCodeAction()`: Retrieves available code actions. **Editor Decorations** - `setGitDiffDecorations(...)`: Applies decorations for Git diff information (added, removed, modified ranges). - `clearGitDiffDecorations()`: Clears all Git diff decorations. - `addLineDecoration(LineDecoration decoration)`: Adds a decoration to a specific line. - `addLineDecorations(List decorations)`: Adds multiple line decorations. - `removeLineDecoration(String id)`: Removes a line decoration by its ID. - `addGutterDecoration(GutterDecoration decoration)`: Adds a decoration to the gutter. - `addGutterDecorations(List decorations)`: Adds multiple gutter decorations. - `removeGutterDecoration(String id)`: Removes a gutter decoration by its ID. - `clearGutterDecorations()`: Clears all gutter decorations. **Ghost Text (Inline Suggestions)** - `setGhostText(GhostText ghostText)`: Sets inline suggestion text. - `clearGhostText()`: Clears inline suggestion text. **File Operations** - `saveFile()`: Saves the current file. **Navigation** - `pressLeftArrowKey({bool isShiftPressed = false})`: Simulates pressing the left arrow key. - `pressRightArrowKey({bool isShiftPressed = false})`: Simulates pressing the right arrow key. - `pressUpArrowKey({bool isShiftPressed = false})`: Simulates pressing the up arrow key. - `pressDownArrowKey({bool isShiftPressed = false})`: Simulates pressing the down arrow key. - `pressHomeKey({bool isShiftPressed = false})`: Simulates pressing the Home key. - `pressEndKey({bool isShiftPressed = false})`: Simulates pressing the End key. - `pressDocumentHomeKey({bool isShiftPressed = false})`: Simulates pressing Ctrl+Home. - `pressDocumentEndKey({bool isShiftPressed = false})`: Simulates pressing Ctrl+End. - `pressWordLeftArrowKey({bool isShiftPressed = false})`: Simulates pressing Ctrl+Left Arrow. - `pressWordRightArrowKey({bool isShiftPressed = false})`: Simulates pressing Ctrl+Right Arrow. **Multi-cursor Operations** - `addMultiCursor(int line, int character)`: Adds a new cursor at the specified position. - `clearMultiCursor()`: Removes all additional cursors, leaving only the primary one. - `backspaceAtAllCursors()`: Performs backspace operation for all cursors. - `insertAtAllCursors(String textToInsert)`: Inserts text at all cursor positions. ``` -------------------------------- ### HoverDetailsStyle Constructor Source: https://pub.dev/packages/code_forge Sets the visual style for hover information popups, similar to suggestion styling. ```dart HoverDetailsStyle( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), backgroundColor: Colors.grey[850]!, focusColor: Colors.blue.withOpacity(0.3), hoverColor: Colors.blue.withOpacity(0.1), splashColor: Colors.blue.withOpacity(0.2), textStyle: TextStyle(color: Colors.white), ) ``` -------------------------------- ### Add code_forge_web Dependency Source: https://pub.dev/packages/code_forge_web/install Run this command to add the code_forge_web package to your Flutter project. It automatically updates your pubspec.yaml file. ```bash $ flutter pub add code_forge_web ``` -------------------------------- ### Set Git Diff Decorations Source: https://pub.dev/packages/code_forge/changelog Anchors gutter decorations for `controller.setGitDiffDecorations`. This ensures that git diff decorations are properly aligned with the gutter. ```dart controller.setGitDiffDecorations(...); ``` -------------------------------- ### Integrate CodeForgeWeb Widget Source: https://pub.dev/packages/code_forge_web/example Integrates the CodeForgeWeb widget into a Flutter application. It requires a controller, language configuration, editor theme, file URL, text style, and padding. ```dart CodeForgeWeb( editorTheme: vs2015Theme, language: langDart, fileUrl: "https://raw.githubusercontent.com/heckmon/code_forge/refs/heads/main/lib/code_forge/syntax_highlighter.dart", controller: controller, textStyle: GoogleFonts.jetBrainsMono(), innerPadding: EdgeInsets.only(top: 10), ) ``` -------------------------------- ### Suggestion Management API Source: https://pub.dev/packages/code_forge/changelog APIs for managing editor suggestions, including clearing all and accepting specific ones. ```APIDOC ## Suggestion Management API ### Description APIs to manage editor suggestions, allowing for programmatic control over suggestion display and acceptance. ### APIs - **`controller.clearAllSuggestions()`** - Clears all currently displayed suggestions in the editor. - **`controller.acceptSuggestion()`** - Manually accepts the currently highlighted LSP suggestion. ### Example Usage ```dart // Clear all suggestions controller.clearAllSuggestions(); // Accept the current suggestion controller.acceptSuggestion(); ``` ``` -------------------------------- ### Multi-cursor Operations API Source: https://pub.dev/packages/code_forge/changelog APIs for managing multiple cursors within the editor. ```APIDOC ## Multi-cursor Operations API ### Description Provides methods to interact with multiple cursors in the editor, allowing for simultaneous edits across different locations. ### APIs - **`controller.addMultiCursor(int line, int character)`** - Adds a new cursor at the specified line and character. - **`controller.clearMultiCursor()`** - Removes all added multi-cursors, leaving only the primary cursor. - **`controller.backspaceAtAllCursors()`** - Performs a backspace operation at the position of every active cursor. - **`controller.insertAtAllCursors(String textToInsert)`** - Inserts the provided text at the position of every active cursor. ### Example Usage ```dart // Add a multi-cursor at line 10, character 5 controller.addMultiCursor(10, 5); // Insert 'Hello' at all cursor positions controller.insertAtAllCursors('Hello'); // Clear all multi-cursors controller.clearMultiCursor(); ``` ``` -------------------------------- ### Multi-cursor Operations API Source: https://pub.dev/packages/code_forge/changelog Provides APIs for managing multi-cursor operations within the editor. Use these methods to add, clear, or perform actions at all cursor positions. ```dart // Multi-cursor operations controller.addMultiCursor(int line, int character); controller.clearMultiCursor(); controller.backspaceAtAllCursors(); controller.insertAtAllCursors(String textToInsert); ``` -------------------------------- ### Schedule CCLS Refresh with Debounce Source: https://pub.dev/packages/code_forge/changelog Schedules a CCLS semantic highlighting refresh with a 1-second debounce to prevent excessive document saves. This is useful for CCLS servers using custom semantic token protocols. ```dart _scheduleCclsRefresh() { Future.delayed(const Duration(seconds: 1), () { // Refresh logic here }); } ``` -------------------------------- ### Import code_forge in Dart Code Source: https://pub.dev/packages/code_forge/install Include this import statement in your Dart files to access the functionality provided by the code_forge package. ```dart import 'package:code_forge/code_forge.dart'; ``` -------------------------------- ### Add code_forge Dependency with Flutter Source: https://pub.dev/packages/code_forge/install Use this command to add the code_forge package to your Flutter project's dependencies. This command automatically updates your pubspec.yaml file. ```bash flutter pub add code_forge ``` -------------------------------- ### Add code_forge to pubspec.yaml Source: https://pub.dev/packages/code_forge Add the code_forge package as a dependency in your pubspec.yaml file to include it in your Flutter project. ```yaml dependencies: code_forge: ^9.9.0 ``` -------------------------------- ### Custom Code Snippets API Source: https://pub.dev/packages/code_forge/changelog API for adding external code snippets to the editor's suggestions. ```APIDOC ## Custom Code Snippets API ### Description Allows the addition of external code snippets to be presented as suggestions within the editor. ### Parameter - **`customCodeSnippets`** (parameter on the editor) - A parameter that accepts a list of external code snippets to be included in the suggestion list. ### Example Usage ```dart // Assuming 'mySnippets' is a List of custom snippets CodeForgeEditor( // ... other parameters customCodeSnippets: mySnippets, ); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.