mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
add value bar
This commit is contained in:
parent
2ebf2c6cef
commit
41b6a0cd57
6 changed files with 64 additions and 39 deletions
68
src/view.rs
68
src/view.rs
|
|
@ -2,8 +2,7 @@ use crate::*;
|
|||
pub(crate) use tengri::tui::ratatui::style::Color;//, Style}, prelude::Stylize};
|
||||
pub(crate) use pad::PadStr;
|
||||
|
||||
mod status; pub use self::status::*;
|
||||
mod table; pub use self::table::*;
|
||||
mod table; pub use self::table::*;
|
||||
|
||||
impl Taggart {
|
||||
pub(crate) const FG_BROWSE: Color = Color::Rgb(255, 192, 0);
|
||||
|
|
@ -14,27 +13,58 @@ impl Taggart {
|
|||
|
||||
impl Content<TuiOut> for Taggart {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let sizer = Fill::xy(&self.display);
|
||||
let size = format!("{}x{}", self.display.w(), self.display.h());
|
||||
let titlebar = status_bar(Align::w(self.columns.header()));
|
||||
let size_bar = status_bar(Fill::x(Bsp::a(
|
||||
Fill::x(Align::w(Tui::bold(true, if self.editing.is_some() {
|
||||
Bsp::e(
|
||||
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
|
||||
" Esc: cancel, Enter: set value"
|
||||
let size = format!("{}x{}", self.display.w(), self.display.h());
|
||||
let sizer = Fill::xy(&self.display);
|
||||
let titlebar = status_bar(
|
||||
Color::Rgb(0, 0, 0),
|
||||
Color::Rgb(192, 192, 192),
|
||||
Align::w(self.columns.header())
|
||||
);
|
||||
let value_bar = status_bar(
|
||||
Color::Rgb(192, 192, 192),
|
||||
Color::Rgb(0, 0, 0),
|
||||
Fill::x(Align::w(format!(" {}/{} ", self.cursor + 1, self.entries.len())))
|
||||
);
|
||||
let mode_bar = status_bar(
|
||||
Color::Rgb(0, 0, 0),
|
||||
Color::Rgb(192, 192, 192),
|
||||
Fill::x(Bsp::a(
|
||||
Fill::x(Align::w(Tui::bold(true, if self.editing.is_some() {
|
||||
Bsp::e(
|
||||
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
|
||||
" Esc: cancel, Enter: set value"
|
||||
)
|
||||
} else {
|
||||
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)),
|
||||
))
|
||||
);
|
||||
Bsp::n(
|
||||
value_bar,
|
||||
Bsp::n(
|
||||
mode_bar,
|
||||
Bsp::s(
|
||||
titlebar,
|
||||
Bsp::b(
|
||||
sizer,
|
||||
Fill::xy(TreeTable(self))
|
||||
)
|
||||
)
|
||||
} else {
|
||||
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)),
|
||||
)));
|
||||
Bsp::n(size_bar, Bsp::s(titlebar, Bsp::b(sizer, Fill::xy(TreeTable(self)))))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status_bar (
|
||||
fg: Color, bg: Color, content: impl Content<TuiOut>
|
||||
) -> impl Content<TuiOut> {
|
||||
Fixed::y(1, Fill::x(Tui::bold(true, Tui::fg_bg(fg, bg, content))))
|
||||
}
|
||||
|
||||
impl Entry {
|
||||
pub const ICON_DIRECTORY: &'static str = "";
|
||||
pub const ICON_IMAGE: &'static str = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue