Buffer

Struct Buffer 

Source
pub struct Buffer {
    pub opts: PrintOpts,
    /* private fields */
}
Expand description

The widget that is used to print and edit buffers

Fields§

§opts: PrintOpts

The PrintOpts of this Buffer

You can use this member to change the way this Buffer will be printed specifically.

Implementations§

Source§

impl Buffer

Source

pub fn path(&self) -> String

The full path of the buffer.

If there is no set path, returns "*scratch buffer*#{id}".

Source

pub fn path_set(&self) -> Option<String>

The full path of the buffer.

Returns None if the path has not been set yet, i.e., if the buffer is a scratch buffer.

Source

pub fn path_txt(&self) -> Text

A Text from the full path of this PathKind

§Formatting

If the buffer’s path was set:

[buffer]{path}

If the buffer’s path was not set:

[buffer.new.scratch]*scratch buffer #{id}*
Source

pub fn name(&self) -> String

The buffer’s name.

If there is no set path, returns "*scratch buffer #{id}*".

Source

pub fn name_set(&self) -> Option<String>

The buffer’s name.

Returns None if the path has not been set yet, i.e., if the buffer is a scratch buffer.

Source

pub fn name_txt(&self) -> Text

A Text from the name of this PathKind

The name of a Buffer widget is the same as the path, but it strips away the current directory. If it can’t, it will try to strip away the home directory, replacing it with "~". If that also fails, it will just show the full path.

§Formatting

If the buffer’s name was set:

[buffer]{name}

If the buffer’s name was not set:

[buffer.new.scratch]*scratch buffer #{id}*
Source

pub fn path_kind(&self) -> PathKind

The type of PathBuf

This represents the three possible states for a Buffer’s PathBuf, as it could either represent a real Buffer, not exist, or not have been defined yet.

Source

pub fn buffer_id(&self) -> BufferId

A unique identifier for this Buffer

This is more robust than identifying it by its path or name, or event PathKind, since those could change, but this cannot.

Source

pub fn bytes(&self) -> &Bytes

The Bytes of the Buffer’s Text

Source

pub fn len_bytes(&self) -> usize

The number of bytes in the buffer.

Source

pub fn len_chars(&self) -> usize

The number of chars in the buffer.

Source

pub fn len_lines(&self) -> usize

The number of lines in the buffer.

Source

pub fn selections(&self) -> &Selections

The Selections that are used on the Text

Source

pub fn selections_mut(&mut self) -> &mut Selections

A mutable reference to the Selections

Source

pub fn exists(&self) -> bool

Whether o not the Buffer exists or not

Trait Implementations§

Source§

impl Widget for Buffer

Source§

fn update(pa: &mut Pass, handle: &Handle<Self>)

Updates the widget alongside its RwArea in the Handle Read more
Source§

fn needs_update(&self, _: &Pass) -> bool

Tells Duat that this Widget should be updated Read more
Source§

fn text(&self) -> &Text

The text that this widget prints out
Source§

fn text_mut(&mut self) -> TextMut<'_>

A mutable reference to the Text that is printed
Source§

fn get_print_opts(&self) -> PrintOpts

The configuration for how to print Text Read more
Source§

fn on_mouse_event(pa: &mut Pass, handle: &Handle<Self>, event: MouseEvent)

How to handle a MouseEvent Read more
Source§

fn on_focus(pa: &mut Pass, handle: &Handle<Self>)
where Self: Sized,

Actions to do whenever this Widget is focused Read more
Source§

fn on_unfocus(pa: &mut Pass, handle: &Handle<Self>)
where Self: Sized,

Actions to do whenever this Widget is unfocused Read more

Auto Trait Implementations§

§

impl !Freeze for Buffer

§

impl !RefUnwindSafe for Buffer

§

impl Send for Buffer

§

impl Sync for Buffer

§

impl Unpin for Buffer

§

impl !UnwindSafe for Buffer

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