Skip to content

TUI: word-jump and line-jump cursor navigation in input field #487

@bug-ops

Description

@bug-ops

Problem

Input field cursor navigation is limited to single-character movement with arrow keys. Home/End keys work but are not discoverable, and there is no word-level navigation.

Proposed solution

Add standard terminal cursor shortcuts in handle_insert_key() (crates/zeph-tui/src/app.rs):

Shortcut Action
Alt+Left Jump to previous word boundary
Alt+Right Jump to next word boundary
Ctrl+A Jump to start of line (same as Home)
Ctrl+E Jump to end of line (same as End)
Alt+Backspace Delete previous word

Implementation

  1. Add prev_word_boundary(&self) -> usize and next_word_boundary(&self) -> usize helpers that scan self.input chars from cursor_position looking for word boundaries (transition between whitespace/punctuation and alphanumeric).

  2. Handle KeyCode::Left with ALT modifier and KeyCode::Right with ALT modifier in the existing match block.

  3. Map Ctrl+A / Ctrl+E to cursor_position = 0 / char_count() respectively.

  4. Add Alt+Backspace to delete from cursor to previous word boundary.

  5. Add tests for all new navigation and deletion shortcuts.

Notes

  • On macOS, Cmd+Arrow keys are intercepted by the terminal emulator and do not reach the application, so Ctrl+A/E (emacs-style) is the standard approach.
  • Word boundary detection should handle Unicode properly (use char::is_alphanumeric()).
  • Existing Home/End handlers remain unchanged.

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