|
|
Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
|
Headless editing substrate — the text buffer, cursor, undo history and syntax colorizer with no ImGui dependency. More...
#include "donner/editor/TextEditorCore.h"
Public Types | |
| using | UndoBuffer = std::vector<UndoRecord> |
Public Member Functions | |
| TextEditorCore (const TextEditorCore &)=delete | |
| TextEditorCore & | operator= (const TextEditorCore &)=delete |
| TextEditorCore (TextEditorCore &&)=delete | |
| TextEditorCore & | operator= (TextEditorCore &&)=delete |
| void | setText (std::string_view text, bool preserveScroll=false) |
| Replace the buffer contents with text. By default this scrolls the view back to the top — appropriate for File→Open and similar "load a different document" flows. Pass preserveScroll=true when the replacement is a small in-place edit (e.g. canvas→text writeback after a transform drag) so the user's scroll position isn't yanked out from under them. | |
| void | applyExternalSourceEdit (std::size_t offset, std::size_t removedLength, std::string_view replacement) |
| Apply a source-view update that originated outside the text editor. | |
| std::string | getText () const |
| std::string | getText (const Coordinates &start, const Coordinates &end) const |
| Coordinates | getCoordinatesAtByteOffset (std::size_t offset) const |
| Resolve a full-buffer byte offset to editor coordinates. | |
| bool | isTextChanged () const |
| void | resetTextChanged () |
| 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. | |
| Coordinates | getCursorPosition () const |
| void | setCursorPosition (const Coordinates &position) |
| void | setSelection (const Coordinates &start, const Coordinates &end, SelectionMode mode=SelectionMode::Normal) |
| void | setInteractiveSelection (const Coordinates &start, const Coordinates &end, SelectionMode mode=SelectionMode::Normal) |
| Update the visible selection during an active mouse interaction while preserving the raw anchor/current endpoints in interactiveStart_/End_. | |
| void | setSelectionStart (const Coordinates &position) |
| void | setSelectionEnd (const Coordinates &position) |
| const Coordinates & | getSelectionStart () const |
| const Coordinates & | getSelectionEnd () const |
| bool | hasSelection () const |
| std::string | getSelectedText () const |
| void | selectAll () |
| void | selectWordUnderCursor () |
| void | moveUp (int amount=1, bool select=false) |
| void | moveDown (int amount=1, bool select=false) |
| void | moveLeft (int amount=1, bool select=false, bool wordMode=false) |
| void | moveRight (int amount=1, bool select=false, bool wordMode=false) |
| void | moveTop (bool select=false) |
| void | moveBottom (bool select=false) |
| void | moveHome (bool select=false) |
| void | moveEnd (bool select=false) |
| void | enterCharacter (char32_t character, bool shift) |
| void | insertText (std::string_view text, bool indent=false) |
| int | insertTextAt (Coordinates &where, std::string_view text, bool indent=false) |
| void | deleteRange (const Coordinates &start, const Coordinates &end) |
| void | deleteSelection () |
| void | backspace () |
| void | delete_ () |
| bool | canUndo () const |
| bool | canRedo () const |
| void | undo (int steps=1) |
| void | redo (int steps=1) |
| void | addUndo (UndoRecord &value) |
| void | setLanguageDefinition (const LanguageDefinition &langDef) |
| const LanguageDefinition & | getLanguageDefinition () const |
| void | colorize (int fromLine=0, int count=-1) |
| void | colorizeRange (int fromLine=0, int toLine=0) |
| void | colorizeInternal () |
| bool | isColorizerEnabled () const |
| void | setColorizerEnabled (bool enabled) |
| void | setPalette (const Palette &value) |
| const Palette & | getPalette () const |
| void | setTabSize (int size) |
| int | getTabSize () const |
| void | setInsertSpaces (bool value) |
| bool | getInsertSpaces () const |
| void | setSmartIndent (bool value) |
| void | setAutoIndentOnPaste (bool value) |
| void | setCompleteBraces (bool value) |
| void | setActiveAutocomplete (bool value) |
| void | setScrollbarMarkers (bool value) |
| bool & | scrollbarMarkersRef () |
| void | setErrorMarkers (const ErrorMarkers &markers) |
| const ErrorMarkers & | getErrorMarkers () const |
| ErrorMarkers & | mutableErrorMarkers () |
| Coordinates | findWordStart (const Coordinates &from) const |
| Coordinates | findWordEnd (const Coordinates &from) const |
| Coordinates | findNextWord (const Coordinates &from) const |
| bool | isOnWordBoundary (const Coordinates &at) const |
| RcString | getWordUnderCursor () const |
| RcString | getWordAt (const Coordinates &coords) const |
| Coordinates | findFirst (std::string_view searchText, const Coordinates &start) const |
| Coordinates | getActualCursorCoordinates () const |
| Coordinates | sanitizeCoordinates (const Coordinates &value) const |
| void | advance (Coordinates &coordinates) const |
| TextBuffer & | buffer () |
| const TextBuffer & | buffer () const |
| EditorState & | mutableState () |
| const EditorState & | state () const |
| const UndoBuffer & | undoBuffer () const |
| int | undoIndex () const |
| std::vector< int > & | changedLines () |
| const std::vector< int > & | changedLines () const |
| std::vector< Coordinates > & | foldBegin () |
| const std::vector< Coordinates > & | foldBegin () const |
| std::vector< Coordinates > & | foldEnd () |
| const std::vector< Coordinates > & | foldEnd () const |
| bool & | foldSorted () |
| SelectionMode | selectionMode () const |
| void | setSelectionMode (SelectionMode mode) |
| Coordinates & | interactiveStart () |
| Coordinates & | interactiveEnd () |
| Palette & | mutablePalette () |
| const Palette & | livePalette () const |
| Palette & | mutablePaletteBase () |
| bool | scrollToCursorRequested () const |
| void | clearScrollToCursor () |
| void | requestScrollToCursor () |
| bool & | scrollToCursorRef () |
| bool | scrollToTopRequested () const |
| void | clearScrollToTop () |
| bool & | scrollToTopRef () |
| bool | cursorPositionChanged () const |
| void | setCursorPositionChanged (bool value) |
| bool & | cursorPositionChangedRef () |
| int | replaceIndex () const |
| void | setReplaceIndex (int index) |
| int & | replaceIndexRef () |
| int & | tabSizeRef () |
| SelectionMode & | selectionModeRef () |
| bool & | textChangedRef () |
| bool & | autoIndentOnPasteRef () |
| unsigned int | getGlyphColor (const Glyph &glyph) const |
| void | removeLine (int start, int end) |
| void | removeLine (int index) |
| Line & | insertLine (int index, int column) |
| void | removeFolds (const Coordinates &start, const Coordinates &end) |
| void | removeFolds (std::vector< Coordinates > &folds, const Coordinates &start, const Coordinates &end) |
| void | detectIndentationStyle () |
| void | handleNewLine (UndoState &state, const Coordinates &coord, bool smartIndent) |
| void | handleRegularCharacter (UndoState &state, const Coordinates &coord, char32_t character) |
| void | handleEndOfLineDelete (Coordinates pos, UndoRecord &undo) |
| void | handleMidLineDelete (Coordinates pos, UndoRecord &undo) |
| void | handleStartOfLineDelete (const Coordinates &pos, UndoRecord &undo) |
| void | handleMidLineBackspace (const Coordinates &pos, UndoRecord &undo) |
| void | recordSourceEditIntent (const UndoRecord &record, SourceEditIntentKind kind) |
| void | appendSourceEditIntent (SourceEditIntent intent) |
| void | handleMultiLineTab (UndoState &state, bool shift) |
| void | updateChangeTracking () |
Public Attributes | |
| std::function< void()> | ensureCursorVisibleHook |
| std::function< void()> | requestAutocompleteHook |
| std::function< void(char32_t, const Coordinates &)> | functionTooltipHook |
| std::function< void()> | onContentUpdateInternal |
| std::function< void(const SourceEditIntent &)> | sourceEditIntentHook |
Headless editing substrate — the text buffer, cursor, undo history and syntax colorizer with no ImGui dependency.
TextEditor wraps this class and adds the ImGui rendering and input layer. Direct consumers should go through TextEditor; tests (once C3 migrates them) will construct TextEditorCore directly.
| void donner::editor::TextEditorCore::applyExternalSourceEdit | ( | std::size_t | offset, |
| std::size_t | removedLength, | ||
| std::string_view | replacement ) |
Apply a source-view update that originated outside the text editor.
This mutates the visible buffer and recolorizes the affected region, but it does not append an undo record, does not create a pending SourceEditIntent, and leaves isTextChanged false. Use this for XML-owned canvas writebacks that are being mirrored into the source pane.
| offset | Byte offset in the current buffer. |
| removedLength | Number of bytes to remove at offset. |
| replacement | Replacement bytes to insert at offset. |
|
inline |
Resolve a full-buffer byte offset to editor coordinates.
| offset | Byte offset in getText(). |