5 Commits
v0.1.0 ... main

Author SHA1 Message Date
62ef3b5d44 Add 'Has' to layout flags 2026-01-29 06:12:52 -06:00
16f7e7466a Bug Fix 2026-01-23 14:58:18 -06:00
b04cc91245 Check bounds of list 2026-01-23 14:56:00 -06:00
c821a8fa06 Style bugfix 2026-01-23 09:38:53 -06:00
c1296b1dc1 Add SetStyle Function 2026-01-23 09:36:43 -06:00
32 changed files with 446 additions and 396 deletions

View File

@@ -75,6 +75,7 @@ const (
LFSizeAll = LayoutFlag(0x11110000) LFSizeAll = LayoutFlag(0x11110000)
) )
func (f LayoutFlag) Has(fl LayoutFlag) bool { return f&fl != 0 }
func (f LayoutFlag) Add(fl LayoutFlag) { f |= fl } func (f LayoutFlag) Add(fl LayoutFlag) { f |= fl }
func (f LayoutFlag) Remove(fl LayoutFlag) { f = f &^ fl } func (f LayoutFlag) Remove(fl LayoutFlag) { f = f &^ fl }
func (f LayoutFlag) ClearAll() { func (f LayoutFlag) ClearAll() {

View File

@@ -139,6 +139,7 @@ func (w *AbsoluteLayout) Draw(screen tcell.Screen) {
} }
} }
func (w *AbsoluteLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *AbsoluteLayout) Active() bool { return w.active } func (w *AbsoluteLayout) Active() bool { return w.active }
func (w *AbsoluteLayout) SetActive(a bool) { w.active = a } func (w *AbsoluteLayout) SetActive(a bool) { w.active = a }
func (w *AbsoluteLayout) Visible() bool { return w.visible } func (w *AbsoluteLayout) Visible() bool { return w.visible }

View File

@@ -125,6 +125,7 @@ func (w *Alert) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.layout, screen) w.GetPos().DrawOffset(w.layout, screen)
} }
func (w *Alert) SetStyle(s tcell.Style) { w.style = s }
func (w *Alert) Active() bool { return w.active } func (w *Alert) Active() bool { return w.active }
func (w *Alert) SetActive(a bool) { w.active = a } func (w *Alert) SetActive(a bool) { w.active = a }
func (w *Alert) Visible() bool { return w.visible } func (w *Alert) Visible() bool { return w.visible }

View File

@@ -80,6 +80,7 @@ func (w *ArtWidget) Draw(screen tcell.Screen) {
w.buffer.Draw(w.x, w.y, screen) w.buffer.Draw(w.x, w.y, screen)
} }
func (w *ArtWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *ArtWidget) Active() bool { return w.active } func (w *ArtWidget) Active() bool { return w.active }
func (w *ArtWidget) SetActive(a bool) { w.active = a } func (w *ArtWidget) SetActive(a bool) { w.active = a }
func (w *ArtWidget) Visible() bool { return w.visible } func (w *ArtWidget) Visible() bool { return w.visible }

View File

@@ -51,6 +51,7 @@ func (w *BlankWidget) HandleKey(ev *tcell.EventKey) bool { return false }
func (w *BlankWidget) HandleTime(ev *tcell.EventTime) {} func (w *BlankWidget) HandleTime(ev *tcell.EventTime) {}
func (w *BlankWidget) Draw(screen tcell.Screen) {} func (w *BlankWidget) Draw(screen tcell.Screen) {}
func (w *BlankWidget) SetStyle(s tcell.Style) {}
func (w *BlankWidget) Active() bool { return false } func (w *BlankWidget) Active() bool { return false }
func (w *BlankWidget) SetActive(a bool) {} func (w *BlankWidget) SetActive(a bool) {}
func (w *BlankWidget) Visible() bool { return true } func (w *BlankWidget) Visible() bool { return true }

View File

@@ -91,6 +91,7 @@ func (w *BorderedWidget) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.widget, screen) w.GetPos().DrawOffset(w.widget, screen)
} }
func (w *BorderedWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *BorderedWidget) Active() bool { return w.widget.Active() } func (w *BorderedWidget) Active() bool { return w.widget.Active() }
func (w *BorderedWidget) SetActive(a bool) { w.widget.SetActive(a) } func (w *BorderedWidget) SetActive(a bool) { w.widget.SetActive(a) }
func (w *BorderedWidget) Visible() bool { return w.widget.Visible() } func (w *BorderedWidget) Visible() bool { return w.widget.Visible() }

View File

@@ -75,6 +75,8 @@ func (w *BufferWidget) HandleKey(ev *tcell.EventKey) bool {
} }
func (w *BufferWidget) HandleTime(ev *tcell.EventTime) { w.timeMap.Handle(ev) } func (w *BufferWidget) HandleTime(ev *tcell.EventTime) { w.timeMap.Handle(ev) }
func (w *BufferWidget) Draw(screen tcell.Screen) { w.buffer.Draw(w.x, w.y, screen) } func (w *BufferWidget) Draw(screen tcell.Screen) { w.buffer.Draw(w.x, w.y, screen) }
func (w *BufferWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *BufferWidget) Active() bool { return w.active } func (w *BufferWidget) Active() bool { return w.active }
func (w *BufferWidget) SetActive(a bool) { w.active = a } func (w *BufferWidget) SetActive(a bool) { w.active = a }
func (w *BufferWidget) Visible() bool { return w.visible } func (w *BufferWidget) Visible() bool { return w.visible }

View File

@@ -119,6 +119,7 @@ func (w *Button) Draw(screen tcell.Screen) {
wh.DrawText(w.x, w.y+2, fmt.Sprintf("╰%s╯", strings.Repeat("─", w.w-2)), dStyle, screen) wh.DrawText(w.x, w.y+2, fmt.Sprintf("╰%s╯", strings.Repeat("─", w.w-2)), dStyle, screen)
} }
func (w *Button) SetStyle(s tcell.Style) { w.style = s }
func (w *Button) Active() bool { return w.active } func (w *Button) Active() bool { return w.active }
func (w *Button) SetActive(a bool) { w.active = a } func (w *Button) SetActive(a bool) { w.active = a }
func (w *Button) Visible() bool { return w.visible } func (w *Button) Visible() bool { return w.visible }

View File

@@ -158,6 +158,7 @@ func (w *Chat) Draw(screen tcell.Screen) {
// x += len(post) - 1 // x += len(post) - 1
} }
func (w *Chat) SetStyle(s tcell.Style) { w.style = s }
func (w *Chat) Active() bool { return w.active } func (w *Chat) Active() bool { return w.active }
func (w *Chat) SetActive(a bool) { w.active = a } func (w *Chat) SetActive(a bool) { w.active = a }
func (w *Chat) Visible() bool { return w.visible } func (w *Chat) Visible() bool { return w.visible }

View File

@@ -92,6 +92,7 @@ func (w *Checkbox) Draw(screen tcell.Screen) {
wh.DrawText(w.x, w.y, fmt.Sprintf("[%s] %s", string(w.stateRunes[w.state]), w.label), dStyle, screen) wh.DrawText(w.x, w.y, fmt.Sprintf("[%s] %s", string(w.stateRunes[w.state]), w.label), dStyle, screen)
} }
func (w *Checkbox) SetStyle(s tcell.Style) { w.style = s }
func (w *Checkbox) Active() bool { return w.active } func (w *Checkbox) Active() bool { return w.active }
func (w *Checkbox) SetActive(a bool) { w.active = a } func (w *Checkbox) SetActive(a bool) { w.active = a }
func (w *Checkbox) Visible() bool { return w.visible } func (w *Checkbox) Visible() bool { return w.visible }

View File

@@ -172,6 +172,7 @@ func (w *Cli) Draw(screen tcell.Screen) {
wh.DrawText(x, y, wh.PadR(post, w.w-x-2), dStyle, screen) wh.DrawText(x, y, wh.PadR(post, w.w-x-2), dStyle, screen)
} }
func (w *Cli) SetStyle(s tcell.Style) { w.style = s }
func (w *Cli) Active() bool { return w.active } func (w *Cli) Active() bool { return w.active }
func (w *Cli) SetActive(a bool) { w.active = a } func (w *Cli) SetActive(a bool) { w.active = a }
func (w *Cli) Visible() bool { return w.visible } func (w *Cli) Visible() bool { return w.visible }

View File

