pub struct Buffer { /* private fields */ }Expand description
Internal state for a text buffer backed by a file on disk
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn new_from_canonical_file_path(
id: usize,
path: PathBuf,
config: Arc<RwLock<Config>>,
) -> Result<Self>
pub fn new_from_canonical_file_path( id: usize, path: PathBuf, config: Arc<RwLock<Config>>, ) -> Result<Self>
As the name implies, this method MUST be called with the full canonical file path
Sourcepub fn new_unnamed(
id: usize,
content: impl Into<String>,
config: Arc<RwLock<Config>>,
) -> Self
pub fn new_unnamed( id: usize, content: impl Into<String>, config: Arc<RwLock<Config>>, ) -> Self
Create a new unnamed buffer with the given content
Sourcepub fn new_virtual(
id: usize,
name: impl Into<String>,
content: impl Into<String>,
config: Arc<RwLock<Config>>,
) -> Self
pub fn new_virtual( id: usize, name: impl Into<String>, content: impl Into<String>, config: Arc<RwLock<Config>>, ) -> 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.
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
Short name for displaying in the status line
Sourcepub fn dir(&self) -> Option<&Path>
pub fn dir(&self) -> Option<&Path>
The directory containing the file backing this buffer (if any).
Sourcepub fn output_file_key(&self, cwd: &Path) -> String
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
Sourcepub fn is_unnamed(&self) -> bool
pub fn is_unnamed(&self) -> bool
Check whether or not this is an unnamed buffer
Sourcepub fn has_trailing_newline(&self) -> bool
pub fn has_trailing_newline(&self) -> bool
Whether or not the contents of the buffer end with a final newline character.
POSIX semantics define a line as “A sequence of zero or more non-newline characters plus a terminating newline character.”
See: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
Sourcepub fn configured_filetype(&self) -> Option<String>
pub fn configured_filetype(&self) -> Option<String>
Check the current Config to see if this buffer matches a known filetype configuration.
Sourcepub fn str_contents(&self) -> String
pub fn str_contents(&self) -> String
The utf-8 string contents of this buffer
pub fn update_ts_state(&mut self, from: usize, n_rows: usize)
pub fn iter_tokenized_lines_from( &self, line: usize, load_exec_range: Option<(bool, Range)>, ) -> LineIter<'_> ⓘ
Sourcepub fn dot_contents(&self) -> String
pub fn dot_contents(&self) -> String
The contents of the current Dot.
Sourcepub fn xdot_contents(&self) -> String
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.
Sourcepub fn xaddr(&self) -> String
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.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn line(&self, y: usize) -> Option<Slice<'_>>
pub fn line(&self, y: usize) -> Option<Slice<'_>>
The line at the requested index returned as a Slice.
Sourcepub fn handle_action(
&mut self,
a: Action,
source: Source,
) -> Option<ActionOutcome>
pub fn handle_action( &mut self, a: Action, source: Source, ) -> Option<ActionOutcome>
The error result of this function is an error string that should be displayed to the user
Sourcepub fn set_dot_from_cursor(&mut self, idx: usize)
pub fn set_dot_from_cursor(&mut self, idx: usize)
Set this Buffer’s dot to an explicit cursor position, clamping to EOB.
Sourcepub fn set_dot_from_range(&mut self, from: usize, to: usize)
pub fn set_dot_from_range(&mut self, from: usize, to: usize)
Set this Buffer’s dot to an explicit Range, clamping to EOB.