1. Scrolling and click to set the cursor works. 2. GUI now uses Brass Mono as the font. 3. A lot of stability and other updates.
5.0 KiB
5.0 KiB
kte ROADMAP — from skeleton to a working editor
Scope for “working editor” v0.1
- Runs in a terminal; opens files passed on the CLI or an empty buffer.
- Basic navigation, insert/delete, newline handling.
- Status line and message area; shows filename, dirty flag, cursor position.
- Save file(s) to disk safely; quit/confirm on dirty buffers.
- Core ke key chords: C-g (cancel), C-k s/x/q/C-q, C-l, basic arrows, Enter/Backspace, C-s (simple find).
Guiding principles
- Keep the core small and understandable; evolve incrementally.
- Separate model (Buffer/Editor), control (Input/Command), and view (Renderer).
- Favor terminal first; GUI hooks arrive later behind interfaces.
✓ Milestone 0 — Wire up a minimal app shell
- main.cpp
- Replace demo printing with real startup using
Editor. - Parse CLI args; open each path into a buffer (create empty if none). ✓ when
kte file1 file2loads buffers and exits cleanly.
- Replace demo printing with real startup using
- Editor integration
- Ensure
Editorcan open/switch/close buffers and hold status messages. - Add a temporary “headless loop” to prove open/save calls work.
- Ensure
✓ Milestone 1 — Command model
- Command vocabulary
- Flesh out
Command.h/.cpp: enums/struct for operations and data (e.g., InsertChar, MoveCursor, Save, Quit, FindNext, etc.). - Provide a dispatcher entry point callable from the input layer to mutate
Editor/Buffer. - Definition of done: commands exist for minimal edit/navigation/save/quit; no rendering yet.
- Flesh out
✓ Milestone 2 — Terminal input
- Input interfaces
- Add
InputHandler.hinterface plusTerminalInputHandlerimplementation. - Terminal input via ncurses (
getch,keypad, non‑blocking withnodelay), basic key decoding (arrows, Ctrl, ESC sequences).
- Add
- Keymap
- Map ke chords to
Command(C-k prefix handling, C-g cancel, C-l refresh, C-k s/x/q/C-q, C-s find start, text input → InsertChar).
- Map ke chords to
- Event loop
- Introduce the core loop in main: read key → translate to
Command→ dispatch → trigger render.
- Introduce the core loop in main: read key → translate to
✓ Milestone 3 — Terminal renderer
- View interfaces
- Add
Renderer.hwithTerminalRendererimplementation (ncurses‑based).
- Add
- Minimal draw
- Render viewport lines from current buffer; draw status bar (filename, dirty, row:col, message).
- Handle scrolling when cursor moves past edges; support window resize (SIGWINCH).
- Cursor
- Place terminal cursor at logical buffer location (account for tabs later; start with plain text).
Milestone 4 — Buffer fundamentals to support editing
- GapBuffer
- Ensure
GapBuffersupports insert char, backspace, delete, newline, and efficient cursor moves.
- Ensure
- Buffer API
- File I/O (open/save), dirty tracking, encoding/line ending kept simple (UTF‑8, LF) for v0.1.
- Cursor state, mark (optional later), and viewport bookkeeping.
- Basic motions
- Left/Right/Up/Down, Home/End, PageUp/PageDown; word f/b (optional in v0.1).
Milestone 5 — Core editing loop complete
- Tighten loop timing
- Ensure keystroke→update→render latency is reliably low; avoid unnecessary redraws.
- Status/messages
Editor::SetStatus()shows transient messages; C-l forces full refresh.
- Prompts
- Minimal prompt line for save‑as/confirm quit; blocking read in prompt mode is acceptable for v0.1.
Milestone 6 — Search (minimal)
- Incremental search (C-s)
- Simple forward substring search with live highlight of current match; arrow keys navigate matches while in search mode (ke‑style quirk acceptable).
- ESC/C-g exits search; Enter confirms and leaves cursor on match.
Milestone 7 — Safety and polish for v0.1
- Safe writes
- Write to temp file then rename; preserve permissions where possible.
- Dirty/quit logic
- Confirm on quit when any buffer is dirty;
C-k C-qbypasses confirmation.
- Confirm on quit when any buffer is dirty;
- Resize/terminal quirks
- Handle small terminals gracefully; no crashes on narrow widths.
- Basic tests
- Unit tests for
GapBuffer, Buffer open/save round‑trip, and command mapping.
- Unit tests for
Out of scope for v0.1 (tracked, not blocking)
- Undo/redo, regex search, kill ring, word motions, tabs/render width, syntax highlighting, piece table selection, GUI.
Implementation notes (files to add)
- Input:
InputHandler.h,TerminalInputHandler.cc/h(ncurses). - Rendering:
Renderer.h,TerminalRenderer.cc/h(ncurses). - Prompt helpers: minimal utility for line input in raw mode.
- Platform: small termios wrapper; SIGWINCH handler.
Acceptance checklist for v0.1
- Start:
./kte [files]opens files or an empty buffer. - Edit: insert text, backspace, newlines; move cursor; content scrolls.
- Save:
C-k swrites file atomically; dirty flag clears; status shows bytes written. - Quit:
C-k qconfirms if dirty;C-k C-qexits without confirm;C-k xsave+exit. - Refresh:
C-lredraws. - Search:
C-sfinds next while typing; ESC cancels.
Next concrete step
- Stabilize cursor placement and scrolling logic; add resize handling and begin minimal prompt for save‑as.