@@ -129,6 +129,7 @@ func (w *DatePicker) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.dateNow, screen) w.GetPos().DrawOffset(w.dateNow, screen)
} }
func (w *DatePicker) SetStyle(s tcell.Style) { w.style = s }
func (w *DatePicker) Active() bool { return w.active } func (w *DatePicker) Active() bool { return w.active }
func (w *DatePicker) SetActive(a bool) { func (w *DatePicker) SetActive(a bool) {
if !w.active && a { if !w.active && a {

View File

@@ -165,6 +165,7 @@ func (w *DebugWidget) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.widget, screen) w.GetPos().DrawOffset(w.widget, screen)
} }
func (w *DebugWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *DebugWidget) Active() bool { return w.active } func (w *DebugWidget) Active() bool { return w.active }
func (w *DebugWidget) SetActive(a bool) { func (w *DebugWidget) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -155,6 +155,7 @@ func (w *Field) Draw(screen tcell.Screen) {
wh.DrawText(x, w.y, post, valueStyle, screen) wh.DrawText(x, w.y, post, valueStyle, screen)
} }
func (w *Field) SetStyle(s tcell.Style) { w.style = s }
func (w *Field) Active() bool { return w.active } func (w *Field) Active() bool { return w.active }
func (w *Field) SetActive(a bool) { w.active = a } func (w *Field) SetActive(a bool) { w.active = a }
func (w *Field) Visible() bool { return w.visible } func (w *Field) Visible() bool { return w.visible }

View File

@@ -121,6 +121,7 @@ func (w *FilePicker) Draw(screen tcell.Screen) {
p.DrawOffset(w.btnSelect, screen) p.DrawOffset(w.btnSelect, screen)
} }
func (w *FilePicker) SetStyle(s tcell.Style) { w.style = s }
func (w *FilePicker) Active() bool { return w.active } func (w *FilePicker) Active() bool { return w.active }
func (w *FilePicker) SetActive(a bool) { w.active = a } func (w *FilePicker) SetActive(a bool) { w.active = a }
func (w *FilePicker) Visible() bool { return w.visible } func (w *FilePicker) Visible() bool { return w.visible }

View File

@@ -146,6 +146,7 @@ func (w *Form) Draw(screen tcell.Screen) {
} }
} }
func (w *Form) SetStyle(s tcell.Style) { w.style = s }
func (w *Form) Active() bool { return w.active } func (w *Form) Active() bool { return w.active }
func (w *Form) SetActive(a bool) { func (w *Form) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -160,6 +160,7 @@ func (w *LinearLayout) Draw(screen tcell.Screen) {
} }
} }
func (w *LinearLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *LinearLayout) Active() bool { return w.active } func (w *LinearLayout) Active() bool { return w.active }
func (w *LinearLayout) SetActive(a bool) { func (w *LinearLayout) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -224,6 +224,8 @@ func (w *Menu) drawVMenu(screen tcell.Screen) {
y++ y++
} }
} }
func (w *Menu) SetStyle(s tcell.Style) { w.style = s }
func (w *Menu) Active() bool { return w.active } func (w *Menu) Active() bool { return w.active }
func (w *Menu) SetActive(a bool) { w.active = a } func (w *Menu) SetActive(a bool) { w.active = a }
func (w *Menu) Visible() bool { return w.visible } func (w *Menu) Visible() bool { return w.visible }

View File

@@ -197,6 +197,7 @@ func (w *MenuItem) Draw(screen tcell.Screen) {
} }
} }
func (w *MenuItem) SetStyle(s tcell.Style) { w.style = s }
func (w *MenuItem) Active() bool { return w.active } func (w *MenuItem) Active() bool { return w.active }
func (w *MenuItem) SetActive(a bool) { func (w *MenuItem) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -114,6 +114,7 @@ func (w *Prompt) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.btnCancel, screen) w.GetPos().DrawOffset(w.btnCancel, screen)
} }
func (w *Prompt) SetStyle(s tcell.Style) { w.style = s }
func (w *Prompt) Active() bool { return w.active } func (w *Prompt) Active() bool { return w.active }
func (w *Prompt) SetActive(a bool) { w.active = a } func (w *Prompt) SetActive(a bool) { w.active = a }
func (w *Prompt) Visible() bool { return w.visible } func (w *Prompt) Visible() bool { return w.visible }

View File

