Skip to main content

Cursor

Struct Cursor 

Source
pub struct Cursor {
    pub is_dragging: bool,
    pub leave_bind: String,
    pub enter_bind: String,
    pub copy_bind: String,
    /* private fields */
}
Expand description

Cursor is used to select and copy or log text directly from fm output. Once the cursor is active, you can’t move in the file tree or open menus etc. You can only :

  • toggle the selection state,
  • move the cursor with keys or mouse,
  • copy the selected chars (only while selecting)
  • leave the cursor and go back to normal usage of fm,
  • exit fm completely

It’s a way to allow copying text without having to exit fm or open a new shell.

Cursor has a state (inactive, movement, selecting), knows its position and where it started its selection. We also store the associated binds to help the user.

Fields§

§is_dragging: bool

Are we dragging the cursor with the mouse ?

§leave_bind: String

What is the keybind associated to leave menu ?

§enter_bind: String

What is the keybind associated to entering the cursor ? It’s used to toggle selection state.

§copy_bind: String

What is the bind associated to copy/paste. Used to copy the selection to clipboard and log it.

Implementations§

Source§

impl Cursor

Source

pub fn new(binds: &Bindings) -> Self

Creates a new cursor with binds read from keybinds.

Source

pub fn rect(&self) -> Option<Rect>

Copy of the inner rect.

Source

pub fn cursor(&self) -> Option<Position>

Position of the cursor if any

Source

pub fn is_active(&self) -> bool

True iff the cursor is in active mode (either movement or selecting)

Source

pub fn is_selecting(&self) -> bool

True iff the cursor is selecting.

Source

pub fn reset(&mut self)

Reset the cursor. set state to inactive, erase cusrsor, origin & rect and set is_dragging to false.

Source

pub fn toggle(&mut self, position: Position)

Set the state from inactive to movement or toggle between movement & selecting.

Source

pub fn move_cursor(&mut self, direction: CursorDirection, _: Size)

Move the cursor in given direction. Cursor is clamped to the the screen. It’s coordinates can’t be equal or bigger to terminal height or width.

Source

pub fn move_cursor_to(&mut self, position: Position)

Move the cursor to position Does nothing if cursor isn’t active.

Source

pub fn move_origin_to(&mut self, position: Position)

Move the origin of selection to position Does nothing if cursor isn’t active.

Source

pub fn extend_selection(&mut self)

Update the selection from origin to current position. Does nothing if cursor isn’t active.

Source

pub fn mouse_drag(&mut self, row: u16, col: u16)

Used to allow selecting text with the mouse. Either start selecting from previous position if we enter the “dragging” state Move the cursor to the current mouse position. Or extend selection.

Source

pub fn stop_drag(&mut self)

Stop dragging.

Trait Implementations§

Source§

impl Clone for Cursor

Source§

fn clone(&self) -> Cursor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Cursor

Source§

fn default() -> Cursor

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,