tui-editor

command
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

tui-editor is the reference loom-style interactive demo for tui.App: a modal (vi-inspired) text editor built on top of the existing toolkit widgets — TextView for the buffer, Statusbar for the mode + cursor + filename indicator, MenuBar for the chrome, and a Popover-wrapped SearchEntry for the command palette.

Modes:

  • View — read-only. Keys drive actions: 'i' → Edit, 'q' / Ctrl+C → Quit, Ctrl+S → save, Ctrl+P → Palette. Every printable key is consumed so nothing leaks into the buffer.
  • Edit — every key falls through to TextView.OnEvent, so arrow keys move the cursor, Backspace deletes, and printable characters insert. Escape returns to View. Ctrl+S saves (consumed, does not insert Ctrl+S into the buffer).
  • Palette — keys forward to a SearchEntry inside a Popover. Enter runs the typed command ("save", "quit"); Escape returns to View.

Run with:

go run . --file=path/to/file.txt
go run . --theme=dark

The demo saves via os.WriteFile (writeFile seam so tests substitute a no-op) and loads via os.ReadFile (readFile seam). Both are unset when --file is empty; the editor starts on an in-memory buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL