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: boolAre we dragging the cursor with the mouse ?
leave_bind: StringWhat is the keybind associated to leave menu ?
enter_bind: StringWhat is the keybind associated to entering the cursor ? It’s used to toggle selection state.
copy_bind: StringWhat is the bind associated to copy/paste. Used to copy the selection to clipboard and log it.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
True iff the cursor is in active mode (either movement or selecting)
Sourcepub fn is_selecting(&self) -> bool
pub fn is_selecting(&self) -> bool
True iff the cursor is selecting.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the cursor. set state to inactive, erase cusrsor, origin & rect and set is_dragging to false.
Sourcepub fn toggle(&mut self, position: Position)
pub fn toggle(&mut self, position: Position)
Set the state from inactive to movement or toggle between movement & selecting.
Sourcepub fn move_cursor(&mut self, direction: CursorDirection, _: Size)
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.
Sourcepub fn move_cursor_to(&mut self, position: Position)
pub fn move_cursor_to(&mut self, position: Position)
Move the cursor to position
Does nothing if cursor isn’t active.
Sourcepub fn move_origin_to(&mut self, position: Position)
pub fn move_origin_to(&mut self, position: Position)
Move the origin of selection to position
Does nothing if cursor isn’t active.
Sourcepub fn extend_selection(&mut self)
pub fn extend_selection(&mut self)
Update the selection from origin to current position. Does nothing if cursor isn’t active.
Sourcepub fn mouse_drag(&mut self, row: u16, col: u16)
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnsafeUnpin for Cursor
impl UnwindSafe for Cursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.