Struct broot::verb::Verb

source ·
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

source

pub fn new( id: VerbId, invocation_str: Option<&str>, execution: VerbExecution, description: VerbDescription ) -> Result<Self, ConfError>

source

pub fn with_key(&mut self, key: KeyEvent) -> &mut Self

source

pub fn add_keys(&mut self, keys: Vec<KeyEvent>)

source

pub fn no_doc(&mut self) -> &mut Self

source

pub fn with_description(&mut self, description: &str) -> &mut Self

source

pub fn with_shortcut(&mut self, shortcut: &str) -> &mut Self

source

pub fn with_condition( &mut self, selection_condition: FileTypeCondition ) -> &mut Self

source

pub fn needing_another_panel(&mut self) -> &mut Self

source

pub fn with_auto_exec(&mut self, b: bool) -> &mut Self

source

pub fn has_name(&self, searched_name: &str) -> bool

source

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.

source

pub fn get_status_markdown( &self, sel_info: SelInfo<'_>, app_state: &AppState, invocation: &VerbInvocation ) -> String

source

pub fn get_unique_arg_anchor(&self) -> PathAnchor

source

pub fn get_internal(&self) -> Option<Internal>

source

pub fn is_internal(&self, internal: Internal) -> bool

source

pub fn is_some_internal(v: Option<&Verb>, internal: Internal) -> bool

source

pub fn is_sequence(&self) -> bool

source

pub fn can_be_called_in_panel(&self, panel_state_type: PanelStateType) -> bool

source

pub fn accepts_extension(&self, extension: Option<&str>) -> bool

Trait Implementations§

source§

impl Debug for Verb

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Verb

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl RefUnwindSafe for Verb

§

impl Send for Verb

§

impl Sync for Verb

§

impl Unpin for Verb

§

impl UnwindSafe for Verb

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.