diff --git a/src/keys.rs b/src/keys.rs index 7001ff2..58cd260 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -80,7 +80,7 @@ impl Taggart { self.editing = None; } pub fn edit_confirm (&mut self) { - if let Some((edit_index, value)) = &self.editing + if let Some((_edit_index, value)) = &self.editing && let Some(column) = self.columns.0.get(self.column) && let Some(setter) = &column.setter && let Some(entry) = self.paths.get_mut(self.cursor) diff --git a/src/view.rs b/src/view.rs index 6a24f8c..0db0a64 100644 --- a/src/view.rs +++ b/src/view.rs @@ -5,12 +5,26 @@ pub(crate) use pad::PadStr; mod status; pub use self::status::*; mod table; pub use self::table::*; +impl Taggart { + pub(crate) const FG_BROWSE: Color = Color::Rgb(255, 192, 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 FG_EDIT: Color = Color::Rgb(255, 255, 255); +} + impl Content for Taggart { fn content (&self) -> impl Render { let sizer = Fill::xy(&self.size); let size = format!("{}x{}", self.size.w(), self.size.h()); - let size_bar = status_bar(Align::e(size)); 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() { + Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")) + } else { + Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE ")) + }))), + Fill::x(Align::e(size)), + ))); Bsp::n(size_bar, Bsp::s(titlebar, Bsp::b(sizer, Fill::xy(TreeTable(self))))) } } diff --git a/src/view/table.rs b/src/view/table.rs index 4e7ae5d..c24735e 100644 --- a/src/view/table.rs +++ b/src/view/table.rs @@ -14,12 +14,12 @@ impl<'a> Content for TreeTable<'a> { } impl<'a> TreeTable<'a> { - const BG_COLUMN: Color = Color::Rgb(0, 0, 0); - const FG_ROW: Color = Color::Rgb(0, 0, 0); - const BG_ROW: Color = Color::Rgb(192, 128, 0); - const BG_CELL: Color = Color::Rgb(224, 192, 0); - const BG_EDIT: Color = Color::Rgb(48, 96, 0); - const FG_EDIT: Color = Color::Rgb(255, 255, 255); + pub(crate) const BG_COLUMN: Color = Color::Rgb(0, 0, 0); + pub(crate) const FG_ROW: Color = Color::Rgb(0, 0, 0); + pub(crate) const BG_ROW: Color = Color::Rgb(192, 128, 0); + pub(crate) const BG_CELL: Color = Color::Rgb(224, 192, 0); + pub(crate) const BG_EDIT: Color = Color::Rgb(48, 96, 0); + pub(crate) const FG_EDIT: Color = Color::Rgb(255, 255, 255); fn rows (&self, to: &mut TuiOut, area: [u16;4], active_x: u16, active_w: u16) { for (row_index, row_y) in area.iter_y().enumerate() { let row_index_scrolled = row_index + self.0.offset; @@ -32,7 +32,7 @@ impl<'a> TreeTable<'a> { to.area[1] = row_y; if selected { Self::row_cursor(to, area.x(), row_y, area.w()); - self.cell_cursor(to, area.x(), active_x, column_x, row_y, active_w); + self.cell_cursor(to, area.x(), active_x, row_y, active_w); } self.row_data(to, entry, row_index_scrolled, &mut column_x); } @@ -50,14 +50,14 @@ impl<'a> TreeTable<'a> { to.fill_fg(fill, Self::FG_ROW); to.fill_bg(fill, Self::BG_ROW); } - fn cell_cursor (&self, to: &mut TuiOut, xa: u16, x0: u16, x: u16, y: u16, w: u16) { + fn cell_cursor (&self, to: &mut TuiOut, xa: u16, x0: u16, y: u16, w: u16) { let fill = [xa + x0, y, w, 1]; to.fill_bg(fill, Self::BG_CELL); } fn row_data (&self, to: &mut TuiOut, entry: &Entry, row: usize, x: &mut u16) { for (column_index, Column { width, getter, .. }) in self.0.columns.0.iter().enumerate() { to.area[0] = *x; - if let Some((edit_index, value)) = self.0.editing.as_ref() + if let Some((_edit_index, value)) = self.0.editing.as_ref() && self.0.column == column_index && self.0.cursor == row {