Add mouse tests; tidy TUI idioms

This commit is contained in:
Andy Dixon
2026-10-02 08:36:23 +01:00
parent 71556b76de
commit 8559616b65
7 changed files with 85 additions and 36 deletions
+13 -1
View File
@@ -29,6 +29,15 @@ type table struct {
height int // rows visible in the last paint
}
// scroll moves the cursor three rows for a mouse wheel step.
func (tb *table) scroll(up bool, n int) {
if up {
tb.move(-3, n)
} else {
tb.move(3, n)
}
}
func (tb *table) move(d, n int) {
if n == 0 {
tb.cursor = 0
@@ -177,7 +186,10 @@ func (m *Model) paintBar(cv *Canvas, x, y, w int, frac float64, col Color, sel b
ch = parts[eighths]
}
if t.ASCII {
ch = map[bool]string{true: "#", false: " "}[eighths >= 4]
ch = " "
if eighths >= 4 {
ch = "#"
}
}
eighths -= 8
st := Style{FG: col, BG: bg}