Add mouse support to the TUI (tmux-style tile resize)

Enable mouse in the Bubble Tea program. In the layout grid editor:
click a cell to assign a camera, or press on a tile and drag to
resize its span (grid-snapped). Click-to-select on the menu/list
screens and the camera picker. Works over SSH; edits the config,
so it never fights the daemon geometry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Woodard
2026-07-01 20:07:18 -05:00
parent 9300266f5c
commit 780396076d
4 changed files with 174 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
package tui
import (
"testing"
"github.com/lwoodard/rtsp-streamer/internal/config"
)
func TestCellAtMouse(t *testing.T) {
m := &model{
cfg: &config.Config{Layouts: []config.Layout{{Name: "g", Grid: "3x3"}}},
editLayout: 0,
}
cases := []struct {
x, y int
wantCol, wRow int
ok bool
}{
{1, 3, 0, 0, true}, // first content row, first cell
{12, 3, 1, 0, true}, // second column (x past the divider at 11)
{1, 6, 0, 1, true}, // second grid row
{23, 9, 2, 2, true}, // third column, third row
{1, 1, 0, 0, false}, // in the title/blank header area
{1, 12, 0, 0, false}, // below the 3x3 grid
}
for _, tc := range cases {
col, row, ok := m.cellAtMouse(tc.x, tc.y)
if ok != tc.ok || (ok && (col != tc.wantCol || row != tc.wRow)) {
t.Errorf("cellAtMouse(%d,%d) = (%d,%d,%v), want (%d,%d,%v)",
tc.x, tc.y, col, row, ok, tc.wantCol, tc.wRow, tc.ok)
}
}
}