pub struct Buffer {
pub opts: BufferOpts,
/* private fields */
}Expand description
The widget that is used to print and edit buffers.
Fields§
§opts: BufferOptsYou can use this member to change the way this Buffer will
be printed specifically.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn path(&self) -> String
pub fn path(&self) -> String
The full path of the buffer.
If there is no set path, returns "*scratch buffer*#{id}".
Sourcepub fn path_set(&self) -> Option<String>
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.
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
The buffer’s name.
If there is no set path, returns "*scratch buffer #{id}*".
Sourcepub fn name_set(&self) -> Option<String>
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.
Sourcepub fn name_txt(&self) -> Text
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}*Sourcepub fn path_kind(&self) -> PathKind
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.
Sourcepub fn buffer_id(&self) -> BufferId
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.
Sourcepub fn text(&self) -> &Text
pub fn text(&self) -> &Text
The Text of this Buffer
This is the same as Widget::text, but doesn’t need the
Widget trait to be in scope.
Sourcepub fn text_mut(&mut self) -> TextMut<'_>
pub fn text_mut(&mut self) -> TextMut<'_>
The mutable TextMut of this Buffer
This is the same as Widget::text_mut, but doesn’t need the
Widget trait to be in scope.
Sourcepub fn selections(&self) -> &Selections
pub fn selections(&self) -> &Selections
The Selections that are used on the Text.
Sourcepub fn selections_mut(&mut self) -> &mut Selections
pub fn selections_mut(&mut self) -> &mut Selections
A mutable reference to the Selections.
Trait Implementations§
Source§impl Widget for Buffer
impl Widget for Buffer
Source§fn needs_update(&self, _: &Pass) -> bool
fn needs_update(&self, _: &Pass) -> bool
Source§fn print_opts(&self) -> PrintOpts
fn print_opts(&self) -> PrintOpts
Source§fn on_mouse_event(pa: &mut Pass, handle: &Handle<Self>, event: MouseEvent)
fn on_mouse_event(pa: &mut Pass, handle: &Handle<Self>, event: MouseEvent)
MouseEvent Read more