Expand description
Multi-line plain-text and code editing surfaces.
Three faces over one core:
CodeEditor— a source editor: gutter, current-line highlight, indentation, bracket handling, multiple carets.PlainTextEditor— the same core with the code affordances off and wrapping on: a notes field, a commit message, a description box.LogView— read-only, append-only, tail-following.
They are one implementation because they differ in configuration, not in kind. All three are a monospaced-or-not run of lines with a caret in it; a separate widget per face would triplicate the caret, selection, IME, clipboard, scrolling, and accessibility and let them drift.
§Why not RichTextEditor
RichTextEditor already edits multi-line text, and this deliberately does
not build on it. Its command vocabulary is tables, lists, blockquotes, and
bold — reusing it would put Tab-navigates-a-table-cell and
Ctrl+B-emboldens into a source file, where the first is wrong and the second
is meaningless. Its state carries a table-aware Ctrl+A ladder and a rich
clipboard fragment; this one carries an indent policy and a caret vector.
The overlap is real but it is the clock — the caret blink, the debounce
window, the scroll arithmetic — and that lives in the crate-internal
common::editor_runtime, shared by both.
§Language-agnostic by construction
There is no Language enum here. Comment tokens, bracket pairs, indent
width, and highlighting are CodeConfig values the application supplies:
the editor knows how to toggle a line comment, not that Rust uses //.
Guessing would be worse than not knowing — inserting // into a Python file
corrupts it silently.
Structs§
- Bracket
Pair - A pair of characters the editor treats as opening and closing delimiters.
- Code
Config - Editing behaviour the code editor applies, all supplied by the application.
- Code
Editor - A multi-line source-code editing surface: gutter, current-line highlight, indentation, bracket handling, and multiple carets.
- Code
Editor Handle - A handle onto a live editor, cloneable and detachable from the widget.
- Completion
Context - What a completion provider is told about the caret when asked for candidates.
- Completion
Item - A completion candidate. Build with
CompletionItem::newand the fluent setters;insert_textdefaults tolabel. - LogView
- A read-only, append-only, tail-following log / console view.
- LogView
Handle - A cloneable handle to append to a
LogViewand drive it. - Plain
Text Editor - A multi-line plain-text editing surface — the code editor with its code affordances off and wrapping on. A notes field, a commit message, a description box.
Enums§
- Code
Command - Commands the code editor’s keyboard layer may emit.
- Completion
Kind - The category of a completion candidate — drives a small leading badge only. Deliberately a fixed, language-neutral set: the editor renders a glyph, the application decides which candidate is which kind.
- Indent
Style - How a line’s leading indentation is written.
Constants§
- CODE_
EDITOR_ PRESET - The editable preset, shared by
CodeEditor::newandPlainTextEditor::new: every command accepted, blinking caret,MultilineTextInputrole, full clipboard. - CODE_
READ_ ONLY_ PRESET - The read-only preset for
CodeEditor::read_only/PlainTextEditor::read_onlyand for a streaming log view. - COMMON_
BRACKETS - The three pairs that are structural in essentially every bracketed language. A convenience starting point, not a default — an editor with no configured pairs simply does no bracket handling, which is correct for prose or a log.