Expand description
A real NSTextView (in its NSScrollView) as a text editor, plain or rich.
What AppKit brings: IME with the candidate window at the caret, spell and grammar checking with the suggestion menu, the find bar, undo, text services (Look Up, Translate, Writing Tools), Dark Mode and VoiceOver.
Offsets in this API are UTF-8 byte offsets into the text, as Rust strings
use; they’re converted from AppKit’s UTF-16 ranges at the boundary.
Like crate::table::TableModel, user actions are queued on the model
and announced with crate::request_redraw.
Styled text: TextModel::set_highlighter colours and emphasises runs
of the text (syntax highlighting, search matches), re-run on every edit
before it’s drawn. The text stays plain: styles aren’t typed, pasted,
copied or undone.
Rich text: TextModel::set_rich lets the user style the text
themselves (fonts, bold, colours, alignment, lists, pictures), with the
font panel, the ruler and the format bar; TextModel::rtf and
TextModel::html read it out, TextModel::set_rtf and
TextModel::set_html load it.
Structs§
- Completion
- What a completer offers at the caret: the text it completes (a byte
range ending at the caret, such as the partial word) and the words that
would replace it, best first. See
TextModel::set_completer. - Text
Model - A native plain-text editor. Cheap to clone (a handle); main thread only.
- Text
Style - How a run of text looks. What it leaves unset stays as the editor’s own (its font and text colour).
Enums§
- Color
- A colour: for text, backgrounds, borders, drawing. The named ones are the system’s colours: they follow Dark Mode, Increase Contrast and the user’s accent colour.