Lines
100 %
Functions
Branches
//! The vocabulary of key intents applied to the app.
use super::{BuilderKey, ScriptKey, TemplateKey};
use crate::tabs::reports::ReportKind;
use crate::view::Tab;
use crate::window::WindowId;
use tvui::Change;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Intent {
/// Ask before leaving the application.
Quit,
/// Leave the application at once.
QuitNow,
/// Close the front window, or ask before leaving when none is open.
CloseOrQuit,
/// Bring the rearmost window to the front.
NextWindow,
/// Send the front window to the back.
PrevWindow,
/// Zoom the front window to the desktop, or restore it.
ToggleZoom,
/// Start moving or sizing the front window from the keyboard.
SizeWindow,
/// A step of moving or sizing the window.
Drag(Change),
/// Keep the window as moved or sized.
DragDone,
/// Put the window back as it was before the move or size.
DragCancel,
/// Lay every window out side by side over the desktop.
Tile,
/// Stack every window from the desktop corner, each one step further in.
Cascade,
NextField,
PrevField,
/// Create a row in the active tab: an account's transaction, a config key, an SSH key, a tag, a template or a script.
NewRow,
/// Delete the selected row of the active tab.
DeleteRow,
SelectTab(Tab),
/// Open a new window of a view.
NewWindow(Tab),
/// Raise the window with this TV number.
SelectWindow(u8),
/// Raise this window; the entries of the Window list.
RaiseWindow(WindowId),
OpenCommandLine,
CloseTopmost,
/// Close the front window.
CloseWindow,
/// Close every window.
CloseAll,
Submit,
/// Enter on a form: presses the focused button, else submits.
Press,
/// Confirm the topmost confirm overlay (equivalent to pressing `y`).
ConfirmYes,
/// Enter on a confirm overlay: confirms, but the discard prompt cancels.
InsertChar(char),
DeleteBackward,
MoveLeft,
MoveRight,
MoveHome,
MoveEnd,
MoveUp,
MoveDown,
InsertNewline,
KillToEnd,
KillWordBackward,
MoveWordForward,
MoveWordBackward,
DeleteForward,
DeleteWordForward,
/// Leave typing for the command line's normal mode.
EnterNormalMode,
InsertAtCursor,
InsertAfterCursor,
InsertAtLineStart,
InsertAtLineEnd,
OpenHelp,
OpenMenu,
CloseMenu,
MenuNext,
MenuPrev,
MenuFirst,
MenuLast,
MenuLeft,
MenuRight,
MenuSelect,
ConsoleFocus,
ConsoleBlur,
ConsoleSubmit,
ConsoleInterrupt,
ConsoleHistoryPrev,
ConsoleHistoryNext,
ConsoleCyclePane,
ScrollLineUp,
ScrollLineDown,
ScrollPageUp,
ScrollPageDown,
ScrollTop,
ScrollEnd,
ListSelectNext,
ListSelectPrev,
ListSelectFirst,
ListSelectLast,
/// Select the row at this index among the rows the view holds (a click).
ListSelectRow(usize),
ListViewDown,
ListViewUp,
ListPageNext,
ListPagePrev,
/// Open the Transactions filter form.
ListFilter,
/// Drop the Transactions filter.
ListFilterClear,
ListMark,
ListUnmarkAll,
ListDeleteMarked,
/// Open the edit form of the selected row of the active tab.
EditRow,
/// Open the read-only detail of the selected transaction.
ListDetail,
/// Edit the transaction shown in the detail window.
DetailEdit,
/// Open account-merge with From set to the selected account.
ListMergeAccount,
/// Open the Transactions tab filtered to the selected account.
ListAccountTransactions,
RefreshTab,
/// Open a report form with defaults.
ReportNew(ReportKind),
/// Switch the Reports tab between the table and the chart.
ReportChart,
/// Fetch the shown category report as CSV.
ReportCsv,
/// Copy the shown CSV to the clipboard (OSC 52).
CsvCopy,
/// Ask for a path and save the shown CSV there.
CsvSave,
/// A template key; see [`TemplateKey`].
Template(TemplateKey),
/// A script key; see [`ScriptKey`].
Script(ScriptKey),
SelectNext,
SelectPrev,
SelectConfirm,
SelectOpen,
SelectCancel,
/// Close the open list on the option at this index among those shown (a click).
SelectPick(usize),
SelectPageUp,
SelectPageDown,
/// Splits: move focus to next column within the focused row; at the last cell
/// the form moves to its next field.
CellNext,
/// Splits: move focus to previous column within the focused row; at the first
/// cell the form moves to its previous field.
CellPrev,
/// Up in a Splits or Rows cell: steps a select cell's options, else walks to the previous row.
CellUp,
/// Down in a Splits or Rows cell: steps a select cell's options, else walks to the next row.
CellDown,
/// Splits: move focus to next row.
RowNext,
/// Splits: move focus to previous row.
RowPrev,
/// Splits: append a new blank row.
SplitAddRow,
/// Splits: remove the focused row (minimum 1 kept).
SplitRemoveRow,
/// Ctrl-T in a form: tests the template being edited, else opens the focused
/// split's tag list or goes back to the splits.
ToggleSplitTags,
/// Tag list: fill the focused cell with its next suggestion.
CompleteSuggestion,
OpenFilterBuilder,
Builder(BuilderKey),
/// The menu entry that opens the Options dialog.
OpenOptions,
/// The Apply button of the Options dialog.
ApplyOptions,
/// Complete the current command-palette token (Tab in the command line).
CompleteCommandLine,
/// Step the focused Date field back by one day (Up key).
DateStepBack,
/// Step the focused Date field forward by one day (Down key).
DateStepForward,
}
impl Intent {
/// Whether the intent starts a new action, which clears the status; text
/// editing, cursor movement and field or option focus never do.
pub(super) fn starts_action(self) -> bool {
matches!(
self,
Intent::Quit
| Intent::CloseOrQuit
| Intent::SelectTab(_)
| Intent::SizeWindow
| Intent::NewWindow(_)
| Intent::SelectWindow(_)
| Intent::RaiseWindow(_)
| Intent::OpenCommandLine
| Intent::CloseTopmost
| Intent::CloseWindow
| Intent::CloseAll
| Intent::Tile
| Intent::Cascade
| Intent::Submit
| Intent::Press
| Intent::ConfirmYes
| Intent::OpenHelp
| Intent::OpenMenu
| Intent::ConsoleSubmit
| Intent::ListPageNext
| Intent::ListPagePrev
| Intent::ListFilter
| Intent::ListFilterClear
| Intent::NewRow
| Intent::DeleteRow
| Intent::ListUnmarkAll
| Intent::ListDeleteMarked
| Intent::EditRow
| Intent::ListDetail
| Intent::DetailEdit
| Intent::ListMergeAccount
| Intent::ListAccountTransactions
| Intent::RefreshTab
| Intent::ReportNew(_)
| Intent::ReportChart
| Intent::ReportCsv
| Intent::CsvCopy
| Intent::CsvSave
| Intent::Template(_)
| Intent::Script(_)
| Intent::SplitAddRow
| Intent::SplitRemoveRow
)