forked from ncruces/zenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg.go
60 lines (52 loc) · 1.69 KB
/
msg.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
package zenity
// Question displays the question dialog.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// Icon, WindowIcon, Attach, Modal, NoWrap, Ellipsize, DefaultCancel.
//
// May return: ErrCanceled, ErrExtraButton.
func Question(text string, options ...Option) error {
return message(questionKind, text, applyOptions(options))
}
// Info displays the info dialog.
//
// Valid options: Title, Width, Height, OKLabel, ExtraButton,
// Icon, WindowIcon, Attach, Modal, NoWrap, Ellipsize.
//
// May return: ErrCanceled, ErrExtraButton.
func Info(text string, options ...Option) error {
return message(infoKind, text, applyOptions(options))
}
// Warning displays the warning dialog.
//
// Valid options: Title, Width, Height, OKLabel, ExtraButton,
// Icon, WindowIcon, Attach, Modal, NoWrap, Ellipsize.
//
// May return: ErrCanceled, ErrExtraButton.
func Warning(text string, options ...Option) error {
return message(warningKind, text, applyOptions(options))
}
// Error displays the error dialog.
//
// Valid options: Title, Width, Height, OKLabel, ExtraButton,
// Icon, WindowIcon, Attach, Modal, NoWrap, Ellipsize.
//
// May return: ErrCanceled, ErrExtraButton.
func Error(text string, options ...Option) error {
return message(errorKind, text, applyOptions(options))
}
type messageKind int
const (
questionKind messageKind = iota
infoKind
warningKind
errorKind
)
// NoWrap returns an Option to disable text wrapping (Unix only).
func NoWrap() Option {
return funcOption(func(o *options) { o.noWrap = true })
}
// Ellipsize returns an Option to enable ellipsizing in the dialog text (Unix only).
func Ellipsize() Option {
return funcOption(func(o *options) { o.ellipsize = true })
}