tui: text-input primitive with cursor motion, word ops, and paste #58

Closed
opened 2026-08-23 19:28:04 +01:00 by naps62-yolo · 1 comment
Collaborator

SpawnModal::on_input in crates/maestro-tui/src/overlays.rs handles typing with String::push and backspace with String::pop. There is no cursor: the operator cannot move left, cannot fix a typo in the middle of a path, cannot delete a word, and cannot paste. For two fields that is merely bad; for the richer draft form the rest of this milestone builds it is unusable, so this lands first.

Add a shared single-line text-input widget to the TUI:

  • Cursor motion: left/right, home/end, word-left and word-right.
  • Editing: backspace and delete at the cursor, delete-word-backwards, kill-to-end.
  • Paste: bracketed paste arrives as crossterm's paste event, not as a burst of key events — insert it as one operation so a pasted path does not go through the per-character path.
  • Horizontal scrolling when the value is wider than the field, keeping the cursor visible.
  • Rendering reports the cursor's screen column so the caller can position the terminal cursor, which overlays.rs does by hand today.

Unit-test it directly against InputKey sequences — this is the one piece of the TUI form that can be tested without a terminal.

Non-goals: multi-line input; undo; selection or clipboard integration beyond receiving a paste event.

`SpawnModal::on_input` in `crates/maestro-tui/src/overlays.rs` handles typing with `String::push` and backspace with `String::pop`. There is no cursor: the operator cannot move left, cannot fix a typo in the middle of a path, cannot delete a word, and cannot paste. For two fields that is merely bad; for the richer draft form the rest of this milestone builds it is unusable, so this lands first. Add a shared single-line text-input widget to the TUI: - Cursor motion: left/right, home/end, word-left and word-right. - Editing: backspace and delete at the cursor, delete-word-backwards, kill-to-end. - Paste: bracketed paste arrives as `crossterm`'s paste event, not as a burst of key events — insert it as one operation so a pasted path does not go through the per-character path. - Horizontal scrolling when the value is wider than the field, keeping the cursor visible. - Rendering reports the cursor's screen column so the caller can position the terminal cursor, which `overlays.rs` does by hand today. Unit-test it directly against `InputKey` sequences — this is the one piece of the TUI form that can be tested without a terminal. Non-goals: multi-line input; undo; selection or clipboard integration beyond receiving a paste event.
naps62-yolo added this to the Spawn v2 milestone 2026-08-23 19:28:04 +01:00
naps62-yolo added the area/tuidifficulty/mediumtype/feat labels 2026-08-23 19:28:04 +01:00
naps62-yolo added a new dependency 2026-08-23 19:29:56 +01:00
Author
Collaborator

Integrated into blitz/spawn-v2 as 35bc5bf.

crates/maestro-tui/src/text_input.rs holds the widget; InputKey gained home/end/delete and a bracketed-paste variant, and terminal.rs enables bracketed paste. The spawn overlay's cwd and command fields now go through it.

Verified on the integration branch: just test green through the gate (fmt check, clippy --all-targets -D warnings, full workspace tests).

Integrated into `blitz/spawn-v2` as 35bc5bf. `crates/maestro-tui/src/text_input.rs` holds the widget; `InputKey` gained home/end/delete and a bracketed-paste variant, and `terminal.rs` enables bracketed paste. The spawn overlay's cwd and command fields now go through it. Verified on the integration branch: `just test` green through the gate (fmt check, `clippy --all-targets -D warnings`, full workspace tests).
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Reference: naps62/maestro#58