Problem
Pasting multi-line text into the TUI input field does not preserve newlines. Crossterm bracketed paste mode is not enabled, so pasted text arrives as individual KeyCode::Char events with newlines stripped by the terminal.
Proposed solution
Enable crossterm bracketed paste and handle Event::Paste(text) to insert the full string at cursor position.
Changes
-
crates/zeph-tui/src/lib.rs — enable/disable bracketed paste:
- Add
crossterm::event::EnableBracketedPaste to the terminal setup sequence (alongside EnableMouseCapture)
- Add
crossterm::event::DisableBracketedPaste to the teardown/cleanup
-
crates/zeph-tui/src/event.rs — propagate paste events:
- Add
Paste(String) variant to AppEvent enum
- Handle
CrosstermEvent::Paste(text) => AppEvent::Paste(text) in the event reader
-
crates/zeph-tui/src/app.rs — insert pasted text:
- Add
AppEvent::Paste(text) arm in handle_event()
- Insert the full string at
byte_offset_of_char(cursor_position)
- Advance
cursor_position by text.chars().count()
- This naturally preserves newlines in the pasted content (multi-line input already works via Shift+Enter)
Notes
- Bracketed paste is widely supported by modern terminals (iTerm2, Terminal.app, Alacritty, kitty, WezTerm)
- No config option needed — this should always be enabled
- Existing
Shift+Enter newline insertion continues to work as before
Problem
Pasting multi-line text into the TUI input field does not preserve newlines. Crossterm bracketed paste mode is not enabled, so pasted text arrives as individual
KeyCode::Charevents with newlines stripped by the terminal.Proposed solution
Enable crossterm bracketed paste and handle
Event::Paste(text)to insert the full string at cursor position.Changes
crates/zeph-tui/src/lib.rs— enable/disable bracketed paste:crossterm::event::EnableBracketedPasteto the terminal setup sequence (alongsideEnableMouseCapture)crossterm::event::DisableBracketedPasteto the teardown/cleanupcrates/zeph-tui/src/event.rs— propagate paste events:Paste(String)variant toAppEventenumCrosstermEvent::Paste(text) => AppEvent::Paste(text)in the event readercrates/zeph-tui/src/app.rs— insert pasted text:AppEvent::Paste(text)arm inhandle_event()byte_offset_of_char(cursor_position)cursor_positionbytext.chars().count()Notes
Shift+Enternewline insertion continues to work as before