Really figuring some things out

This commit is contained in:
2025-08-07 11:18:03 -05:00
parent 7c96fbb187
commit b476c74683
23 changed files with 737 additions and 249 deletions

View File

@@ -22,7 +22,7 @@ THE SOFTWARE.
package widgets
import (
h "git.bullercodeworks.com/brian/tcell-widgets/helpers"
wh "git.bullercodeworks.com/brian/tcell-widgets/helpers"
"github.com/gdamore/tcell"
)
@@ -44,6 +44,8 @@ type BorderedWidget struct {
logger func(string)
}
var _ Widget = (*BorderedWidget)(nil)
func (w *BorderedWidget) SetLogger(l func(string)) { w.logger = l }
func (w *BorderedWidget) Log(txt string) {
if w.logger != nil {
@@ -63,7 +65,7 @@ func (w *BorderedWidget) Init(id string, s tcell.Style) {
w.id = id
w.style = s
w.visible = true
w.border = h.BRD_CSIMPLE
w.border = wh.BRD_CSIMPLE
w.tabbable = true
}
@@ -71,6 +73,9 @@ func (w *BorderedWidget) Id() string { return w.id }
func (w *BorderedWidget) HandleResize(ev *tcell.EventResize) {
// Trim space for border and pass the resize to the widget
w.w, w.h = ev.Size()
w.w = wh.Min(w.w, w.WantW())
w.h = wh.Min(w.h, w.WantH())
w.widget.HandleResize(tcell.NewEventResize(w.w-2, w.h-2))
}
@@ -87,9 +92,9 @@ func (w *BorderedWidget) Draw(screen tcell.Screen) {
return
}
if len(w.title) > 0 {
h.TitledBorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, w.title, w.border, w.style, screen)
wh.TitledBorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, w.title, w.border, w.style, screen)
} else {
h.BorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, w.border, w.style, screen)
wh.BorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, w.border, w.style, screen)
}
w.widget.SetPos(Coord{X: w.x + 1, Y: w.y + 1})
w.widget.DrawOffset(w.GetPos(), screen)