pub struct StatusLine<U: Ui> { /* private fields */ }Expand description
A widget to show information, usually about a File
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 with OnFileOpen, it’s information
will point to the File to which it was pushed. However, if you
push it with OnWindowOpen, it will always point to the
currently active File:
use duat_core::{
hook::{OnFileOpen, OnWindowOpen},
prelude::*,
};
use duat_utils::{state::*, widgets::*};
fn setup_generic_over_ui<U: Ui>() {
hook::remove("FileWidgets");
hook::add::<OnFileOpen<U>, U>(|pa, builder| {
builder.push(pa, LineNumbers::cfg());
builder.push(pa, status!("{file_fmt}").above());
});
hook::remove("WindowWidgets");
hook::add::<OnWindowOpen<U>, U>(|pa, builder| {
let footer = FooterWidgets::new(status!("{mode_fmt} {sels_fmt} {main_fmt}"));
builder.push(pa, footer);
});
}In the above example, each file would have a status line with the
name of the file, and by pushing FooterWidgets, you will push
a StatusLine, PromptLine and Notifications combo to
each window. This StatusLine will point to the currently
active File, instead of a specific one.
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 just:
use duat_core::{hook::OnFileOpen, prelude::*};
use duat_utils::widgets::*;
fn setup_generic_over_ui<U: Ui>() {
hook::remove("FileWidgets");
hook::add::<OnFileOpen<U>, U>(|pa, builder| {
builder.push(pa, LineNumbers::cfg());
builder.push(pa, StatusLine::cfg().above());
});
}Trait Implementations§
Source§impl<U: Ui> Widget<U> for StatusLine<U>
impl<U: Ui> Widget<U> for StatusLine<U>
Source§type Cfg = StatusLineCfg<U>
type Cfg = StatusLineCfg<U>
Source§fn once() -> Result<(), Text>
fn once() -> Result<(), Text>
Source§fn on_focus(pa: &mut Pass, handle: Handle<Self, U>)where
Self: Sized,
fn on_focus(pa: &mut Pass, handle: Handle<Self, U>)where
Self: Sized,
Widget is focused