Skip to content

feat: editor/ sample app — multi-buffer text editor (Stage 4 §3.2) - #189

Merged
rorygraves merged 1 commit into
mainfrom
feat/editor-sample-app
Apr 29, 2026
Merged

feat: editor/ sample app — multi-buffer text editor (Stage 4 §3.2)#189
rorygraves merged 1 commit into
mainfrom
feat/editor-sample-app

Conversation

@rorygraves

Copy link
Copy Markdown
Contributor

Summary

Closes another §3.2 sample-app gap. A focused multi-buffer editor that
exercises `widgets.MultiLineInput` + `widgets.SplitPane` +
`widgets.MenuBar` in one app.

Layout

  • Menu bar (File / Edit) at the top.
  • `SplitPane` — buffer list on the left, editor on the right.
  • `StatusBar` at the bottom showing buffer count, dirty state, and the most recent action.

Buffers

  • Starts with one untitled buffer.
  • `Ctrl+N` adds a new untitled buffer.
  • `Ctrl+O` opens a `Dialogs.textInput` overlay; Enter loads the path into a new buffer; Esc cancels.
  • `Ctrl+S` writes the current buffer (refuses untitled — surfaced in the status bar).
  • `Ctrl+W` closes the active buffer; closing the only buffer leaves a fresh untitled.
  • `Ctrl+I` (Ctrl-Tab on most terminals) switches to the next buffer.

Quit

  • `Ctrl+Q` / `Ctrl+C` exits when no buffers are dirty.
  • With dirty buffers, surfaces a `Dialogs.confirm` overlay; Tab flips Yes/No focus, Enter commits, Esc cancels.
  • `q` is a printable character inside the editor — not a quit key.

Menu

  • `F2` moves focus to the menu bar; arrows + Enter operate it via `MenuBar.handleKey`. The picked `(menuIdx, itemIdx)` routes through `applyMenuPick` to the same buffer ops as the keyboard shortcuts. `Esc` returns focus to the editor.

Tests

15 specs covering:

  • initial state
  • Ctrl+N / Ctrl+W / Ctrl+I buffer ops
  • dirty tracking via printable characters
  • Enter-in-editor produces a newline (not a quit)
  • `Ctrl+O` flow against a real temp dir on disk: type path → Enter loads file
  • `Ctrl+S` round-trip writes to disk and clears the dirty flag
  • `Ctrl+S` on an untitled buffer reports the error and keeps dirty
  • Ctrl+Q with no dirty exits via the App
  • Ctrl+Q with dirty surfaces ConfirmQuit; Tab flips focus; Enter commits
  • F2 ↔ Esc for menu focus
  • Menu File → New round-trips through `MenuBar.handleKey`

Test plan

  • `sbt termflowSample/testOnly termflow.apps.editor.EditorAppSpec` — 15/15 pass
  • `sbt ciCheck` — green
  • `mdbook build` — clean
  • CI green on this PR
  • Manual smoke: `sbt editorDemo` in a real terminal

Closes another §3.2 sample-app gap. A focused multi-buffer editor
demonstrating widgets.MultiLineInput + widgets.SplitPane +
widgets.MenuBar in one place.

Layout:
  - Menu bar (File / Edit) at the top.
  - SplitPane.Direction.Horizontal: buffer list on the left, editor
    on the right.
  - StatusBar at the bottom showing buffer count, dirty state, and
    the most recent action.

Buffers:
  - One untitled buffer at startup.
  - Ctrl+N adds a new untitled buffer.
  - Ctrl+O opens a textInput dialog; Enter loads the path into a new
    buffer; Esc cancels.
  - Ctrl+S writes the current buffer to disk (refuses untitled —
    surfaced in the status bar).
  - Ctrl+W closes the active buffer; closing the only buffer leaves
    a fresh untitled one.
  - Ctrl+I (Ctrl-Tab on most terminals) switches to the next buffer.

Quit:
  - Ctrl+Q / Ctrl+C exits when no buffers are dirty.
  - With dirty buffers, surfaces a Dialogs.confirm overlay; Tab
    flips Yes/No focus, Enter commits, Esc cancels.

Menu:
  - F2 moves focus to the menu bar; arrows + Enter operate it via
    MenuBar.handleKey; the picked (menuIdx, itemIdx) routes through
    applyMenuPick to the same buffer ops as the keyboard shortcuts.
  - Esc returns focus to the editor.

Tests: 15 specs in EditorAppSpec covering initial state, buffer
ops, dirty tracking, OpenPath dialog flow against a real temp dir
on disk, save round-trip, ConfirmQuit dialog, menu pick → New
buffer.

  - sbt editorDemo command alias added
  - docs/contrib/RUN_EXAMPLES.md updated
@rorygraves
rorygraves force-pushed the feat/editor-sample-app branch from 8941df1 to 873872b Compare April 29, 2026 21:47
@rorygraves
rorygraves merged commit 447cb73 into main Apr 29, 2026
4 checks passed
@rorygraves
rorygraves deleted the feat/editor-sample-app branch April 29, 2026 21:50
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant