Scoop API

scoop:scoop.terminal:0.1.0

src/event/event.scoop

Selected production source · src/event/event.scoop

1package scoop.terminal.event
3/**
4 * A user-facing keyboard, mouse, focus, bracketed-paste, or terminal-resize event.
5 */
6public enum Event {
7 /**
8 * A decoded key event with modifiers, event kind, and additional state.
9 */
10 Key(val event: KeyEvent),
11 /**
12 * A decoded mouse event with position and modifiers.
13 */
14 Mouse(val event: MouseEvent),
15 /**
16 * The terminal reported gaining focus.
17 */
18 FocusGained,
19 /**
20 * The terminal reported losing focus.
21 */
22 FocusLost,
23 /**
24 * Text received between bracketed-paste boundaries.
25 */
26 Paste(val text: String),
27 /**
28 * New terminal dimensions in character columns and rows.
29 */
30 Resize(val columns: Long, val rows: Long)
33/**
34 * The mouse button associated with a button or drag event.
35 */
36public enum MouseButton {
37 /**
38 * The left mouse button.
39 */
40 Left,
41 /**
42 * The right mouse button.
43 */
44 Right,
45 /**
46 * The middle mouse button.
47 */
48 Middle }
50/**
51 * Button transitions, drag/motion, and wheel directions reported by the terminal mouse protocol.
52 */
53public enum MouseEventKind {
54 /**
55 * A button was pressed.
56 */
57 Down(val button: MouseButton),
58 /**
59 * A button was released.
60 */
61 Up(val button: MouseButton),
62 /**
63 * The pointer moved while the specified button was held.
64 */
65 Drag(val button: MouseButton),
66 /**
67 * The pointer moved with no reported drag.
68 */
69 Moved,
70 /**
71 * The wheel scrolled upward.
72 */
73 ScrollUp,
74 /**
75 * The wheel scrolled downward.
76 */
77 ScrollDown,
78 /**
79 * The wheel scrolled left.
80 */
81 ScrollLeft,
82 /**
83 * The wheel scrolled right.
84 */
85 ScrollRight
88/**
89 * A mouse event with zero-based cell coordinates and active key modifiers.
90 */
91public struct MouseEvent(
92 val kind: MouseEventKind, val column: Long, val row: Long,
93 val modifiers: KeyModifiers = KeyModifiers()
96/**
97 * Reports malformed terminal input that cannot be delivered as an ordinary event.
98 */
99public class TerminalInputException public constructor(
100 /**
101 * The malformed-input explanation.
102 */
103 public val detail: String) : Exception(Some(detail))