File: event.go

package info (click to toggle)
elvish 0.21.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,372 kB
  • sloc: javascript: 236; sh: 130; python: 104; makefile: 88; xml: 9
file content (54 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download | duplicates (2)
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
package term

import (
	"src.elv.sh/pkg/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

// K constructs a new KeyEvent.
func K(r rune, mods ...ui.Mod) KeyEvent {
	return KeyEvent(ui.K(r, mods...))
}

// 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
}

// 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 (CursorPosition) isEvent() {}
func (PasteSetting) isEvent()   {}

func (FatalErrorEvent) isEvent()    {}
func (NonfatalErrorEvent) isEvent() {}