Skip to content

feat: tui polish - #6

Merged
sunng87 merged 8 commits into
mainfrom
feat/tui-polish
Jul 10, 2026
Merged

sunng87 merged 8 commits into
mainfrom
feat/tui-polish

Conversation

@sunng87

@sunng87 sunng87 commented Jul 10, 2026

Copy link
Copy Markdown
Owner
  • line wrap toggle
  • border highlight

sunng87 added 8 commits July 10, 2026 11:23
- `w` toggles line wrap (Paragraph::wrap, no trim); scroll range widens when
  wrap is on so the last event stays reachable.
- Zebra striping on the packet view, shaded by the terminal's theme: a best-
  effort OSC 11 query (non-blocking stdin read on unix) detects the default
  background, with COLORFGBG and a dark fallback. Dark -> Indexed(236),
  Light -> Indexed(254).
- The packet view block gets a green border.

Verified via PTY: wrap toggles cleanly, border emits green, zebra emits bg
Indexed(236) on dark; clean quit.
- Zebra stripe colour is now DarkGray on dark terminals, Gray on light ones
  (was Indexed(236)/(254)).
- The background now fills the entire row width, not just the cells under the
  text. Each packet row is rendered as its own widget: a borderless Block paints
  the full-width background, then the styled text Paragraph is drawn on top.
  Wrapped events size themselves via Paragraph::line_count (gated by ratatui's
  unstable-rendered-line-info feature) so multi-row events stay fully striped.

Verified via PTY: rows emit bg 48;5;8 (DarkGray) with trailing filler spaces
carrying the bg out to the row edge; green border present; wrap toggles; rc=0.
The zebra background didn't read well, so drop it: no per-row background, no
OSC 11 / COLORFGBG theme probe. Reverts to a single Paragraph for the packet
view. This also removes the now-unneeded libc dependency and ratatui's
unstable-rendered-line-info feature (Paragraph::line_count).

Kept: the `w` line-wrap toggle and the green packet-view border.
Each event row is separated by a blank line in the default (non-wrap) view.
Since a row now occupies two terminal lines, the visible window is halved
(log_h.div_ceil(2) events) and the scroll range / follow target adjust so the
newest events still land at the bottom. Wrap mode stays dense (per-row spacing
there would need per-line height info).
In wrap mode max_scroll was len-1, so with follow on the draw window collapsed
to events[len-1..len] — a single line (the Terminate), starving the view of the
recent stream. Drop the wrap special-case: follow pins to the last log_h events
in both modes (short lines are one row; only genuinely long ones wrap/clip).
Previously the wrap viewport rendered a fixed window of log_h events, so
multi-row (wrapped) events overflowed and were clipped at the bottom — the
newest / multi-line items lost rows. Now the window is sized by display rows:
wrap_window fills the viewport with whole items, backward from the newest when
following, forward from the scroll anchor otherwise. Item heights come from
Paragraph::line_count with .wrap() set (re-enables ratatui's
unstable-rendered-line-info feature — the right tool for this; it was only
removed along with the zebra experiment).

Verified: a 300-char value ending in a sentinel is fully visible (sentinel
present) in both follow+wrap and scroll+wrap; no-wrap unchanged.
Wire the BANNER figlet into clap via before_help so it prints at the top of
-h/--help. BANNER is now used, so the dead_code workaround is dropped (clippy
-D warnings passes cleanly again).
@sunng87
sunng87 merged commit 3b5f49f into main Jul 10, 2026
2 checks passed
@sunng87
sunng87 deleted the feat/tui-polish branch July 10, 2026 16:03
@sunng87
sunng87 restored the feat/tui-polish branch July 11, 2026 03:04
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