So much work

This commit is contained in:
2025-08-06 16:15:08 -05:00
parent 1474caffaa
commit 81c7ec8324
20 changed files with 1386 additions and 376 deletions

View File

@@ -35,14 +35,15 @@ const (
)
type Checkbox struct {
id string
label string
style tcell.Style
active bool
visible bool
state int
x, y int
w, h int
id string
label string
style tcell.Style
active bool
visible bool
tabbable bool
state int
x, y int
w, h int
stateRunes []rune
}
@@ -60,9 +61,11 @@ func (w *Checkbox) Init(id string, style tcell.Style) {
w.style = style
w.visible = true
w.stateRunes = []rune{'X', ' ', '-'}
w.tabbable = true
}
func (w *Checkbox) Id() string { return w.id }
func (w *Checkbox) HandleResize(ev *tcell.EventResize) {}
func (w *Checkbox) HandleResize(ev *tcell.EventResize) { w.w, w.h = ev.Size() }
func (w *Checkbox) HandleKey(ev *tcell.EventKey) bool {
if !w.active {
return false
@@ -96,6 +99,7 @@ func (w *Checkbox) SetX(x int) { w.x = x }
func (w *Checkbox) SetY(y int) { w.y = y }
func (w *Checkbox) GetX() int { return w.x }
func (w *Checkbox) GetY() int { return w.y }
func (w *Checkbox) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Checkbox) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Checkbox) SetW(x int) { w.w = x }
func (w *Checkbox) SetH(y int) { w.h = y }
@@ -104,10 +108,15 @@ func (w *Checkbox) GetH() int { return w.y }
func (w *Checkbox) WantW() int {
return len(fmt.Sprintf("[%s] %s", string(w.state), w.label))
}
func (w *Checkbox) WantH() int { return 1 }
func (w *Checkbox) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Checkbox) Focusable() bool { return true }
func (w *Checkbox) WantH() int { return 1 }
func (w *Checkbox) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Checkbox) Focusable() bool { return true }
func (w *Checkbox) SetTabbable(b bool) { w.tabbable = b }
func (w *Checkbox) Tabbable() bool { return w.tabbable }
func (w *Checkbox) MinW() int {
return len(fmt.Sprintf("[%s] %s", string(w.state), w.label))
}
func (w *Checkbox) MinH() int { return 1 }
func (w *Checkbox) SetLabel(l string) { w.label = l }
func (w *Checkbox) SetChecked(v bool) {