mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
mode indicator
This commit is contained in:
parent
acc2ce0ca2
commit
26d05e544b
3 changed files with 25 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
16
src/view.rs
16
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<TuiOut> for Taggart {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
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)))))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ impl<'a> Content<TuiOut> 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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue