Skip to content

Arrow-key picker for the VPN interface prompt - #31

Merged
madeye merged 1 commit into
mainfrom
feature/tui-arrow-select
Jul 8, 2026
Merged

Arrow-key picker for the VPN interface prompt#31
madeye merged 1 commit into
mainfrom
feature/tui-arrow-select

Conversation

@madeye

@madeye madeye commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • When stdin and stdout are TTYs, the VPN interface prompt becomes an interactive menu: ↑/↓ move an inverse-video highlight with wraparound, Enter confirms, digits 1-9 still jump directly, and q / bare Escape / Ctrl-C cancel.
  • Raw mode is hand-rolled on termios via the existing libc dependency — no new crates. A Drop guard restores terminal attributes and cursor visibility on every exit path; ISIG is disabled during selection so Ctrl-C cancels cleanly instead of leaving the terminal in raw mode.
  • Piped/non-TTY stdin keeps the numbered choice> fallback, so scripts and tests are unaffected.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings, cargo test --lib (27/27) pass.
  • Verified through a real pty (script): ↓↓+Enter selects the third interface and generates its PF rules; digit 6 jumps straight to the sixth; q and bare ESC cancel with "VPN interface selection cancelled" and the cursor/termios restored.
  • echo 1 | lianyaohu --print-firewall (non-TTY) still uses the numbered prompt.

🤖 Generated with Claude Code

Replace the type-a-number prompt with an interactive menu when stdin and
stdout are TTYs: up/down arrows move an inverse-video highlight with
wraparound, Enter confirms, digits 1-9 still jump directly, and q, bare
Escape, or Ctrl-C cancel. Raw mode is hand-rolled on termios via the
existing libc dependency (no new crates); a Drop guard restores terminal
attributes and cursor visibility on every exit path, with ISIG disabled so
Ctrl-C cancels through the same cleanup instead of killing the process
mid-raw-mode.

Piped/non-TTY stdin keeps the numbered choice> fallback so scripts and
tests are unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@madeye
madeye merged commit 94b86f9 into main Jul 8, 2026
2 checks passed
@madeye
madeye deleted the feature/tui-arrow-select branch July 8, 2026 08:12
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