forked from ncruces/zenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_unix.go
48 lines (42 loc) · 1.38 KB
/
list_unix.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
//go:build !windows && !darwin
package zenity
import "github.com/ncruces/zenity/internal/zenutil"
func list(text string, items []string, opts options) (string, error) {
args := []string{"--list", "--hide-header", "--text", text}
args = appendGeneral(args, opts)
args = appendButtons(args, opts)
args = appendWidthHeight(args, opts)
args = appendWindowIcon(args, opts)
if opts.listKind == radioListKind {
args = append(args, "--radiolist", "--column=", "--column=")
for _, i := range items {
args = append(args, "", i)
}
} else {
args = append(args, "--column=")
args = append(args, items...)
}
if opts.midSearch {
args = append(args, "--mid-search")
}
out, err := zenutil.Run(opts.ctx, args)
return strResult(opts, out, err)
}
func listMultiple(text string, items []string, opts options) ([]string, error) {
args := []string{"--list", "--hide-header", "--text", text, "--multiple", "--separator", zenutil.Separator}
args = appendGeneral(args, opts)
args = appendButtons(args, opts)
args = appendWidthHeight(args, opts)
args = appendWindowIcon(args, opts)
if opts.listKind == checkListKind {
args = append(args, "--checklist", "--column=", "--column=")
for _, i := range items {
args = append(args, "", i)
}
} else {
args = append(args, "--column=")
args = append(args, items...)
}
out, err := zenutil.Run(opts.ctx, args)
return lstResult(opts, out, err)
}