Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::TextEditorCore Class Reference

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.
std::string getText () const
std::string getText (const Coordinates &start, const Coordinates &end) const
bool isTextChanged () const
void resetTextChanged ()
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 CoordinatesgetSelectionStart () const
const CoordinatesgetSelectionEnd () 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 LanguageDefinitiongetLanguageDefinition () 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 PalettegetPalette () 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
TextBufferbuffer ()
const TextBufferbuffer () const
EditorStatemutableState ()
const EditorStatestate () 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)
CoordinatesinteractiveStart ()
CoordinatesinteractiveEnd ()
PalettemutablePalette ()
const PalettelivePalette () const
PalettemutablePaletteBase ()
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 ()
SelectionModeselectionModeRef ()
bool & textChangedRef ()
bool & autoIndentOnPasteRef ()
unsigned int getGlyphColor (const Glyph &glyph) const
void removeLine (int start, int end)
void removeLine (int index)
LineinsertLine (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 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

Detailed Description

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.


The documentation for this class was generated from the following file: