pub struct Verb {Show 13 fields
pub id: VerbId,
pub names: Vec<String>,
pub keys: Vec<KeyEvent>,
pub invocation_parser: Option<InvocationParser>,
pub execution: VerbExecution,
pub description: VerbDescription,
pub selection_condition: FileTypeCondition,
pub file_extensions: Vec<String>,
pub needs_selection: bool,
pub needs_another_panel: bool,
pub auto_exec: bool,
pub show_in_doc: bool,
pub panels: Vec<PanelStateType>,
}
Expand description
what makes a verb.
Verbs are the engines of broot commands, and apply
- to the selected file (if user-defined, then must contain {file}, {parent} or {directory})
- to the current app state There are two types of verbs executions:
- external programs or commands (cd, mkdir, user defined commands, etc.)
- internal behaviors (focusing a path, going back, showing the help, etc.) Some verbs are builtins, some other ones are created by configuration. Both builtins and configured vers can be internal or external based.
Verbs can’t be cloned. Two verbs are equal if they have the same address in memory.
Fields§
§id: VerbId
§names: Vec<String>
names (like “cd”, “focus”, “focus_tab”, “c”) by which a verb can be called. Can be empty if the verb is only called with a key shortcut. Right now there’s no way for it to contain more than 2 elements but this may change.
keys: Vec<KeyEvent>
key shortcuts
invocation_parser: Option<InvocationParser>
how the input must be checked and interpreted Can be empty if the verb is only called with a key shortcut.
execution: VerbExecution
how the verb will be executed
description: VerbDescription
a description
selection_condition: FileTypeCondition
the type of selection this verb applies to
file_extensions: Vec<String>
extension filtering. If empty, all extensions apply
needs_selection: bool
whether the verb needs a selection
needs_another_panel: bool
whether we need to have a secondary panel for execution (which is the case when the execution pattern has {other-panel-file})
auto_exec: bool
if true (default) verbs are directly executed when triggered with a keyboard shortcut
show_in_doc: bool
whether to show the verb in help screen (if we show all input related actions, the doc is unusable)
panels: Vec<PanelStateType>
Implementations§
source§impl Verb
impl Verb
pub fn new( id: VerbId, invocation_str: Option<&str>, execution: VerbExecution, description: VerbDescription ) -> Result<Self, ConfError>
pub fn with_key(&mut self, key: KeyEvent) -> &mut Self
pub fn add_keys(&mut self, keys: Vec<KeyEvent>)
pub fn no_doc(&mut self) -> &mut Self
pub fn with_description(&mut self, description: &str) -> &mut Self
pub fn with_shortcut(&mut self, shortcut: &str) -> &mut Self
pub fn with_condition( &mut self, selection_condition: FileTypeCondition ) -> &mut Self
pub fn needing_another_panel(&mut self) -> &mut Self
pub fn with_auto_exec(&mut self, b: bool) -> &mut Self
pub fn has_name(&self, searched_name: &str) -> bool
sourcepub fn check_args(
&self,
sel_info: SelInfo<'_>,
invocation: &VerbInvocation,
other_path: &Option<PathBuf>
) -> Option<String>
pub fn check_args( &self, sel_info: SelInfo<'_>, invocation: &VerbInvocation, other_path: &Option<PathBuf> ) -> Option<String>
Assuming the verb has been matched, check whether the arguments are OK according to the regex. Return none when there’s no problem and return the error to display if arguments don’t match.