Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b04cc91245 | |||
| c821a8fa06 |
@@ -51,7 +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) { w.style = s }
|
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 }
|
||||||
|
|||||||
@@ -46,7 +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.style = s }
|
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() }
|
||||||
|
|||||||
@@ -227,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 {
|
||||||
@@ -328,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
|
||||||
@@ -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) 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 }
|
||||||
|
|||||||
Reference in New Issue
Block a user