forked from atsaki/termeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.go
49 lines (39 loc) · 821 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package termeter
import "gopkg.in/gizak/termui.v1"
type ListWidget struct {
List *termui.List
}
func NewListWidget() *ListWidget {
return &ListWidget{
List: termui.NewList(),
}
}
func (ls *ListWidget) SetX(x int) {
ls.List.X = x
}
func (ls *ListWidget) SetY(y int) {
ls.List.Y = y
}
func (ls *ListWidget) SetWidth(w int) {
ls.List.Width = w
}
func (ls *ListWidget) SetHeight(h int) {
ls.List.Height = h
}
func (ls *ListWidget) Buffer() []termui.Point {
defer func() {
recover()
}()
return ls.List.Buffer()
}
func (ls *ListWidget) Add(items ...string) {
for _, s := range items {
ls.List.Items = append(ls.List.Items, s)
}
}
func (ls *ListWidget) Update(items []string) {
ls.List.Items = make([]string, 0, len(items))
for _, s := range items {
ls.List.Items = append(ls.List.Items, s)
}
}