lineeditor/core/event.rs
1/// Editing actions which can be mapped to key bindings.
2///
3/// Executed by `Editor::run_edit_commands()`
4#[derive(Clone)]
5pub enum EditCommand {
6 /// Insert a character at the current insertion point
7 InsertChar(char),
8
9 /// Insert a string at the current insertion point
10 InsertString(String),
11
12 /// Backspace delete from the current insertion point
13 DeleteLeftChar,
14
15 /// Delete in-place from the current insertion point
16 DeleteRightChar,
17
18 /// Delete in-place range
19 DeleteSpan(usize, usize),
20
21 /// Clear the current buffer
22 Clear,
23}
24
25/// Movements actions which can be mapped to key bindings.
26#[derive(Clone)]
27pub enum MovementCommand {
28 /// Move to the start of the buffer
29 MoveToStart,
30
31 /// Move to the end of the buffer
32 MoveToEnd,
33
34 /// Move one character to the left
35 MoveLeftChar,
36
37 /// Move one character to the right
38 MoveRightChar,
39
40 /// Move one word to the left
41 MoveLeftWord,
42
43 /// Move one word to the right
44 MoveRightWord,
45
46 /// Move to position
47 MoveToPosition(usize),
48}
49
50/// LineEditor supported actions.
51#[derive(Clone)]
52pub enum LineEditorEvent {
53 /// No op event
54 None,
55
56 /// Handle enter event
57 Enter,
58
59 /// Esc event
60 Esc,
61
62 /// Handle unconditional submit event
63 Submit,
64
65 /// Run these commands in the editor
66 Edit(Vec<EditCommand>),
67
68 /// Run movements commands in the editor
69 Movement(Vec<MovementCommand>),
70
71 /// Move up to the previous line, if multiline, or up into the historic buffers
72 Up,
73
74 /// Move down to the next line, if multiline, or down through the historic buffers
75 Down,
76
77 /// Move right to the next column, completion entry, or complete hint
78 Right,
79
80 /// Move left to the next column, or completion entry
81 Left,
82
83 /// Select one character to the right
84 SelectRight,
85
86 /// Select one character to the left
87 SelectLeft,
88
89 /// Select all buffer
90 SelectAll,
91
92 /// Cut the selected text into clipboard
93 CutSelected,
94
95 /// Copy the selected text into clipboard
96 CopySelected,
97
98 /// Paste text from clipboard into selection or at insertion point
99 Paste,
100
101 /// Delete char from the left or delete selected range
102 Backspace,
103
104 /// Delete char from the right or delete selected range
105 Delete,
106
107 /// Show or Hide Auto Complete view depend on the state
108 ToggleAutoComplete,
109}