Mirror the panel in the console table as one summed row in two sections

This commit is contained in:
flamingcow
2026-08-04 14:02:53 -07:00
parent fbfcabda7e
commit 63196eb691
4 changed files with 76 additions and 98 deletions
+38 -7
View File
@@ -111,6 +111,7 @@ func scaleTime(d time.Duration) string {
}
type colSpec struct {
group string
title string
width int
right bool
@@ -122,15 +123,33 @@ type streamTable struct {
headerEvery int
}
// A group change is drawn as a vertical break, so the two halves of the row
// read apart without a second header line naming them.
func (t *streamTable) join(cells []string, brk string) string {
var b strings.Builder
for i, c := range cells {
if i > 0 {
if t.cols[i].group != t.cols[i-1].group {
b.WriteString(brk)
} else {
b.WriteByte(' ')
}
}
b.WriteString(c)
}
return b.String()
}
func (t *streamTable) headerLines() []string {
var titles, rules []string
for _, c := range t.cols {
titles = append(titles, pad(c.title, c.width, c.right))
rules = append(rules, strings.Repeat("─", c.width))
titles := make([]string, len(t.cols))
rules := make([]string, len(t.cols))
for i, c := range t.cols {
titles[i] = paint(pad(c.title, c.width, c.right), cBold)
rules[i] = strings.Repeat("─", c.width)
}
return []string{
paint(strings.Join(titles, " "), cBold),
paint(strings.Join(rules, " "), cGrey),
t.join(titles, paint(" │ ", cGrey)),
paint(t.join(rules, "─┼─"), cGrey),
}
}
@@ -140,6 +159,9 @@ func (t *streamTable) width() int {
w += c.width
if i > 0 {
w++
if t.cols[i].group != t.cols[i-1].group {
w += 2
}
}
}
return w
@@ -174,7 +196,7 @@ func (t *streamTable) emit(cells []string) []string {
padded = append(padded, pad(v, c.width, c.right))
}
t.sinceHeader++
return append(out, strings.Join(padded, " "))
return append(out, t.join(padded, paint(" │ ", cGrey)))
}
func renderBox(title string, headers []string, rights []bool, rows [][]string) string {
@@ -232,6 +254,15 @@ func renderBox(title string, headers []string, rights []bool, rows [][]string) s
return b.String()
}
// Whether rather than how many, matching the panel's top chips: over a window
// this short a count changes faster than it can be read.
func flagCell(v uint64) string {
if v == 0 {
return paint("ok", cGreen)
}
return paint("ERR", cRed)
}
// Exact rather than scaled: scaled, one lost frame and a thousand both read as
// 1.00, separated only by a letter.
func statusCell(v uint64) string {