mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
refactor mode indicators
This commit is contained in:
parent
52102d771d
commit
f571b079b1
1 changed files with 17 additions and 12 deletions
29
src/view.rs
29
src/view.rs
|
|
@ -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)),
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue