forked from TrenchBoot/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
51 lines (39 loc) · 1.53 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
package tty
import "github.com/u-root/u-root/cmds/core/elvish/edit/ui"
// Event represents an event that can be read from the terminal.
type Event interface {
isEvent()
}
// KeyEvent represents a key press.
type KeyEvent ui.Key
// MouseEvent represents a mouse event (either pressing or releasing).
type MouseEvent struct {
Pos
Down bool
// Number of the Button, 0-based. -1 for unknown.
Button int
Mod ui.Mod
}
// RawRune represents a rune read in raw mode.
type RawRune rune
// CursorPosition represents a report of the current cursor position from the
// terminal driver, usually as a response from a cursor position request.
type CursorPosition Pos
// PasteSetting indicates the start or finish of pasted text.
type PasteSetting bool
// FatalErrorEvent represents an error that affects the Reader's ability to
// continue reading events. After sending a FatalError, the Reader makes no more
// attempts at continuing to read events and wait for Stop to be called.
type FatalErrorEvent struct{ Err error }
// NonfatalErrorEvent represents an error that can be gradually recovered. After
// sending a NonfatalError, the Reader will continue to read events. Note that
// one anamoly in the terminal might cause multiple NonfatalError events to be
// sent.
type NonfatalErrorEvent struct{ Err error }
func (KeyEvent) isEvent() {}
func (MouseEvent) isEvent() {}
func (RawRune) isEvent() {}
func (CursorPosition) isEvent() {}
func (PasteSetting) isEvent() {}
func (FatalErrorEvent) isEvent() {}
func (NonfatalErrorEvent) isEvent() {}