Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
TextEditorCore.h File Reference

Headless editing substrate for the ImGui TextEditor widget. More...

#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <regex>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "donner/base/RcString.h"
#include "donner/editor/TextBuffer.h"
Include dependency graph for TextEditorCore.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::EditorState
 Editor cursor and selection state, captured by value for undo/redo. More...
class  donner::editor::UndoRecord
 Record of a single text mutation for undo/redo. More...
struct  donner::editor::UndoState
 Scratch state threaded through the helpers that handle a single character insertion (handleNewLine, handleRegularCharacter, etc.). More...
struct  donner::editor::Identifier
 An editor-recognized identifier (function, variable, attribute name). More...
struct  donner::editor::LanguageDefinition
 Definition of a programming language's syntax for highlighting. More...
class  donner::editor::TextEditorCore
 Headless editing substrate — the text buffer, cursor, undo history and syntax colorizer with no ImGui dependency. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Typedefs

using donner::editor::Identifiers = std::unordered_map<std::string, Identifier>
using donner::editor::Keywords = std::unordered_set<std::string>
using donner::editor::ErrorMarkers = std::map<int, std::string>
using donner::editor::Palette = std::array<unsigned int, static_cast<size_t>(ColorIndex::Max)>
 Color palette indexed by ColorIndex.

Enumerations

enum class  donner::editor::SelectionMode {
  Normal ,
  Word ,
  Line
}
 Editor selection modes that affect how text selection behaves. More...

Detailed Description

Headless editing substrate for the ImGui TextEditor widget.

Commit 1 of the three-commit TextEditor refactor (docs/design_docs/text_editor_refactor.md). TextEditorCore owns the editable buffer, cursor/selection state, undo history, and syntax colorizer. It exposes every editing operation as a plain C++ method and has zero dependency on imgui.h, fonts, or any rendering layer.

donner::editor::TextEditor remains the public user-facing widget; it holds a TextEditorCore core_ by value and forwards every editing-path method to it via a one-line wrapper. Callers of TextEditor see no API change. A later commit (C2) introduces a ClipboardInterface so that copy(), cut(), and paste() can also migrate to the core. C3 then moves the tests onto TextEditorCore directly so they run without an ImGui context.

Palette type note

The canonical Palette type was std::array<ImU32, N>. To keep this header ImGui-free we use std::array<uint32_t, N> instead — ImU32 is a typedef unsigned int in ImGui, so the representation matches and the shell can freely interchange the two at call sites via implicit conversion in ImGui's drawlist APIs.

Typedef Documentation

◆ Palette

using donner::editor::Palette = std::array<unsigned int, static_cast<size_t>(ColorIndex::Max)>

Color palette indexed by ColorIndex.

Intentionally declared as std::array<unsigned int, N> rather than std::array<ImU32, N> so this header stays ImGui-free. ImU32 is a typedef unsigned int in ImGui (see imgui.h), so the two types are identical and freely interchangeable at call sites in the shell.

Enumeration Type Documentation

◆ SelectionMode

enum class donner::editor::SelectionMode
strong

Editor selection modes that affect how text selection behaves.

Enumerator
Normal 

Character-by-character selection.

Word 

Select whole words.

Line 

Select whole lines.