Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Fix columns / table rendering in imUI
Erik Kundt committed 1 year ago
commit ac9df0fa978c4d080323c4b6da480f3a8c8fa763
parent 77d8cb0caf2e890d78253b8e12f3005bb9f0a7ce
3 files changed +8 -13
modified src/lib.rs
@@ -15,9 +15,9 @@ use anyhow::Result;

use store::State;
use task::Interrupted;
+
use ui::im;
use ui::widget::Widget;
use ui::Frontend;
-
use ui::im;

/// An optional return value.
#[derive(Clone, Debug)]
modified src/ui.rs
@@ -1,9 +1,9 @@
pub mod ext;
+
pub mod im;
pub mod layout;
pub mod span;
pub mod theme;
pub mod widget;
-
pub mod im;

use std::fmt::Debug;
use std::time::Duration;
modified src/ui/im.rs
@@ -811,15 +811,8 @@ pub mod widget {
                .collect();

            if has_items {
-
                let [table_area, scroller_area] = Layout::horizontal([
-
                    Constraint::Min(1),
-
                    if show_scrollbar {
-
                        Constraint::Length(1)
-
                    } else {
-
                        Constraint::Length(0)
-
                    },
-
                ])
-
                .areas(area);
+
                let [table_area, scroller_area] =
+
                    Layout::horizontal([Constraint::Min(1), Constraint::Length(1)]).areas(area);

                let rows = self
                    .items
@@ -830,7 +823,7 @@ pub mod widget {

                        for cell in item.to_row() {
                            if let Some(col) = it.next() {
-
                                if !col.skip && col.displayed(area.width as usize) {
+
                                if !col.skip && col.displayed(table_area.width as usize) {
                                    cells.push(cell.clone())
                                }
                            } else {
@@ -997,11 +990,13 @@ pub mod widget {
            let cells = self
                .columns
                .iter()
+
                .filter(|c| !c.skip && c.displayed(area.width as usize))
                .map(|c| c.text.clone())
                .collect::<Vec<_>>();

            let table = ratatui::widgets::Table::default()
-
                .header(Row::new(cells))
+
                .column_spacing(1)
+
                .rows([Row::new(cells)])
                .widths(widths);
            frame.render_widget(table, area);