duat_core::mode

Struct Cursor

Source
pub struct Cursor { /* private fields */ }
Expand description

A cursor in the text file. This is an editing cursor, -(not a printing cursor.

Implementations§

Source§

impl Cursor

Source

pub fn move_to( &mut self, point: Point, text: &Text, area: &impl Area, cfg: &PrintCfg, )

Moves to specific, pre calculated Point.

Source

pub fn move_hor( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )

Internal horizontal movement function.

Source

pub fn move_ver( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )

Internal vertical movement function.

Source

pub fn move_ver_wrapped( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )

Internal vertical movement function.

Source

pub fn shift_by( &mut self, shift: (i32, i32, i32), text: &Text, area: &impl Area, cfg: &PrintCfg, )

Source

pub fn set_anchor(&mut self)

Sets the position of the anchor to be the same as the current cursor position in the file.

The anchor and current act as a range of text on the file.

Source

pub fn unset_anchor(&mut self) -> Option<Point>

Unsets the anchor.

This is done so the cursor no longer has a valid selection.

Source

pub fn swap_ends(&mut self)

Switches the position of the anchor and caret.

Source

pub fn caret(&self) -> Point

Returns the cursor’s position on the screen.

Source

pub fn anchor(&self) -> Option<Point>

Source

pub fn byte(&self) -> u32

The byte (relative to the beginning of the file) of the caret. Indexed at 0.

Source

pub fn char(&self) -> u32

The char (relative to the beginning of the file) of the caret. Indexed at 0.

Source

pub fn col(&self) -> u32

The column of the caret. Indexed at 0.

Source

pub fn line(&self) -> u32

The line of the caret. Indexed at 0.

Source

pub fn range(&self, inclusive: bool) -> Range<u32>

Returns the range between target and anchor.

If anchor isn’t set, returns an empty range on target.

§Warning

This function will return the range that is supposed to be replaced, if self.is_inclusive(), this means that it will return one more byte at the end, i.e. start..=end.

Source

pub fn start(&self) -> Point

The starting Point of this Cursor

Source

pub fn point_range(&self, is_incl: bool, text: &Text) -> (Point, Point)

Returns the range between target and anchor.

If anchor isn’t set, returns an empty range on target.

§Warning

Unlike Self::range(), this function ignores the “inclusiveness” of the range.

Trait Implementations§

Source§

impl Clone for Cursor

Source§

fn clone(&self) -> Cursor

Returns a copy 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 Debug for Cursor

Source§

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

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

impl Default for Cursor

Source§

fn default() -> Cursor

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

impl<'de> Deserialize<'de> for Cursor

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Cursor

Source§

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

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

impl Serialize for Cursor

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Cursor

Auto Trait Implementations§

§

impl Freeze for Cursor

§

impl RefUnwindSafe for Cursor

§

impl Send for Cursor

§

impl Sync for Cursor

§

impl Unpin for Cursor

§

impl UnwindSafe for Cursor

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,