From 16416bc1b0c669195c61e211858e50bf0565b66a Mon Sep 17 00:00:00 2001 From: flamingcow Date: Sat, 25 Jul 2026 19:31:03 -0700 Subject: [PATCH] Draw the counter reset as a labelled rule across the table --- main.go | 2 +- render.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 196f557..f7cba87 100644 --- a/main.go +++ b/main.go @@ -461,7 +461,7 @@ func run(aName, bName, sizesArg, patArg string, d.resetErrors() } stats.sinceHeader = 0 - fmt.Println(paint("error counts reset", cDim)) + fmt.Println(stats.rule("error counts reset")) case now := <-tick.C: secs := now.Sub(last).Seconds() last = now diff --git a/render.go b/render.go index 4ac38bd..8b1d221 100644 --- a/render.go +++ b/render.go @@ -111,6 +111,31 @@ func (t *streamTable) headerLines() []string { } } +func (t *streamTable) width() int { + w := 0 + for i, c := range t.cols { + w += c.width + if i > 0 { + w++ + } + } + return w +} + +// A labelled horizontal rule spanning the table, for marking a break in the +// stream of rows. +func (t *streamTable) rule(label string) string { + const lead = 3 + text := " " + label + " " + trail := t.width() - lead - visWidth(text) + if trail < 0 { + trail = 0 + } + return paint(strings.Repeat("─", lead), cGrey) + + paint(text, cDim) + + paint(strings.Repeat("─", trail), cGrey) +} + func (t *streamTable) emit(cells []string) []string { var out []string if t.sinceHeader == 0 || (t.headerEvery > 0 && t.sinceHeader >= t.headerEvery) {