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::<BufferOpened>, for example), it’s information will
point to the Buffer to which it was pushed. However, if you
push it with WindowOpened, it will always point to the
currently active Buffer:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
opts::set(|opts| opts.one_line_footer = true);
opts::fmt_status(|pa| status!("{Spacer}{} {sels_txt} {main_txt}", mode_txt()));
hook::add::<BufferOpened>(|pa, handle| {
status!("{Spacer}{name_txt}{Spacer}")
.above()
.push_on(pa, handle);
});
}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::<BufferOpened>(|pa, handle| {
StatusLine::builder().above().push_on(pa, handle);
});
}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 more