diff --git a/src/plot.rs b/src/plot.rs
index 3207e74..4f11b2d 100644
--- a/src/plot.rs
+++ b/src/plot.rs
@@ -51,6 +51,8 @@ impl Ring {
}
}
+/// Plain rounding map (used by tests; hysteresis variant is used in render).
+#[allow(dead_code)]
fn levels(samples: &[f64], max: f64, rows: usize) -> Vec<usize> {
// Row 0 = top of the plot = max value.
samples
@@ -152,16 +154,33 @@ pub fn render(
};
let st = Style::default().fg(color);
+ // nvtop's connected staircase (plot.c lines 55-107, pattern only):
+ // on a step, the corner glyphs *join* the horizontals — old level gets
+ // a corner open toward the incoming line, new level a corner open
+ // toward the outgoing line, '│' strictly between. Every horizontal run
+ // therefore connects to the next through a corner, no gaps.
for (c, &l) in lvls.iter().enumerate() {
- set(l, c, '─', st);
- if c > 0 {
- // Vertical join strictly BETWEEN the levels (endpoints excluded:
- // both endpoint rows already carry '─' — overwriting them with
- // '│' erased the level dash on every transition column, the
- // "─│─│" comb). Subagent-diagnosed off-by-one.
- let prev = lvls[c - 1];
- let (top, bot) = if prev < l { (prev, l) } else { (l, prev) };
- for r in top + 1..bot {
+ if c == 0 {
+ set(l, c, '─', st);
+ continue;
+ }
+ let prev = lvls[c - 1];
+ if prev == l {
+ set(l, c, '─', st);
+ } else if prev < l {
+ // value fell: line steps DOWN screen. Old level: '╮' (opens
+ // left toward incoming). New level: '╰' (opens right toward
+ // outgoing). '│' between.
+ set(prev, c, '╮', st);
+ set(l, c, '╰', st);
+ for r in prev + 1..l {
+ set(r, c, '│', st);
+ }
+ } else {
+ // value rose: line steps UP screen. Old level: '╯', new: '╭'.
+ set(prev, c, '╯', st);
+ set(l, c, '╭', st);
+ for r in l + 1..prev {
set(r, c, '│', st);
}
}
Plot: nvtop connected-corner staircase (corners join horizontals to verticals; ╮╰ / ╯╭ pairs) — no more floating segments
c561d253e8cec1cc59f91d1ab8cd968a489a116b
josie <administrator@josie-c.com> · 2026-08-30T13:56 ·
browse files at this commit
parents:
a05ba41