/
event.go
62 lines (53 loc) · 1.04 KB
/
event.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
package windigo
import termbox "github.com/nsf/termbox-go"
type ResultType struct {
Rc RetCode
Err error
Type PayloadType
Val []int
Sval []string
Cval chan *termbox.Event
Tbox *termbox.Event
}
type ArgType struct {
Type PayloadType
Val []int
Sval []string
Cval chan *termbox.Event
Tbox *termbox.Event
}
type Event struct {
EventType WindigoEventType
Args *ArgType
Result *ResultType
}
type WindigoEventType int
const (
WindEventNone WindigoEventType = iota
WindEventInit
WindEventExit
WindEventError
WindEventRestart
WindEventOutput
WindEventMove
WindEventResize
nWindigoEvents
)
type PayloadType int
const (
// StateFuncs always return a *Event with an Rc
// set to inform the state machine.
Int PayloadType = iota
// passthru means that Result.Tbox is a valid termbox input
// event and is being passed thru as the result of the widget.
String
Channel
PassThru
None
)
func NewEvent(et WindigoEventType, args ...interface{}) *Event {
e := new(Event)
e.Result = new(ResultType)
e.EventType = et
return e
}