Struct Buffer

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

Internal state for a text buffer backed by a file on disk

Implementations§

Source§

impl Buffer

Source

pub fn new_from_canonical_file_path(id: usize, path: PathBuf) -> Result<Self>

As the name implies, this method MUST be called with the full cannonical file path

Source

pub fn new_unnamed(id: usize, content: impl Into<String>) -> Self

Create a new unnamed buffer with the given content

Source

pub fn new_virtual( id: usize, name: impl Into<String>, content: impl Into<String>, ) -> Self

Create a new virtual buffer with the given name and content.

The buffer will not be included in the virtual filesystem and it will be removed when it loses focus.

Source

pub fn display_name(&self) -> String

Short name for displaying in the status line

Source

pub fn full_name(&self) -> &str

Absolute path of full name of a virtual buffer

Source

pub fn dir(&self) -> Option<&Path>

The directory containing the file backing this buffer (if any).

Source

pub fn path(&self) -> Option<&Path>

The path for the file backing this buffer (if any).

Source

pub fn output_file_key(&self, cwd: &Path) -> String

The key for the +output buffer that output from command run from this buffer should be redirected to

Source

pub fn is_unnamed(&self) -> bool

Check whether or not this is an unnamed buffer

Source

pub fn contents(&self) -> Vec<u8>

The raw binary contents of this buffer

Source

pub fn str_contents(&self) -> String

The utf-8 string contents of this buffer

Source

pub fn update_ts_state(&mut self, from: usize, n_rows: usize)

Source

pub fn iter_tokenized_lines_from( &self, line: usize, load_exec_range: Option<(bool, Range)>, ) -> LineIter<'_>

Source

pub fn dot_contents(&self) -> String

The contents of the current Dot.

Source

pub fn addr(&self) -> String

The address of the current Dot.

Source

pub fn xdot_contents(&self) -> String

The contents of the current xdot.

This is a virtual dot that is only made use of through the filesystem interface.

Source

pub fn xaddr(&self) -> String

The address of the current xdot.

This is a virtual dot that is only made use of through the filesystem interface.

Source

pub fn len_lines(&self) -> usize

The number of lines currently held in the buffer.

Source

pub fn len_chars(&self) -> usize

The number of utf-8 characters currently held in the buffer.

Source

pub fn is_empty(&self) -> bool

Whether or not the buffer is empty.

§Note

This does not always imply that the underlying buffer is zero sized, only that the visible contents are empty.

Source

pub fn line(&self, y: usize) -> Option<Slice<'_>>

The line at the requested index returned as a Slice.

Trait Implementations§

Source§

impl Debug for Buffer

Source§

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

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

impl Edit for Buffer

Source§

fn insert(&mut self, idx: usize, s: &str)

Insert a string at the specified index
Source§

fn remove(&mut self, from: usize, to: usize)

Remove all characters from (from..to)
Source§

fn begin_edit_transaction(&mut self)

Mark the start of an edit transaction
Source§

fn end_edit_transaction(&mut self)

Mark the end of an edit transaction
Source§

fn submatch(&self, m: &Match, n: usize) -> Option<String>

Extract the content of a previous submatch so it can be used in templating

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