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

@@ -33,10 +33,11 @@ type Prompt struct {
id string
style tcell.Style
x, y int
w, h int
active bool
visible bool
x, y int
w, h int
active bool
visible bool
tabbable bool
title string
message *Text
@@ -62,6 +63,7 @@ func (w *Prompt) Init(id string, style tcell.Style) {
w.btnOk.SetLabel("Ok")
w.btnCancel = NewButton(fmt.Sprintf("%s-cancel", id), style)
w.btnCancel.SetLabel("Cancel")
w.tabbable = true
}
func (w *Prompt) Id() string { return w.id }
func (w *Prompt) HandleResize(ev *tcell.EventResize) {
@@ -91,21 +93,24 @@ func (w *Prompt) Draw(screen tcell.Screen) {
w.btnOk.Draw(screen)
w.btnCancel.Draw(screen)
}
func (w *Prompt) Active() bool { return w.active }
func (w *Prompt) SetActive(a bool) { w.active = a }
func (w *Prompt) Visible() bool { return w.visible }
func (w *Prompt) SetVisible(a bool) { w.visible = a }
func (w *Prompt) SetX(x int) { w.x = x }
func (w *Prompt) SetY(y int) { w.y = y }
func (w *Prompt) GetX() int { return w.x }
func (w *Prompt) GetY() int { return w.y }
func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Prompt) SetW(x int) { w.w = x }
func (w *Prompt) SetH(y int) { w.h = y }
func (w *Prompt) GetW() int { return w.w }
func (w *Prompt) GetH() int { return w.y }
func (w *Prompt) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Prompt) Focusable() bool { return true }
func (w *Prompt) Active() bool { return w.active }
func (w *Prompt) SetActive(a bool) { w.active = a }
func (w *Prompt) Visible() bool { return w.visible }
func (w *Prompt) SetVisible(a bool) { w.visible = a }
func (w *Prompt) SetX(x int) { w.x = x }
func (w *Prompt) SetY(y int) { w.y = y }
func (w *Prompt) GetX() int { return w.x }
func (w *Prompt) GetY() int { return w.y }
func (w *Prompt) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Prompt) SetW(x int) { w.w = x }
func (w *Prompt) SetH(y int) { w.h = y }
func (w *Prompt) GetW() int { return w.w }
func (w *Prompt) GetH() int { return w.y }
func (w *Prompt) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Prompt) Focusable() bool { return true }
func (w *Prompt) SetTabbable(b bool) { w.tabbable = b }
func (w *Prompt) Tabbable() bool { return w.tabbable }
func (w *Prompt) WantW() int {
return w.btnOk.WantW() + w.btnCancel.WantW() + 4
}
@@ -120,4 +125,12 @@ func (w *Prompt) SetMessage(msg string) {
w.message.SetText(msg)
}
func (w *Prompt) MinW() int {
return 2 + w.field.MinW() + w.btnOk.MinW() + w.btnCancel.MinW() + w.message.MinW()
}
func (w *Prompt) MinH() int {
return 2 + w.field.MinH() + w.btnOk.MinH() + w.message.MinH()
}
func (w *Prompt) SetOnOk(f func(string) bool) { w.onOk = f }