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

@@ -36,7 +36,6 @@ type Table struct {
active bool
visible bool
focusable bool
tabbable bool
header []string
footer []string
@@ -52,6 +51,8 @@ type Table struct {
w, h int
columnWidths []int
keyMap KeyMap
}
var _ Widget = (*Table)(nil)
@@ -82,21 +83,30 @@ func (w *Table) Init(id string, style tcell.Style) {
w.style = style
w.visible = true
w.border = wh.BRD_CSIMPLE
w.tabbable = true
w.focusable = true
w.keyMap = BlankKeyMap()
}
func (w *Table) Id() string { return w.id }
func (w *Table) HandleResize(ev *tcell.EventResize) {
w.w, w.h = ev.Size()
}
// w.w = wh.Min(w.w, w.WantW())
// w.h = wh.Min(w.h, w.WantH())
func (w *Table) SetKeyMap(km KeyMap) { w.keyMap = km }
func (w *Table) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *Table) RemoveFromKeyMap(km KeyMap) {
for k := range km.Keys {
w.keyMap.Remove(k)
}
for r := range km.Runes {
w.keyMap.RemoveRune(r)
}
}
func (w *Table) HandleKey(ev *tcell.EventKey) bool {
if !w.active {
return false
}
return false
return w.keyMap.Handle(ev)
}
func (w *Table) HandleTime(ev *tcell.EventTime) {}
func (w *Table) Draw(screen tcell.Screen) {
@@ -252,13 +262,11 @@ func (w *Table) MinH() int {
return datLen
}
func (w *Table) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Table) Focusable() bool { return w.focusable }
func (w *Table) SetTabbable(b bool) { w.tabbable = b }
func (w *Table) Tabbable() bool { return w.tabbable }
func (w *Table) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Table) Focusable() bool { return w.focusable }
func (w *Table) SetFocusable(b bool) { w.focusable = b }
func (w *Table) SetTitle(ttl string) { w.title = ttl }
func (w *Table) SetFocusable(f bool) { w.focusable = f }
func (w *Table) SetBorder(b []rune) { w.border = b }
func (w *Table) AddRow(row []string) { w.data = append(w.data, row) }