refactor mode indicators

This commit is contained in:
🪞👃🪞 2025-04-03 23:45:27 +03:00
parent 52102d771d
commit f571b079b1

View file

@ -9,6 +9,10 @@ impl Taggart {
pub(crate) const BG_BROWSE: Color = Color::Rgb(0, 0, 0); pub(crate) const BG_BROWSE: Color = Color::Rgb(0, 0, 0);
pub(crate) const BG_EDIT: Color = Color::Rgb(48, 128, 0); pub(crate) const BG_EDIT: Color = Color::Rgb(48, 128, 0);
pub(crate) const FG_EDIT: Color = Color::Rgb(255, 255, 255); pub(crate) const FG_EDIT: Color = Color::Rgb(255, 255, 255);
pub(crate) const BG_SAVE: Color = Color::Rgb(192, 96, 0);
pub(crate) const FG_SAVE: Color = Color::Rgb(255, 255, 255);
pub(crate) const BG_QUIT: Color = Color::Rgb(128, 0, 0);
pub(crate) const FG_QUIT: Color = Color::Rgb(255, 255, 255);
} }
impl Content<TuiOut> for Taggart { impl Content<TuiOut> for Taggart {
@ -55,22 +59,23 @@ impl Taggart {
) )
} }
fn mode_bar (&self, size: String) -> impl Content<TuiOut> { fn mode_bar (&self, size: String) -> impl Content<TuiOut> {
let mode = match self.mode {
Some(Mode::Save { .. }) => Tui::bg(Self::BG_SAVE, Tui::fg(Self::FG_SAVE, " SAVE ")),
Some(Mode::Quit { .. }) => Tui::bg(Self::BG_QUIT, Tui::fg(Self::FG_QUIT, " QUIT ")),
Some(Mode::Edit { .. }) => Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
_ => Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE "))
};
let help = match self.mode {
Some(Mode::Save { .. }) => " Esc: cancel, Arrows: select, Enter: confirm",
Some(Mode::Quit { .. }) => " Esc: cancel, Arrows: select, Enter: confirm",
Some(Mode::Edit { .. }) => " Esc: cancel, Enter: set value",
_ => " Q: exit, W: save, Arrows: select, Space: open, Enter: edit",
};
status_bar( status_bar(
Color::Rgb(0, 0, 0), Color::Rgb(0, 0, 0),
Color::Rgb(192, 192, 192), Color::Rgb(192, 192, 192),
Fill::x(Bsp::a( Fill::x(Bsp::a(
Fill::x(Align::w(Tui::bold(true, match self.mode { Fill::x(Align::w(Tui::bold(true, Bsp::e(mode, help)))),
Some(Mode::Edit { .. }) => {
Bsp::e(
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
" Esc: cancel, Enter: set value"
)
},
_ => Bsp::e(
Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE ")),
" Q: exit, Arrows: select, Space: open, Enter: edit"
)
}))),
Fill::x(Align::e(size)), Fill::x(Align::e(size)),
)) ))
) )