Much Work

- Definable KeyMaps
- Change 'Tabbable' to just use 'Focusable'
This commit is contained in:
2025-09-04 11:09:34 -05:00
parent c1db729bb3
commit f571b13a31
26 changed files with 881 additions and 615 deletions

View File

@@ -31,12 +31,12 @@ import (
// TODO: Fix this, it's not drawing correctly.
type TimeField struct {
id string
label string
style tcell.Style
active bool
visible bool
tabbable bool
id string
label string
style tcell.Style
active bool
visible bool
focusable bool
x, y int
w, h int
@@ -92,7 +92,7 @@ func (w *TimeField) Init(id string, style tcell.Style) {
tcell.KeyEnd: w.handleEnd,
})
w.visible = true
w.tabbable = true
w.focusable = true
}
func (w *TimeField) Id() string { return w.id }
@@ -138,6 +138,17 @@ func (w *TimeField) HandleResize(ev *tcell.EventResize) {
}
}
func (w *TimeField) SetKeyMap(km KeyMap) { w.keyMap = km }
func (w *TimeField) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *TimeField) RemoveFromKeyMap(km KeyMap) {
for k := range km.Keys {
w.keyMap.Remove(k)
}
for r := range km.Runes {
w.keyMap.RemoveRune(r)
}
}
func (w *TimeField) HandleKey(ev *tcell.EventKey) bool {
if !w.active {
return false
@@ -167,26 +178,25 @@ func (w *TimeField) Draw(screen tcell.Screen) {
}
}
func (w *TimeField) Active() bool { return w.active }
func (w *TimeField) SetActive(a bool) { w.active = a }
func (w *TimeField) Visible() bool { return w.visible }
func (w *TimeField) SetVisible(a bool) { w.visible = a }
func (w *TimeField) SetX(x int) { w.x = x }
func (w *TimeField) SetY(y int) { w.y = y }
func (w *TimeField) GetX() int { return w.x }
func (w *TimeField) GetY() int { return w.y }
func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *TimeField) SetW(x int) { w.w = x }
func (w *TimeField) SetH(y int) { w.h = y }
func (w *TimeField) GetW() int { return w.w }
func (w *TimeField) GetH() int { return w.y }
func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *TimeField) Focusable() bool { return true }
func (w *TimeField) SetTabbable(b bool) { w.tabbable = b }
func (w *TimeField) Tabbable() bool { return w.tabbable }
func (w *TimeField) WantW() int { return w.MinW() }
func (w *TimeField) WantH() int { return w.MinH() }
func (w *TimeField) Active() bool { return w.active }
func (w *TimeField) SetActive(a bool) { w.active = a }
func (w *TimeField) Visible() bool { return w.visible }
func (w *TimeField) SetVisible(a bool) { w.visible = a }
func (w *TimeField) SetX(x int) { w.x = x }
func (w *TimeField) SetY(y int) { w.y = y }
func (w *TimeField) GetX() int { return w.x }
func (w *TimeField) GetY() int { return w.y }
func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *TimeField) SetW(x int) { w.w = x }
func (w *TimeField) SetH(y int) { w.h = y }
func (w *TimeField) GetW() int { return w.w }
func (w *TimeField) GetH() int { return w.y }
func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *TimeField) Focusable() bool { return w.focusable }
func (w *TimeField) SetFocusable(b bool) { w.focusable = b }
func (w *TimeField) WantW() int { return w.MinW() }
func (w *TimeField) WantH() int { return w.MinH() }
func (w *TimeField) MinW() int {
wdt := 0
if w.fldYear.Visible() {