@@ -112,6 +112,7 @@ func (w *RelativeLayout) Draw(screen tcell.Screen) {
*/ */
} }
func (w *RelativeLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *RelativeLayout) Active() bool { return w.active } func (w *RelativeLayout) Active() bool { return w.active }
func (w *RelativeLayout) SetActive(a bool) { w.active = a } func (w *RelativeLayout) SetActive(a bool) { w.active = a }
func (w *RelativeLayout) Visible() bool { return w.visible } func (w *RelativeLayout) Visible() bool { return w.visible }

View File

@@ -257,6 +257,7 @@ func (w *Searcher) buildBuffer() {
w.buffer = b w.buffer = b
} }
func (w *Searcher) SetStyle(s tcell.Style) { w.style = s }
func (w *Searcher) Active() bool { return w.active } func (w *Searcher) Active() bool { return w.active }
func (w *Searcher) SetActive(a bool) { func (w *Searcher) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -46,6 +46,7 @@ func (w *ShrinkWrap) HandleKey(ev *tcell.EventKey) bool { return w.widget.Handle
func (w *ShrinkWrap) HandleTime(ev *tcell.EventTime) { w.widget.HandleTime(ev) } func (w *ShrinkWrap) HandleTime(ev *tcell.EventTime) { w.widget.HandleTime(ev) }
func (w *ShrinkWrap) Draw(screen tcell.Screen) { w.widget.Draw(screen) } func (w *ShrinkWrap) Draw(screen tcell.Screen) { w.widget.Draw(screen) }
func (w *ShrinkWrap) SetStyle(s tcell.Style) { w.widget.SetStyle(s) }
func (w *ShrinkWrap) Active() bool { return w.widget.Active() } func (w *ShrinkWrap) Active() bool { return w.widget.Active() }
func (w *ShrinkWrap) SetActive(a bool) { w.widget.SetActive(a) } func (w *ShrinkWrap) SetActive(a bool) { w.widget.SetActive(a) }
func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() } func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() }

View File

