Editor
April 28, 2026 · View on GitHub
Multi-line text editor with cursor, selection, copy/paste, optional line numbers, and auto-indent.
Constructor: NewEditor(id, class string) *Editor
Content access
Text() string— full content as a single stringLines() []string— content as a slice of linesLoad(text string)— replace content from a stringSetContent(lines []string)— replace content from a line slice
Configuration
SetAutoIndent(auto bool)— copy leading whitespace from the previous line on EnterSetReadOnly(ro bool)— disable editing without removing focusabilitySetTabWidth(width int)— visual width of a tab characterUseSpaces(useSpaces bool)— insert spaces instead of tab charactersShowLineNumbers(show bool)— toggle the gutter
Cursor / movement
Left() / Right() / Up() / Down()— move one character / lineHome() / End()— start / end of current lineDocumentHome() / DocumentEnd()— start / end of documentPageUp() / PageDown()— scroll by one pageMoveTo(line, column int)— jump to position
Editing
Insert(ch rune)— insert a character at the cursorDelete()— backspace (delete before the cursor)DeleteForward()— delete at the cursorEnter()— insert a newline with optional auto-indent
Selection
HasSelection() boolSelectAll(),ClearSelection()SelectionText() string— selected textDeleteSelection()ShiftLeft() / ShiftRight() / ShiftUp() / ShiftDown() / ShiftHome() / ShiftEnd()— extend selection by movement
Clipboard
Copy()— copy the selection (uses the system clipboard viaatotto/clipboard)Cut()— copy + deletePaste()— insert clipboard contents at the cursor
Events
| Event | Data | Description |
|---|---|---|
"change" | — | Content modified |
Notes
Flags: "focusable", "readonly".
Backed by a gap-buffer per line for efficient editing in long files. Long lines are not wrapped; they scroll horizontally.