pub struct StatusLine { /* private fields */ }Expand description
A widget to show information, usually about a Buffer
This widget is updated whenever any of its parts needs to be
updated, and it also automatically adjusts to where it was pushed.
For example, if you push it to a buffer (via
hook::add::<Buffer>, for example), it’s information will point
to the Buffer to which it was pushed. However, if you push it
with WindowCreated, it will always point to the currently
active Buffer:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
opts::one_line_footer();
opts::set_status(|pa| status!("{AlignRight}{} {sels_txt} {main_txt}", mode_txt()));
hook::add::<Buffer>(|pa, handle| {
status!("{AlignCenter}{name_txt}")
.above()
.push_on(pa, handle);
Ok(())
});
}In the code above, I’m modifying the “global” StatusLine through
opts::set_status (this can be done with hooks as well, but
this method is added for convenience’s sake). This is in
conjunction with opts::one_line_footer, which will place
the PromptLine and StatusLine on the same line.
After that, I’m also pushing a new StatusLine above every
opened Buffer, showing that Buffer]’s name, centered.
You will usually want to create StatusLines via the
[status!] macro, since that is how you can customize it.
Although, if you want the regular status line, you can call
StatusLine::builder:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
hook::add::<Buffer>(|pa, handle| {
StatusLine::builder().above().push_on(pa, handle);
Ok(())
});
}Implementations§
Source§impl StatusLine
impl StatusLine
Sourcepub fn fmt(&mut self, new: StatusLineFmt)
pub fn fmt(&mut self, new: StatusLineFmt)
Replaces this StatusLine with a new one
Sourcepub fn builder() -> StatusLineFmt
pub fn builder() -> StatusLineFmt
Returns a StatusLineFmt, which can be used to push
around StatusLines
The same can be done more conveniently with the [status!]
macro, which is imported by default in the configuration
crate.
Trait Implementations§
Source§impl Widget for StatusLine
impl Widget for StatusLine
Source§fn needs_update(&self, pa: &Pass) -> bool
fn needs_update(&self, pa: &Pass) -> bool
Source§fn on_mouse_event(pa: &mut Pass, handle: &Handle<Self>, event: MouseEvent)where
Self: Sized,
fn on_mouse_event(pa: &mut Pass, handle: &Handle<Self>, event: MouseEvent)where
Self: Sized,
MouseEvent Read moreSource§fn get_print_opts(&self) -> PrintOpts
fn get_print_opts(&self) -> PrintOpts
Auto Trait Implementations§
impl !Freeze for StatusLine
impl !RefUnwindSafe for StatusLine
impl Send for StatusLine
impl !Sync for StatusLine
impl Unpin for StatusLine
impl !UnwindSafe for StatusLine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.