@@ -185,6 +185,7 @@ func (w *SimpleList) Draw(screen tcell.Screen) {
} }
} }
func (w *SimpleList) SetStyle(s tcell.Style) { w.style = s }
func (w *SimpleList) Active() bool { return w.active } func (w *SimpleList) Active() bool { return w.active }
func (w *SimpleList) SetActive(a bool) { w.active = a } func (w *SimpleList) SetActive(a bool) { w.active = a }
func (w *SimpleList) Visible() bool { return w.visible } func (w *SimpleList) Visible() bool { return w.visible }
@@ -226,6 +227,12 @@ func (w *SimpleList) MinW() int {
func (w *SimpleList) MinH() int { return 4 } func (w *SimpleList) MinH() int { return 4 }
func (w *SimpleList) getItemAt(idx int) {
for idx >= len(w.list) {
idx--
}
}
func (w *SimpleList) SetCursorWrap(b bool) { w.cursorWrap = b } func (w *SimpleList) SetCursorWrap(b bool) { w.cursorWrap = b }
func (w *SimpleList) MoveUp() bool { func (w *SimpleList) MoveUp() bool {
if w.cursor > 0 { if w.cursor > 0 {
@@ -327,7 +334,12 @@ func (w *SimpleList) SetItem(idx int, txt string) {
w.list[idx] = txt w.list[idx] = txt
} }
} }
func (w *SimpleList) SelectedIndex() int { return w.cursor } func (w *SimpleList) SelectedIndex() int {
if w.cursor >= len(w.list) {
w.cursor = len(w.list) - 1
}
return w.cursor
}
func (w *SimpleList) SetSelectedIndex(i int) { func (w *SimpleList) SetSelectedIndex(i int) {
if i < 0 { if i < 0 {
i = 0 i = 0
@@ -349,6 +361,11 @@ func (w *SimpleList) Log(txt string, args ...any) {
func (w *SimpleList) SetOnChange(c func(int, string) bool) { w.onChange = c } func (w *SimpleList) SetOnChange(c func(int, string) bool) { w.onChange = c }
func (w *SimpleList) GetSelectedItem() string { return w.list[w.cursor] } func (w *SimpleList) GetSelectedItem() string {
if w.cursor >= len(w.list) {
w.cursor = len(w.list) - 1
}
return w.list[w.cursor]
}
func (w *SimpleList) GetAllItems() []string { return w.list } func (w *SimpleList) GetAllItems() []string { return w.list }
func (w *SimpleList) GetAllItemStyles() map[int]tcell.Style { return w.itemsStyle } func (w *SimpleList) GetAllItemStyles() map[int]tcell.Style { return w.itemsStyle }

View File

@@ -84,6 +84,7 @@ func (w *SimpleListWithHelp) Draw(screen tcell.Screen) {
w.GetPos().DrawOffset(w.help, screen) w.GetPos().DrawOffset(w.help, screen)
} }
func (w *SimpleListWithHelp) SetStyle(s tcell.Style) { w.style = s }
func (w *SimpleListWithHelp) Active() bool { return w.list.Active() } func (w *SimpleListWithHelp) Active() bool { return w.list.Active() }
func (w *SimpleListWithHelp) SetActive(a bool) { func (w *SimpleListWithHelp) SetActive(a bool) {
w.list.SetActive(a) w.list.SetActive(a)

View File

@@ -78,6 +78,7 @@ func (w *Spinner) Draw(screen tcell.Screen) {
screen.SetContent(w.x, w.y, w.frames[w.currentFrame], nil, w.style) screen.SetContent(w.x, w.y, w.frames[w.currentFrame], nil, w.style)
} }
func (w *Spinner) SetStyle(s tcell.Style) { w.style = s }
func (w *Spinner) Active() bool { return false } func (w *Spinner) Active() bool { return false }
func (w *Spinner) SetActive(a bool) {} func (w *Spinner) SetActive(a bool) {}
func (w *Spinner) Visible() bool { return w.visible } func (w *Spinner) Visible() bool { return w.visible }

View File

@@ -153,6 +153,7 @@ func (w *ScrollingWidgetList) Draw(screen tcell.Screen) {
} }
} }
func (w *ScrollingWidgetList) SetStyle(s tcell.Style) { w.style = s }
func (w *ScrollingWidgetList) Active() bool { return w.active } func (w *ScrollingWidgetList) Active() bool { return w.active }
func (w *ScrollingWidgetList) SetActive(a bool) { func (w *ScrollingWidgetList) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -149,6 +149,7 @@ func (w *Table) Draw(screen tcell.Screen) {
} }
} }
func (w *Table) SetStyle(s tcell.Style) { w.style = s }
func (w *Table) Active() bool { return w.active } func (w *Table) Active() bool { return w.active }
func (w *Table) SetActive(a bool) { w.active = a } func (w *Table) SetActive(a bool) { w.active = a }
func (w *Table) Visible() bool { return w.visible } func (w *Table) Visible() bool { return w.visible }

View File

@@ -82,6 +82,7 @@ func (w *Text) Draw(screen tcell.Screen) {
} }
} }
func (w *Text) SetStyle(s tcell.Style) { w.style = s }
func (w *Text) Active() bool { return w.active } func (w *Text) Active() bool { return w.active }
func (w *Text) SetActive(a bool) { w.active = a } func (w *Text) SetActive(a bool) { w.active = a }
func (w *Text) Visible() bool { return w.visible } func (w *Text) Visible() bool { return w.visible }

View File

@@ -181,6 +181,7 @@ func (w *TimeField) Draw(screen tcell.Screen) {
} }
} }
func (w *TimeField) SetStyle(s tcell.Style) { w.style = s }
func (w *TimeField) Active() bool { return w.active } func (w *TimeField) Active() bool { return w.active }
func (w *TimeField) SetActive(a bool) { w.active = a } func (w *TimeField) SetActive(a bool) { w.active = a }
func (w *TimeField) Visible() bool { return w.visible } func (w *TimeField) Visible() bool { return w.visible }

View File

@@ -158,6 +158,7 @@ func (w *TopMenuLayout) Draw(screen tcell.Screen) {
} }
} }
func (w *TopMenuLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *TopMenuLayout) Active() bool { return w.active } func (w *TopMenuLayout) Active() bool { return w.active }
func (w *TopMenuLayout) SetActive(a bool) { func (w *TopMenuLayout) SetActive(a bool) {
w.active = a w.active = a

View File

@@ -38,6 +38,7 @@ type Widget interface {
SetKeyMap(km *KeyMap) SetKeyMap(km *KeyMap)
Draw(tcell.Screen) Draw(tcell.Screen)
SetStyle(tcell.Style)
Active() bool Active() bool
SetActive(bool) SetActive(bool)
Visible() bool Visible() bool