Documentation
¶
Overview ¶
Package editor renders an editable multi-line text buffer with a 2D cursor, viewport scrolling, optional line-number gutter, undo/redo, and per-line syntax tint via codeview's tokenizer.
The model is a Bubble Tea component. The buffer is stored as a slice of rune-slices so every column index is a rune index, never a byte offset; multibyte glyphs and combining marks are handled correctly at the cost of treating each rune as one cell (no East-Asian wide- rune awareness in v0.1 — that lives in a later widening of runeWidth).
The editor only knows about *text*. Saves, syntax-aware indentation, language servers, and selection clipboards are intentionally out of scope: the consumer owns the file, the disk, and the OS clipboard. The model exposes Value() so the consumer can persist whenever it wants and emits no Save/Load messages on its own.
Index ¶
- type ChangeMsg
- type Model
- func (m Model) Blur() Model
- func (m Model) Cursor() (int, int)
- func (m Model) Dirty() bool
- func (m Model) Focus() Model
- func (m Model) Focused() bool
- func (m Model) Init() tea.Cmd
- func (m Model) LineCount() int
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Value() string
- func (m Model) View() string
- func (m Model) WithContent(s string) Model
- func (m Model) WithGutter(on bool) Model
- func (m Model) WithHeight(h int) Model
- func (m Model) WithLanguage(lang codeview.Language) Model
- func (m Model) WithTabSize(n int) Model
- func (m Model) WithWidth(w int) Model
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeMsg ¶
ChangeMsg is emitted on every edit so the consumer can mark a tab "dirty" or schedule an autosave. The cursor position is included so the consumer can update breadcrumbs / status-bars in lock-step.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea model for an editable text buffer.
func New ¶
New returns an editor with one empty line, focused, 80 cells wide, 20 rows tall, line numbers on, no language tint, 4-space tabs.
func (Model) Dirty ¶
Dirty reports whether the undo stack has at least one entry — useful for tab "modified" indicators.
func (Model) View ¶
View renders the editor as a bordered frame containing the gutter and the visible slice of the buffer with the cursor injected on its line.
func (Model) WithContent ¶
WithContent presets the buffer. The cursor lands at (0, 0).
func (Model) WithGutter ¶
WithGutter toggles the line-number gutter.
func (Model) WithLanguage ¶
WithLanguage selects the tokenizer dialect for non-cursor lines.
func (Model) WithTabSize ¶
WithTabSize sets the tab expansion width. Clamped to [1, 16].
