Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62ef3b5d44 | |||
| 16f7e7466a | |||
| b04cc91245 |
@@ -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() {
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user