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

@@ -26,6 +26,7 @@ import (
"github.com/gdamore/tcell"
)
// TODO: Make sure this works right... I don't think it does.
type BorderedWidget struct {
id string
style tcell.Style
@@ -35,9 +36,10 @@ type BorderedWidget struct {
widget Widget
border []rune
title string
active bool
visible bool
title string
active bool
visible bool
tabbable bool
logger func(string)
}
@@ -62,11 +64,14 @@ func (w *BorderedWidget) Init(id string, s tcell.Style) {
w.style = s
w.visible = true
w.border = h.BRD_CSIMPLE
w.tabbable = true
}
func (w *BorderedWidget) Id() string { return w.id }
func (w *BorderedWidget) HandleResize(ev *tcell.EventResize) {
w.widget.HandleResize(ev)
// Trim space for border and pass the resize to the widget
w.w, w.h = ev.Size()
w.widget.HandleResize(tcell.NewEventResize(w.w-2, w.h-2))
}
func (w *BorderedWidget) HandleKey(ev *tcell.EventKey) bool {
@@ -89,22 +94,28 @@ func (w *BorderedWidget) Draw(screen tcell.Screen) {
w.widget.SetPos(Coord{X: w.x + 1, Y: w.y + 1})
w.widget.Draw(screen)
}
func (w *BorderedWidget) Active() bool { return w.active }
func (w *BorderedWidget) SetActive(a bool) { w.active = a }
func (w *BorderedWidget) Visible() bool { return w.visible }
func (w *BorderedWidget) SetVisible(a bool) { w.visible = a }
func (w *BorderedWidget) Focusable() bool { return true }
func (w *BorderedWidget) SetX(x int) { w.x = x }
func (w *BorderedWidget) SetY(y int) { w.y = y }
func (w *BorderedWidget) GetX() int { return w.x }
func (w *BorderedWidget) GetY() int { return w.y }
func (w *BorderedWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *BorderedWidget) GetW() int { return w.w }
func (w *BorderedWidget) GetH() int { return w.h }
func (w *BorderedWidget) SetW(wd int) { w.w = wd }
func (w *BorderedWidget) SetH(h int) { w.h = h }
func (w *BorderedWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *BorderedWidget) WantW() int { return w.w }
func (w *BorderedWidget) WantH() int { return w.h }
func (w *BorderedWidget) Active() bool { return w.active }
func (w *BorderedWidget) SetActive(a bool) { w.active = a }
func (w *BorderedWidget) Visible() bool { return w.visible }
func (w *BorderedWidget) SetVisible(a bool) { w.visible = a }
func (w *BorderedWidget) Focusable() bool { return true }
func (w *BorderedWidget) SetTabbable(b bool) { w.tabbable = b }
func (w *BorderedWidget) Tabbable() bool { return w.tabbable }
func (w *BorderedWidget) SetX(x int) { w.x = x }
func (w *BorderedWidget) SetY(y int) { w.y = y }
func (w *BorderedWidget) GetX() int { return w.x }
func (w *BorderedWidget) GetY() int { return w.y }
func (w *BorderedWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *BorderedWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *BorderedWidget) GetW() int { return w.w }
func (w *BorderedWidget) GetH() int { return w.h }
func (w *BorderedWidget) SetW(wd int) { w.w = wd }
func (w *BorderedWidget) SetH(h int) { w.h = h }
func (w *BorderedWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *BorderedWidget) WantW() int { return w.w }
func (w *BorderedWidget) WantH() int { return w.h }
func (w *BorderedWidget) MinW() int { return 2 + w.widget.MinW() }
func (w *BorderedWidget) MinH() int { return 2 + w.widget.MinH() }
func (w *BorderedWidget) SetBorder(r []rune) { w.border = r }
func (w *BorderedWidget) SetBorder(r []rune) { w.border = r }
func (w *BorderedWidget) SetTitle(ttl string) { w.title = ttl }