-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
list.go
69 lines (58 loc) · 2.23 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package zenity
// List displays the list dialog.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// WindowIcon, Attach, Modal, RadioList, DefaultItems, DisallowEmpty.
//
// May return: ErrCanceled, ErrExtraButton, ErrUnsupported.
func List(text string, items []string, options ...Option) (string, error) {
return list(text, items, applyOptions(options))
}
// ListItems displays the list dialog.
//
// May return: ErrCanceled, ErrUnsupported.
func ListItems(text string, items ...string) (string, error) {
return List(text, items)
}
// ListMultiple displays the list dialog, allowing multiple items to be selected.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// WindowIcon, Attach, Modal, CheckList, DefaultItems, DisallowEmpty.
//
// May return: ErrCanceled, ErrExtraButton, ErrUnsupported.
func ListMultiple(text string, items []string, options ...Option) ([]string, error) {
return listMultiple(text, items, applyOptions(options))
}
// ListMultipleItems displays the list dialog, allowing multiple items to be selected.
//
// May return: ErrCanceled, ErrUnsupported.
func ListMultipleItems(text string, items ...string) ([]string, error) {
return ListMultiple(text, items, CheckList())
}
// CheckList returns an Option to show check boxes (Unix only).
func CheckList() Option {
return funcOption(func(o *options) { o.listKind = checkListKind })
}
// RadioList returns an Option to show radio boxes (Unix only).
func RadioList() Option {
return funcOption(func(o *options) { o.listKind = radioListKind })
}
type listKind int
const (
basicListKind listKind = iota
checkListKind
radioListKind
)
// MidSearch returns an Option to change list search to find text in the middle,
// not on the beginning (Unix only).
func MidSearch() Option {
return funcOption(func(o *options) { o.midSearch = true })
}
// DefaultItems returns an Option to set the items to initially select (Windows and macOS only).
func DefaultItems(items ...string) Option {
return funcOption(func(o *options) { o.defaultItems = items })
}
// DisallowEmpty returns an Option to not allow zero items to be selected (Windows and macOS only).
func DisallowEmpty() Option {
return funcOption(func(o *options) { o.disallowEmpty = true })
}