3 Commits
v0.2.1 ... 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
2 changed files with 21 additions and 4 deletions

View File

@@ -75,6 +75,7 @@ const (
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) Remove(fl LayoutFlag) { f = f &^ fl }
func (f LayoutFlag) ClearAll() {

View File

@@ -227,6 +227,12 @@ func (w *SimpleList) MinW() int {
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) MoveUp() bool {
if w.cursor > 0 {
@@ -328,7 +334,12 @@ func (w *SimpleList) SetItem(idx int, txt string) {
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) {
if i < 0 {
i = 0
@@ -350,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) 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) GetAllItemStyles() map[int]tcell.Style { return w.itemsStyle }