A text editor widget for Dear ImGui that supports syntax highlighting, undo & redo, and more. More...
#include "donner/editor/TextEditor.h"
Classes | |
| struct | SourceStyleDecoration |
| Source decoration for style/cascade annotations in the editor. More... | |
| struct | SourceStructuralMoveDecoration |
| Source structural-drag decoration supplied by the editor shell. More... | |
| struct | AutocompleteRequest |
| Request payload for structured autocomplete providers. More... | |
| struct | AutocompleteSuggestion |
| A single autocomplete suggestion. More... | |
| struct | AutocompleteResponse |
| Response from a structured autocomplete provider. More... | |
Public Types | |
| enum class | ShortcutId { Undo , Redo , MoveUp , SelectUp , MoveDown , SelectDown , MoveLeft , SelectLeft , MoveWordLeft , SelectWordLeft , MoveRight , SelectRight , MoveWordRight , SelectWordRight , MoveUpBlock , SelectUpBlock , MoveDownBlock , SelectDownBlock , MoveTop , SelectTop , MoveBottom , SelectBottom , MoveStartLine , SelectStartLine , MoveEndLine , SelectEndLine , ForwardDelete , ForwardDeleteWord , DeleteRight , BackwardDelete , BackwardDeleteWord , DeleteLeft , Copy , Paste , Cut , SelectAll , AutocompleteOpen , AutocompleteSelect , AutocompleteSelectActive , AutocompleteUp , AutocompleteDown , NewLine , Indent , Unindent , Find , Replace , FindNext , DuplicateLine , CommentLines , UncommentLines , Count } |
| Shortcut IDs for various editor actions. More... | |
| enum class | SourceStyleChipKind { SelectorMatchCount , ReferenceCount } |
| Visual role for a rendered source style chip. More... | |
| using | ShortcutBindings = std::array<Shortcut, 2> |
| Up to two key bindings for one action; any set binding triggers it, and an unset binding (key1 is ImGuiKey_None) never matches. | |
| using | SelectionMode |
| Selection expansion modes shared with the core. | |
| using | Identifier = ::donner::editor::Identifier |
| Identifier metadata shared with the core. | |
| using | Identifiers = ::donner::editor::Identifiers |
| Identifier table shared with the core. | |
| using | Keywords = ::donner::editor::Keywords |
| Syntax keyword set shared with the core. | |
| using | ErrorMarkers |
| Line-keyed diagnostics shared with the core. | |
| using | Palette = ::donner::editor::Palette |
| Syntax color palette shared with the core. | |
| using | LanguageDefinition |
| Syntax language rules shared with the core. | |
| using | String = RcString |
| Text storage string type. | |
| using | AutocompleteProvider |
| Provider callback for syntax-aware autocomplete. | |
Public Member Functions | |
| TextEditor (const TextEditor &)=delete | |
| TextEditor & | operator= (const TextEditor &)=delete |
| TextEditor (TextEditor &&)=delete | |
| TextEditor & | operator= (TextEditor &&)=delete |
| void | setLanguageDefinition (const LanguageDefinition &langDef) |
| Set syntax language rules and schedule recoloring. | |
| void | setSvgLanguageDefinition () |
| Use the built-in SVG syntax rules. | |
| void | setPalette (const Palette &value) |
| Set the base syntax color palette. | |
| void | setErrorMarkers (const ErrorMarkers &markers) |
| Replace line-keyed diagnostic markers. | |
| void | processFind (const std::string &findWord, bool findNext) |
| Process find operation to locate text in editor. | |
| void | processReplace (const std::string &findWord, const std::string &replaceWord, bool replaceAll=false) |
| Process replace operation to replace text in editor. | |
| void | render (std::string_view title, const ImVec2 &size=ImVec2(), bool showBorder=false) |
| Render the editor in an ImGui child region unless child creation is disabled. | |
| void | setText (std::string_view text, bool preserveScroll=false) |
| Replace the entire buffer with new text. | |
| void | applyExternalSourceEdit (std::size_t offset, std::size_t removedLength, std::string_view replacement) |
| Apply source bytes that changed outside the editor without recording a user edit. | |
| bool | needsRerender () const |
| True if the editor needs to be re-rendered. | |
| std::string | getText () const |
| Get all text in the editor. | |
| std::size_t | textByteLength () const |
| Byte counts for source diagnostics without copying the editor buffer. | |
| std::size_t | selectionByteLength () const |
| Return the selected range length in UTF-8 bytes. | |
| Coordinates | getCoordinatesAtByteOffset (std::size_t offset) const |
| Resolve a full-buffer byte offset to editor coordinates. | |
| std::size_t | getByteOffsetAtCoordinates (const Coordinates &coordinates) const |
| Resolve editor coordinates to a full-buffer byte offset. | |
| std::string | getSelectedText () const |
| Get currently selected text. | |
| bool | isFocused () const |
| Report whether the editor currently owns input focus. | |
| bool | isTextChanged () const |
| Report whether text changed since reset; external source mirroring clears the flag. | |
| bool | isCursorPositionChanged () const |
| Report a pending cursor change; the flag resets when render begins. | |
| bool | didMouseChangeCursorPosition () const |
| Whether mouse input moved the cursor during the current render frame. | |
| std::optional< Coordinates > | hoveredTextPosition () const |
| Source coordinates currently hovered by the mouse, if the text area is hovered. | |
| std::optional< int > | takeSourceGutterDragStartedLine () |
| Return and clear the line whose gutter handle began a structural drag. | |
| std::optional< Coordinates > | sourceGutterDragTarget () const |
| Current source position under an active gutter drag. | |
| std::optional< Coordinates > | takeSourceGutterDropTarget () |
| Return and clear a completed gutter drop position. | |
| bool | takeSourceGutterDragCancelled () |
| Return and clear the gutter-drag cancellation flag. | |
| void | cancelSourceGutterDrag () |
| Cancel any active gutter drag without emitting a drop. | |
| void | resetTextChanged () |
| Clear the text-change flag and changed-line tracking. | |
| bool | hasPendingSourceEditIntents () const |
| True if user-facing edits have pending byte-level source intents. | |
| std::vector< SourceEditIntent > | takePendingSourceEditIntents () |
| Consume pending byte-level source intents captured from user-facing edits. | |
| const LanguageDefinition & | getLanguageDefinition () const |
| Return the active syntax language definition. | |
| const Palette & | getPalette () const |
| Return the configured base syntax color palette. | |
| bool | isColorizerEnabled () const |
| Returns true if syntax highlighting is enabled. | |
| void | setColorizerEnabled (bool enabled) |
| Enable or disable syntax highlighting. | |
| Coordinates | getCorrectCursorPosition () |
| Get the cursor position adjusted for tab characters. | |
| Coordinates | getCursorPosition () const |
| Get the current cursor position in the editor. | |
| void | setCursorPosition (const Coordinates &position) |
| Set the cursor position and ensure it's visible. | |
| void | setHandleMouseInputs (bool value) |
| Enable or disable mouse input handling in the editor region. | |
| bool | isHandleMouseInputsEnabled () const |
| Return the keyboard-input flag currently exposed by this legacy mouse query. | |
| void | setHandleKeyboardInputs (bool value) |
| Enable or disable keyboard input handling in the editor region. | |
| bool | isHandleKeyboardInputsEnabled () const |
| Report whether keyboard input handling is enabled. | |
| void | setImGuiChildIgnored (bool value) |
| Choose whether the caller, rather than this widget, owns the ImGui child region. | |
| bool | isImGuiChildIgnored () const |
| Report whether this widget skips creation of its ImGui child region. | |
| void | setSourceFocusModeContextMenu (bool checked) |
| Show a source-focus toggle in the editor context menu. | |
| void | clearSourceFocusModeContextMenu () |
| Hide the source-focus toggle from the editor context menu. | |
| bool | takeSourceFocusModeContextMenuToggleRequest () |
| Consume a source-focus toggle requested from the editor context menu. | |
| void | setShowWhitespaces (bool value) |
| Show or hide whitespace characters in the editor. | |
| bool | isShowingWhitespaces () const |
| Report whether whitespace markers are visible. | |
| void | insertText (std::string_view text, bool indent=false) |
| Insert text at current cursor position. | |
| void | moveUp (int amount=1, bool select=false) |
| Move cursor up by specified number of lines. | |
| void | moveDown (int amount=1, bool select=false) |
| Move cursor down by specified number of lines. | |
| void | moveLeft (int amount=1, bool select=false, bool wordMode=false) |
| Move the cursor left by characters or words. | |
| void | moveRight (int amount=1, bool select=false, bool wordMode=false) |
| Move the cursor right by characters or words. | |
| void | moveTop (bool select=false) |
| Move the cursor to the start of the first line. | |
| void | moveBottom (bool select=false) |
| Move the cursor to the end of the final line. | |
| void | moveHome (bool select=false) |
| Move the cursor to the start of its current line. | |
| void | moveEnd (bool select=false) |
| Move the cursor to the end of its current line. | |
| void | setSelectionStart (const Coordinates &position) |
| Set the start position of the current selection. | |
| void | setSelectionEnd (const Coordinates &position) |
| Set the end position of the current selection. | |
| void | selectAndFocus (const Coordinates &start, const Coordinates &end) |
| Set a new selection and scroll to it. | |
| void | setSelection (const Coordinates &start, const Coordinates &end, SelectionMode mode=SelectionMode::Normal) |
| Set the current text selection with specified mode. | |
| void | selectWordUnderCursor () |
| Select the word at the current cursor position. | |
| void | selectAll () |
| Select all text in the editor. | |
| void | clearSelection () |
| Collapse any active text selection to the caret ("Deselect All" in the source/XML pane). | |
| bool | hasSelection () const |
| Check if there is currently selected text. | |
| void | copy () |
| Copy current selection or current line to clipboard. | |
| void | cut () |
| Cut current selection to clipboard. | |
| void | paste () |
| Paste clipboard contents at cursor position. | |
| void | handleEndOfLineDelete (Coordinates pos, UndoRecord &undo) |
| Handles deletion of a line ending at the given coordinates. | |
| void | handleMidLineDelete (Coordinates pos, UndoRecord &undo) |
| Handles deletion of a character in the middle of a line. | |
| void | delete_ () |
| Handles deletion of text at the current cursor position or selection. | |
| bool | canUndo () const |
| Check if undo operation is available. | |
| bool | canRedo () const |
| Check if redo operation is available. | |
| void | undo (int steps=1) |
| Undo specified number of operations. | |
| void | redo (int steps=1) |
| Redo specified number of operations. | |
| void | setHighlightedLines (const std::vector< int > &lines) |
| Set source line numbers highlighted by the rendering shell. | |
| void | clearHighlightedLines () |
| Clear source line highlights. | |
| bool | setHoverSourceRanges (std::vector< SourceByteRange > ranges) |
| Set subtle source ranges to highlight while the source mouse hover is active. | |
| bool | clearHoverSourceRanges () |
| Clear source-hover highlights. | |
| const std::vector< SourceByteRange > & | hoverSourceRanges () const |
| Active source-hover ranges. | |
| bool | setSourceDiagnostics (std::vector< SourceDiagnostic > diagnostics) |
| Install exact source diagnostics for inline rendering and hit testing. | |
| const std::vector< SourceDiagnostic > & | sourceDiagnostics () const |
| Active source diagnostics. | |
| std::optional< std::uint64_t > | sourceDiagnosticAtByteOffset (std::size_t byteOffset) const |
Return the narrowest diagnostic containing byteOffset. | |
| std::optional< std::uint64_t > | hoveredSourceDiagnosticId () const |
| Diagnostic under the source pointer, if any. | |
| bool | setActiveSourceDiagnosticId (std::optional< std::uint64_t > id) |
| Emphasize a diagnostic selected or hovered by an external presenter. | |
| std::optional< std::uint64_t > | activeSourceDiagnosticId () const |
| Return the diagnostic currently emphasized by the shell, if any. | |
| bool | setSourceStructuralMoveDecoration (std::optional< SourceStructuralMoveDecoration > decoration) |
| Set the current source structural-move preview decoration. | |
| const std::optional< SourceStructuralMoveDecoration > & | sourceStructuralMoveDecoration () const |
| Return the active structural-move preview, if any. | |
| bool | setSourceStyleDecorations (std::vector< SourceStyleDecoration > decorations) |
| Set source style/cascade decorations. | |
| bool | clearSourceStyleDecorations () |
| Clear source style/cascade decorations. | |
| const std::vector< SourceStyleDecoration > & | sourceStyleDecorations () const |
| Active source style/cascade decorations. | |
| void | beginSourceStyleDecorationRefresh (std::uint64_t documentGeneration, std::uint64_t referenceRevision) |
| Suspend annotation interactions while the current source annotations are refreshed. | |
| std::optional< std::size_t > | takeClickedSourceStyleChipId () |
| Return and clear the last clicked source style decoration chip id. | |
| void | setFocusPartition (const FocusPartition &partition) |
| Install a source-focus partition. Hidden lines are folded from the view only. | |
| void | clearFocusPartition () |
| Clear source-focus mode and reveal every line. | |
| bool | hasFocusPartition () const |
| Return true if a source-focus partition is currently active. | |
| bool | isPositionInsideFocusRange (const Coordinates &position) const |
Return true if position is inside the active source-focus range. | |
| bool | isCursorInsideFocusRange () const |
| Return true if the current cursor is inside the active source-focus range. | |
| void | flashSourceRange (SourceByteRange byteRange) |
Add a transient source flash over byteRange. | |
| std::optional< float > | nextFlashWakeSeconds () const |
| Return the next flash wake interval, or nullopt if no flash is active. | |
| std::optional< float > | nextRopeAnimationWakeSeconds () const |
| Return the next rope-animation wake interval, or nullopt if every rope is idle. | |
| const FrameCostBreakdown::SourceRopes & | lastSourceRopeCost () const |
| Latest source-focus reference rope cost counters. | |
| void | tickSourceFlashes () |
| Remove expired flashes using the current steady-clock time. | |
| void | setTabSize (int size) |
| Set tab width in columns, clamped by the core to 0 through 32. | |
| int | getTabSize () const |
| Return tab width in columns. | |
| void | setInsertSpaces (bool value) |
| Choose spaces instead of tabs for indentation. | |
| bool | getInsertSpaces () const |
| Report whether indentation inserts spaces. | |
| void | setSmartIndent (bool value) |
| Enable or disable context-sensitive indentation. | |
| void | setAutoIndentOnPaste (bool value) |
| Enable or disable indentation of pasted lines. | |
| void | setHighlightLine (bool value) |
| Enable or disable a highlight behind the current line. | |
| void | setCompleteBraces (bool value) |
| Enable or disable automatic closing-brace insertion. | |
| void | setHorizontalScroll (bool) |
| Disable horizontal scrolling; the legacy argument is ignored. | |
| void | setSmartPredictions (bool value) |
| Store the legacy prediction preference; current rendering does not read it. | |
| void | setFunctionDeclarationTooltip (bool value) |
| Enable or disable function declaration tooltips. | |
| void | setFunctionTooltips (bool value) |
| Store the legacy function-tooltip preference; current rendering does not read it. | |
| void | setActiveAutocomplete (bool value) |
| Enable or disable active autocomplete requests. | |
| void | setScrollbarMarkers (bool value) |
| Show or hide changed-line markers in the scrollbar. | |
| void | setSidebarVisible (bool value) |
| Show or hide the editor sidebar. | |
| void | setSearchEnabled (bool value) |
| Store the legacy search preference; current rendering does not read it. | |
| void | setHighlightBrackets (bool value) |
| Store the legacy bracket-highlight preference; current rendering does not read it. | |
| void | setFoldEnabled (bool value) |
| Enable or disable source fold controls. | |
| void | setWordWrapEnabled (bool value) |
| Enable or disable visual line wrapping. | |
| bool | wordWrapEnabled () const |
| Report whether visual line wrapping is enabled. | |
| void | setUIScale (float scale) |
| Set the overall editor UI scale. | |
| void | setUIFontSize (float size) |
| Set the size reference for find/replace control geometry; this does not select a font. | |
| void | setEditorFontSize (float size) |
| Store a legacy editor-sizing reference; current rendering does not read it. | |
| void | setShortcut (ShortcutId id, Shortcut shortcut) |
| Bind a keyboard shortcut to an editor action, replacing every existing binding for it. | |
| void | setShowLineNumbers (bool show) |
| Configure line number display. | |
| float | getTextStart () const |
| Get the horizontal offset where text content starts. | |
| void | colorize (int fromLine=0, int count=-1) |
| Update color range for syntax highlighting. | |
| void | colorizeRange (int fromLine=0, int toLine=0) |
| Recolor the half-open source line range [fromLine, toLine). | |
| void | colorizeInternal () |
| Process the pending syntax-coloring range. | |
| void | clearAutocompleteData () |
| Compatibility no-op; structured autocomplete has no stored payload to clear. | |
| void | clearAutocompleteEntries () |
| Clear generic autocomplete entries and their search terms. | |
| void | addAutocompleteEntry (std::string_view searchTerm, std::string_view displayText, std::string_view insertText) |
| Add an entry to the autocomplete suggestions. | |
| void | setAutocompleteProvider (AutocompleteProvider provider) |
| Install a structured autocomplete provider. | |
| void | deleteRange (const Coordinates &start, const Coordinates &end) |
| Delete a coordinate range and update core text-change state. | |
| int | insertTextAt (Coordinates &where, std::string_view text, bool indent=false) |
| Inserts text at the given coordinates, handling auto-indentation and fold markers. | |
Static Public Member Functions | |
| static std::vector< ShortcutBindings > | getDefaultShortcuts () |
| Returns the default set of keyboard shortcuts for the text editor. | |
| static const Palette & | getDarkPalette () |
| Return the static default dark syntax palette. | |
Public Attributes | |
| std::function< void(TextEditor *, std::string_view)> | onIdentifierHover |
| Legacy identifier-hover callback slot; current rendering does not invoke it. | |
| std::function< bool(TextEditor *, std::string_view)> | hasIdentifierHover |
| Legacy identifier-hover availability slot; current rendering does not read it. | |
| std::function< void(TextEditor *, std::string_view)> | onExpressionHover |
| Legacy expression-hover callback slot; current rendering does not invoke it. | |
| std::function< bool(TextEditor *, std::string_view)> | hasExpressionHover |
| Legacy expression-hover availability slot; current rendering does not read it. | |
| std::function< void(TextEditor *, std::string_view, Coordinates)> | onCtrlAltClick |
| Legacy modified-click callback slot; current input handling does not invoke it. | |
| std::function< void(TextEditor *)> | onContentUpdate |
| Called for core edit updates, not full setText loads. | |
Static Public Attributes | |
| static constexpr int | kLineNumberSpace = 20 |
| Width of line number margin in pixels. | |
A text editor widget for Dear ImGui that supports syntax highlighting, undo & redo, and more.
| struct donner::editor::TextEditor::AutocompleteRequest |
Request payload for structured autocomplete providers.
| Class Members | ||
|---|---|---|
| size_t | cursorOffset = 0 | Cursor byte offset in source. |
| string_view | source | Full editor source text. |
| struct donner::editor::TextEditor::AutocompleteSuggestion |
| struct donner::editor::TextEditor::AutocompleteResponse |
Response from a structured autocomplete provider.
| Class Members | ||
|---|---|---|
| size_t | replaceEndOffset = 0 | Exclusive source byte offset to replace. |
| size_t | replaceStartOffset = 0 | Inclusive source byte offset to replace. |
| vector< AutocompleteSuggestion > | suggestions | |
Provider callback for syntax-aware autocomplete.
Return std::nullopt when the provider does not handle the current source. Return an empty response to suppress generic word autocomplete for handled contexts that have no suggestions.
Line-keyed diagnostics shared with the core.
Syntax language rules shared with the core.
Selection expansion modes shared with the core.
|
strong |
Shortcut IDs for various editor actions.
Each can be bound to a keyboard combination.
|
strong |
|
inline |
Add an entry to the autocomplete suggestions.
| searchTerm | Term to match against when filtering |
| displayText | Text to show in the autocomplete popup |
| insertText | Text to insert when selected |
| void donner::editor::TextEditor::applyExternalSourceEdit | ( | std::size_t | offset, |
| std::size_t | removedLength, | ||
| std::string_view | replacement ) |
Apply source bytes that changed outside the editor without recording a user edit.
| offset | Byte offset in the current buffer. |
| removedLength | Number of bytes to remove. |
| replacement | Replacement bytes to insert. |
| void donner::editor::TextEditor::beginSourceStyleDecorationRefresh | ( | std::uint64_t | documentGeneration, |
| std::uint64_t | referenceRevision ) |
Suspend annotation interactions while the current source annotations are refreshed.
| documentGeneration | Identity of the current source document. |
| referenceRevision | Revision advanced by changes beyond typed transform mutations. |
| bool donner::editor::TextEditor::canRedo | ( | ) | const |
Check if redo operation is available.
| bool donner::editor::TextEditor::canUndo | ( | ) | const |
Check if undo operation is available.
| void donner::editor::TextEditor::clearSelection | ( | ) |
Collapse any active text selection to the caret ("Deselect All" in the source/XML pane).
Leaves the cursor where it is and is a no-op when there is no selection.
| void donner::editor::TextEditor::colorize | ( | int | fromLine = 0, |
| int | count = -1 ) |
Update color range for syntax highlighting.
| fromLine | Starting line number |
| count | Number of lines to colorize (-1 for all remaining lines) |
| void donner::editor::TextEditor::colorizeRange | ( | int | fromLine = 0, |
| int | toLine = 0 ) |
Recolor the half-open source line range [fromLine, toLine).
| fromLine | First line in the range. |
| toLine | First line after the range. |
| void donner::editor::TextEditor::delete_ | ( | ) |
Handles deletion of text at the current cursor position or selection.
If there is a selection, deletes the selected text. Otherwise, deletes either:
The operation is recorded for undo history tracking. After deletion:
| void donner::editor::TextEditor::deleteRange | ( | const Coordinates & | start, |
| const Coordinates & | end ) |
Delete a coordinate range and update core text-change state.
| start | First coordinate to delete. |
| end | Coordinate after the deleted range. |
|
inline |
Resolve editor coordinates to a full-buffer byte offset.
| coordinates | Coordinates in getText(). |
|
inline |
Resolve a full-buffer byte offset to editor coordinates.
| offset | Byte offset in getText(). |
| Coordinates donner::editor::TextEditor::getCorrectCursorPosition | ( | ) |
Get the cursor position adjusted for tab characters.
Returns cursor position with the column adjusted to account for tab size.
|
inline |
Get the current cursor position in the editor.
|
static |
Returns the default set of keyboard shortcuts for the text editor.
These shortcuts map various editor actions (like navigation, editing, and search) to specific key combinations. The returned shortcuts can be further customized at runtime.
Navigation follows macOS text editing: Home/End and Ctrl+Left/Right move to the line start and end, Alt+Left/Right move by word, Ctrl+Up/Down and Ctrl+Home/End move to the document start and end, and Shift extends the selection. Ctrl is ImGui's primary shortcut modifier, which ImGui reports for the Command key on macOS.
| std::string donner::editor::TextEditor::getSelectedText | ( | ) | const |
Get currently selected text.
| std::string donner::editor::TextEditor::getText | ( | ) | const |
| void donner::editor::TextEditor::handleEndOfLineDelete | ( | Coordinates | pos, |
| UndoRecord & | undo ) |
Handles deletion of a line ending at the given coordinates.
This merges the current line with the next line when the delete key is pressed at the end of a line. The operation is recorded in the undo record for history tracking.
| pos | The coordinates where the end-of-line deletion occurs |
| undo | The undo record to store the deletion information |
| void donner::editor::TextEditor::handleMidLineDelete | ( | Coordinates | pos, |
| UndoRecord & | undo ) |
Handles deletion of a character in the middle of a line.
Deletes a single character (which may be a multi-byte UTF-8 sequence) at the given position and updates any affected fold markers. The operation is recorded in the undo record for history tracking.
| pos | The coordinates where the deletion occurs |
| undo | The undo record to store the deletion information |
| bool donner::editor::TextEditor::hasSelection | ( | ) | const |
Check if there is currently selected text.
| void donner::editor::TextEditor::insertText | ( | std::string_view | text, |
| bool | indent = false ) |
Insert text at current cursor position.
Handles selection replacement and auto-indentation.
| text | Text to insert |
| indent | Whether to apply auto-indentation |
| int donner::editor::TextEditor::insertTextAt | ( | Coordinates & | where, |
| std::string_view | text, | ||
| bool | indent = false ) |
Inserts text at the given coordinates, handling auto-indentation and fold markers.
This method handles:
| where | The coordinates where text should be inserted. Modified to point to the end of insertion. |
| text | The text to insert |
| indent | Whether to apply auto-indentation for newlines |
|
nodiscard |
Return true if position is inside the active source-focus range.
| position | Source editor coordinates to test. |
| void donner::editor::TextEditor::moveBottom | ( | bool | select = false | ) |
Move the cursor to the end of the final line.
| select | Whether to extend the selection. |
| void donner::editor::TextEditor::moveDown | ( | int | amount = 1, |
| bool | select = false ) |
Move cursor down by specified number of lines.
Updates selection if shift is held.
| amount | Number of lines to move down |
| select | Whether to extend selection while moving |
| void donner::editor::TextEditor::moveEnd | ( | bool | select = false | ) |
Move the cursor to the end of its current line.
| select | Whether to extend the selection. |
| void donner::editor::TextEditor::moveHome | ( | bool | select = false | ) |
Move the cursor to the start of its current line.
| select | Whether to extend the selection. |
| void donner::editor::TextEditor::moveLeft | ( | int | amount = 1, |
| bool | select = false, | ||
| bool | wordMode = false ) |
Move the cursor left by characters or words.
| amount | Number of steps. |
| select | Whether to extend the selection. |
| wordMode | Whether each step moves to the start of the current or previous word. |
| void donner::editor::TextEditor::moveRight | ( | int | amount = 1, |
| bool | select = false, | ||
| bool | wordMode = false ) |
Move the cursor right by characters or words.
| amount | Number of steps. |
| select | Whether to extend the selection. |
| wordMode | Whether each step moves to the end of the current or next word. |
| void donner::editor::TextEditor::moveTop | ( | bool | select = false | ) |
Move the cursor to the start of the first line.
| select | Whether to extend the selection. |
| void donner::editor::TextEditor::moveUp | ( | int | amount = 1, |
| bool | select = false ) |
Move cursor up by specified number of lines.
Updates selection if shift is held.
| amount | Number of lines to move up |
| select | Whether to extend selection while moving |
| void donner::editor::TextEditor::processFind | ( | const std::string & | findWord, |
| bool | findNext ) |
Process find operation to locate text in editor.
Updates cursor position and selection to found text.
| findWord | Text to search for |
| findNext | Whether this is a "find next" operation |
| void donner::editor::TextEditor::processReplace | ( | const std::string & | findWord, |
| const std::string & | replaceWord, | ||
| bool | replaceAll = false ) |
Process replace operation to replace text in editor.
Can replace single occurrence or all occurrences.
| findWord | Text to search for |
| replaceWord | Text to replace with |
| replaceAll | Whether to replace all occurrences |
| void donner::editor::TextEditor::redo | ( | int | steps = 1 | ) |
Redo specified number of operations.
| steps | Number of operations to redo |
| void donner::editor::TextEditor::render | ( | std::string_view | title, |
| const ImVec2 & | size = ImVec2(), | ||
| bool | showBorder = false ) |
Render the editor in an ImGui child region unless child creation is disabled.
| title | ImGui identifier for the editor region. |
| size | Requested child size; ImGui uses available space for zero dimensions. |
| showBorder | Whether ImGui draws a border around the child. |
|
inline |
Set a new selection and scroll to it.
| start | Selection start |
| end | Selection end. |
|
inline |
Enable or disable active autocomplete requests.
| value | Whether autocomplete is active. |
|
inline |
Install a structured autocomplete provider.
| provider | Provider callback, or empty to use only generic word autocomplete. |
|
inline |
Enable or disable indentation of pasted lines.
| value | Whether pasted lines are auto-indented. |
| void donner::editor::TextEditor::setColorizerEnabled | ( | bool | enabled | ) |
Enable or disable syntax highlighting.
| enabled | Whether to enable the colorizer |
|
inline |
Enable or disable automatic closing-brace insertion.
| value | Whether matching braces are completed. |
| void donner::editor::TextEditor::setCursorPosition | ( | const Coordinates & | position | ) |
Set the cursor position and ensure it's visible.
Updates cursor position and scrolls view if needed.
| position | New cursor coordinates |
|
inline |
Store a legacy editor-sizing reference; current rendering does not read it.
| size | Legacy sizing reference. |
|
inline |
|
inline |
Enable or disable source fold controls.
| value | Whether folding is enabled. |
|
inline |
Enable or disable function declaration tooltips.
| value | Whether declaration tooltips are shown. |
|
inline |
Store the legacy function-tooltip preference; current rendering does not read it.
| value | Preference to store. |
|
inline |
Enable or disable keyboard input handling in the editor region.
| value | Whether the editor handles keyboard input. |
|
inline |
Enable or disable mouse input handling in the editor region.
| value | Whether the editor handles mouse input. |
|
inline |
Store the legacy bracket-highlight preference; current rendering does not read it.
| value | Preference to store. |
|
inline |
Set source line numbers highlighted by the rendering shell.
| lines | Line numbers to highlight. |
|
inline |
Enable or disable a highlight behind the current line.
| value | Whether to highlight the current line. |
|
inline |
Choose whether the caller, rather than this widget, owns the ImGui child region.
| value | True when a surrounding ImGui child is already active. |
|
inline |
Choose spaces instead of tabs for indentation.
| value | True to insert spaces. |
| void donner::editor::TextEditor::setLanguageDefinition | ( | const LanguageDefinition & | langDef | ) |
Set syntax language rules and schedule recoloring.
| langDef | Language definition to use. |
| void donner::editor::TextEditor::setPalette | ( | const Palette & | value | ) |
Set the base syntax color palette.
| value | Palette to store. |
|
inline |
Show or hide changed-line markers in the scrollbar.
| value | Whether markers are shown. |
|
inline |
Store the legacy search preference; current rendering does not read it.
| value | Preference to store. |
| void donner::editor::TextEditor::setSelection | ( | const Coordinates & | start, |
| const Coordinates & | end, | ||
| SelectionMode | mode = SelectionMode::Normal ) |
Set the current text selection with specified mode.
Updates selection range and handles word/line selection modes.
| start | Start coordinates of selection |
| end | End coordinates of selection |
| mode | Selection mode (Normal, Word, or Line) |
| void donner::editor::TextEditor::setSelectionEnd | ( | const Coordinates & | position | ) |
Set the end position of the current selection.
Ensures selection range remains valid by swapping start/end if needed.
| position | Selection end coordinates |
| void donner::editor::TextEditor::setSelectionStart | ( | const Coordinates & | position | ) |
Set the start position of the current selection.
Ensures selection range remains valid by swapping start/end if needed.
| position | Selection start coordinates |
| void donner::editor::TextEditor::setShortcut | ( | ShortcutId | id, |
| Shortcut | shortcut ) |
Bind a keyboard shortcut to an editor action, replacing every existing binding for it.
| id | The action to bind |
| shortcut | The keyboard shortcut to bind to the action |
|
inline |
Configure line number display.
| show | Whether to show line numbers |
|
inline |
Show or hide the editor sidebar.
| value | Whether the sidebar is visible. |
|
inline |
Enable or disable context-sensitive indentation.
| value | Whether smart indentation is active. |
|
inline |
Store the legacy prediction preference; current rendering does not read it.
| value | Preference to store. |
|
inline |
Set tab width in columns, clamped by the core to 0 through 32.
| size | Requested tab width. |
| void donner::editor::TextEditor::setText | ( | std::string_view | text, |
| bool | preserveScroll = false ) |
Replace the entire buffer with new text.
| text | The new text to load into the buffer. |
| preserveScroll | If true, the current scroll position is kept. Use this for in-place edits (e.g. canvas→text writeback) so the view doesn't snap back to the top. Default false matches the "load a fresh document" behavior. |
|
inline |
Set the size reference for find/replace control geometry; this does not select a font.
| size | UI sizing reference. |
|
inline |
Set the overall editor UI scale.
| scale | Scale applied to editor chrome. |
|
inline |
Enable or disable visual line wrapping.
| value | Whether long lines wrap. |
| void donner::editor::TextEditor::undo | ( | int | steps = 1 | ) |
Undo specified number of operations.
| steps | Number of operations to undo |