tui/event/intent.rs
1//! The vocabulary of key intents applied to the app.
2
3use super::{BuilderKey, ScriptKey, TemplateKey};
4use crate::tabs::reports::ReportKind;
5use crate::view::Tab;
6use crate::window::WindowId;
7use tvui::Change;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum Intent {
11 /// Ask before leaving the application.
12 Quit,
13 /// Leave the application at once.
14 QuitNow,
15 /// Close the front window, or ask before leaving when none is open.
16 CloseOrQuit,
17 /// Bring the rearmost window to the front.
18 NextWindow,
19 /// Send the front window to the back.
20 PrevWindow,
21 /// Zoom the front window to the desktop, or restore it.
22 ToggleZoom,
23 /// Start moving or sizing the front window from the keyboard.
24 SizeWindow,
25 /// A step of moving or sizing the window.
26 Drag(Change),
27 /// Keep the window as moved or sized.
28 DragDone,
29 /// Put the window back as it was before the move or size.
30 DragCancel,
31 /// Lay every window out side by side over the desktop.
32 Tile,
33 /// Stack every window from the desktop corner, each one step further in.
34 Cascade,
35 NextField,
36 PrevField,
37 /// Create a row in the active tab: an account's transaction, a config key, an SSH key, a tag, a template or a script.
38 NewRow,
39 /// Delete the selected row of the active tab.
40 DeleteRow,
41 SelectTab(Tab),
42 /// Open a new window of a view.
43 NewWindow(Tab),
44 /// Raise the window with this TV number.
45 SelectWindow(u8),
46 /// Raise this window; the entries of the Window list.
47 RaiseWindow(WindowId),
48 OpenCommandLine,
49 CloseTopmost,
50 /// Close the front window.
51 CloseWindow,
52 /// Close every window.
53 CloseAll,
54 Submit,
55 /// Enter on a form: presses the focused button, else submits.
56 Press,
57 /// Confirm the topmost confirm overlay (equivalent to pressing `y`).
58 ConfirmYes,
59 /// Enter on a confirm overlay: confirms, but the discard prompt cancels.
60 InsertChar(char),
61 DeleteBackward,
62 MoveLeft,
63 MoveRight,
64 MoveHome,
65 MoveEnd,
66 MoveUp,
67 MoveDown,
68 InsertNewline,
69 KillToEnd,
70 KillWordBackward,
71 MoveWordForward,
72 MoveWordBackward,
73 DeleteForward,
74 DeleteWordForward,
75 /// Leave typing for the command line's normal mode.
76 EnterNormalMode,
77 InsertAtCursor,
78 InsertAfterCursor,
79 InsertAtLineStart,
80 InsertAtLineEnd,
81 OpenHelp,
82 OpenMenu,
83 CloseMenu,
84 MenuNext,
85 MenuPrev,
86 MenuFirst,
87 MenuLast,
88 MenuLeft,
89 MenuRight,
90 MenuSelect,
91 ConsoleFocus,
92 ConsoleBlur,
93 ConsoleSubmit,
94 ConsoleInterrupt,
95 ConsoleHistoryPrev,
96 ConsoleHistoryNext,
97 ConsoleCyclePane,
98 ScrollLineUp,
99 ScrollLineDown,
100 ScrollPageUp,
101 ScrollPageDown,
102 ScrollTop,
103 ScrollEnd,
104 ListSelectNext,
105 ListSelectPrev,
106 ListSelectFirst,
107 ListSelectLast,
108 /// Select the row at this index among the rows the view holds (a click).
109 ListSelectRow(usize),
110 ListViewDown,
111 ListViewUp,
112 ListPageNext,
113 ListPagePrev,
114 /// Open the Transactions filter form.
115 ListFilter,
116 /// Drop the Transactions filter.
117 ListFilterClear,
118 ListMark,
119 ListUnmarkAll,
120 ListDeleteMarked,
121 /// Open the edit form of the selected row of the active tab.
122 EditRow,
123 /// Open the read-only detail of the selected transaction.
124 ListDetail,
125 /// Edit the transaction shown in the detail window.
126 DetailEdit,
127 /// Open account-merge with From set to the selected account.
128 ListMergeAccount,
129 /// Open the Transactions tab filtered to the selected account.
130 ListAccountTransactions,
131 RefreshTab,
132 /// Open a report form with defaults.
133 ReportNew(ReportKind),
134 /// Switch the Reports tab between the table and the chart.
135 ReportChart,
136 /// Fetch the shown category report as CSV.
137 ReportCsv,
138 /// Copy the shown CSV to the clipboard (OSC 52).
139 CsvCopy,
140 /// Ask for a path and save the shown CSV there.
141 CsvSave,
142 /// A template key; see [`TemplateKey`].
143 Template(TemplateKey),
144 /// A script key; see [`ScriptKey`].
145 Script(ScriptKey),
146 SelectNext,
147 SelectPrev,
148 SelectConfirm,
149 SelectOpen,
150 SelectCancel,
151 /// Close the open list on the option at this index among those shown (a click).
152 SelectPick(usize),
153 SelectPageUp,
154 SelectPageDown,
155 /// Splits: move focus to next column within the focused row; at the last cell
156 /// the form moves to its next field.
157 CellNext,
158 /// Splits: move focus to previous column within the focused row; at the first
159 /// cell the form moves to its previous field.
160 CellPrev,
161 /// Up in a Splits or Rows cell: steps a select cell's options, else walks to the previous row.
162 CellUp,
163 /// Down in a Splits or Rows cell: steps a select cell's options, else walks to the next row.
164 CellDown,
165 /// Splits: move focus to next row.
166 RowNext,
167 /// Splits: move focus to previous row.
168 RowPrev,
169 /// Splits: append a new blank row.
170 SplitAddRow,
171 /// Splits: remove the focused row (minimum 1 kept).
172 SplitRemoveRow,
173 /// Ctrl-T in a form: tests the template being edited, else opens the focused
174 /// split's tag list or goes back to the splits.
175 ToggleSplitTags,
176 /// Tag list: fill the focused cell with its next suggestion.
177 CompleteSuggestion,
178 OpenFilterBuilder,
179 Builder(BuilderKey),
180 /// The menu entry that opens the Options dialog.
181 OpenOptions,
182 /// The Apply button of the Options dialog.
183 ApplyOptions,
184 /// Complete the current command-palette token (Tab in the command line).
185 CompleteCommandLine,
186 /// Step the focused Date field back by one day (Up key).
187 DateStepBack,
188 /// Step the focused Date field forward by one day (Down key).
189 DateStepForward,
190}
191
192impl Intent {
193 /// Whether the intent starts a new action, which clears the status; text
194 /// editing, cursor movement and field or option focus never do.
195 pub(super) fn starts_action(self) -> bool {
196 matches!(
197 self,
198 Intent::Quit
199 | Intent::CloseOrQuit
200 | Intent::SelectTab(_)
201 | Intent::SizeWindow
202 | Intent::NewWindow(_)
203 | Intent::SelectWindow(_)
204 | Intent::RaiseWindow(_)
205 | Intent::OpenCommandLine
206 | Intent::CloseTopmost
207 | Intent::CloseWindow
208 | Intent::CloseAll
209 | Intent::Tile
210 | Intent::Cascade
211 | Intent::Submit
212 | Intent::Press
213 | Intent::ConfirmYes
214 | Intent::OpenHelp
215 | Intent::OpenMenu
216 | Intent::ConsoleSubmit
217 | Intent::ListPageNext
218 | Intent::ListPagePrev
219 | Intent::ListFilter
220 | Intent::ListFilterClear
221 | Intent::NewRow
222 | Intent::DeleteRow
223 | Intent::ListUnmarkAll
224 | Intent::ListDeleteMarked
225 | Intent::EditRow
226 | Intent::ListDetail
227 | Intent::DetailEdit
228 | Intent::ListMergeAccount
229 | Intent::ListAccountTransactions
230 | Intent::RefreshTab
231 | Intent::ReportNew(_)
232 | Intent::ReportChart
233 | Intent::ReportCsv
234 | Intent::CsvCopy
235 | Intent::CsvSave
236 | Intent::Template(_)
237 | Intent::Script(_)
238 | Intent::SplitAddRow
239 | Intent::SplitRemoveRow
240 )
241 }
242}