Struct duat_core::text::Text

source ·
pub struct Text {
    pub tags: Box<Tags>,
    pub records: Records<(usize, usize, usize)>,
    /* private fields */
}
Expand description

The text in a given area.

Fields§

§tags: Box<Tags>§records: Records<(usize, usize, usize)>

Implementations§

source§

impl Text

source

pub fn new() -> Self

source

pub fn from_file(path: impl AsRef<Path>) -> Self

source

pub fn builder() -> Builder

source

pub fn insert_tag(&mut self, at: usize, tag: Tag, marker: Marker)

source

pub fn remove_tags_on(&mut self, b: usize, markers: impl Markers)

source

pub fn slices(&self) -> (&str, &str)

source

pub fn slices_range(&self, range: impl RangeBounds<usize>) -> (&str, &str)

source

pub fn tags(&self) -> impl Iterator<Item = (usize, RawTag)> + '_

source

pub fn tags_at( &self, at: usize, ) -> impl Iterator<Item = (usize, RawTag)> + Clone + '_

source

pub fn chars(&self) -> impl Iterator<Item = char> + Clone + '_

source

pub fn is_empty(&self) -> bool

source

pub fn get_point_at(&self, at: usize) -> Option<Point>

source

pub fn ghost_max_points_at(&self, at: usize) -> Option<(Point, Option<Point>)>

source

pub fn points_after(&self, tp: impl TwoPoints) -> Option<(Point, Option<Point>)>

Points visually after the [TwoPoints]

If the [TwoPoints] in question is concealed, treats the next visible character as the first character, and returns the points of the next visible character.

This method is useful if you want to iterater reversibly right after a certain point, thus including the character of said point.

source

pub fn len_bytes(&self) -> usize

source

pub fn len_chars(&self) -> usize

source

pub fn len_lines(&self) -> usize

source

pub fn max_point(&self) -> Point

source

pub fn visual_line_start(&self, p: impl TwoPoints) -> (Point, Option<Point>)

The visual start of the line

This point is defined not by where the line actually begins, but by where the last ‘\n’ was located. For example, if Tags create ghost text or ommit text from multiple different lines, this point may differ from where in the Text the physical line actually begins.

source§

impl Text

source

pub fn iter(&self) -> Iter<'_>

source

pub fn iter_at(&self, p: impl TwoPoints) -> Iter<'_>

source

pub fn rev_iter(&self) -> RevIter<'_>

source

pub fn rev_iter_at(&self, p: impl TwoPoints) -> RevIter<'_>

source

pub fn iter_bytes_at(&self, b: usize) -> impl Iterator<Item = u8> + '_

source

pub fn iter_chars_at(&self, c: usize) -> impl Iterator<Item = char> + '_

Trait Implementations§

source§

impl Clone for Text

source§

fn clone(&self) -> Text

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 Text

source§

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

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

impl Default for Text

source§

fn default() -> Text

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

impl<S> From<S> for Text
where S: ToString,

source§

fn from(value: S) -> Self

Converts to this type from the input type.
source§

impl From<Text> for BuilderPart<String>

source§

fn from(value: Text) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Text

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

impl Eq for Text

Auto Trait Implementations§

§

impl Freeze for Text

§

impl !RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl !UnwindSafe for Text

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§

default 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<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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,

§

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

§

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.