Skip to content

TUI: support multi-line paste via bracketed paste mode #489

@bug-ops

Description

@bug-ops

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

  1. 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
  2. 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
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions