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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
use serde::{Deserialize, Serialize};
/// Valid ways how [`Reedline::read_line()`] can return
#[derive(Debug)]
pub enum Signal {
/// Entry succeeded with the provided content
Success(String),
/// Entry was aborted with `Ctrl+C`
CtrlC, // Interrupt current editing
/// Abort with `Ctrl+D` signalling `EOF` or abort of a whole interactive session
CtrlD, // End terminal session
/// Signal to clear the current screen. Buffer content remains untouched.
CtrlL, // FormFeed/Clear current screen
}
/// Editing actions which can be mapped to key bindings.
///
/// Executed by `Reedline::run_edit_commands()`
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum EditCommand {
/// Move to the start of the buffer
MoveToStart,
/// Move to the end of the buffer
MoveToEnd,
/// Move one character to the left
MoveLeft,
/// Move one character to the right
MoveRight,
/// Move one word to the left
MoveWordLeft,
/// Move one word to the right
MoveWordRight,
/// Insert a character at the current insertion point
InsertChar(char),
/// Backspace delete from the current insertion point
Backspace,
/// Delete in-place from the current insertion point
Delete,
/// Backspace delete a word from the current insertion point
BackspaceWord,
/// Delete in-place a word from the current insertion point
DeleteWord,
/// Clear the current buffer
Clear,
/// Cut from the start of the buffer to the insertion point
CutFromStart,
/// Cut from the insertion point to the end of the buffer
CutToEnd,
/// Cut the word left of the insertion point
CutWordLeft,
/// Cut the word right of the insertion point
CutWordRight,
/// Paste the cut buffer at the insertion point
PasteCutBuffer,
/// Upper case the current word
UppercaseWord,
/// Lower case the current word
LowercaseWord,
/// Capitalize the current character
CapitalizeChar,
/// Swap the current word with the word to the right
SwapWords,
/// Swap the current grapheme/character with the one to the right
SwapGraphemes,
/// Undo the previous edit command
Undo,
/// Redo an edit command from the undo history
Redo,
}
/// Reedline supported actions.
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub enum ReedlineEvent {
/// No op event
None,
/// Trigger Tab
HandleTab,
/// Don't know a better name for this
CtrlD,
/// Don't know a better name for this
CtrlC,
/// Clears the screen and sets prompt to first line
ClearScreen,
/// Handle enter event
Enter,
/// Mouse
Mouse, // Fill in details later
/// trigger termimal resize
Resize(u16, u16),
/// Run these commands in the editor
Edit(Vec<EditCommand>),
/// Trigger full repaint
Repaint,
/// Navigate to the previous historic buffer
PreviousHistory,
/// Move up to the previous line, if multiline, or up into the historic buffers
Up,
/// Move down to the next line, if multiline, or down through the historic buffers
Down,
/// Navigate to the next historic buffer
NextHistory,
/// Search the history for a string
SearchHistory,
}