Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Improve table state in imUI
Erik Kundt committed 1 year ago
commit 6003535e4a93abc9b08a7ebcd8c72471491ec187
parent e2c99d7e309fce4f0907c1e63662e565f768f011
1 file changed +9 -0
modified src/ui/im.rs
@@ -628,6 +628,15 @@ pub mod widget {
        internal: ratatui::widgets::TableState,
    }

+
    impl<R> TableState<R> {
+
        pub fn selected_item(&self) -> Option<&R> {
+
            self.internal
+
                .selected()
+
                .as_ref()
+
                .and_then(|selected| self.items.get(*selected))
+
        }
+
    }
+

    impl<R> TableState<R>
    where
        R: Clone,