summaryrefslogtreecommitdiffstats
path: root/src/tui/views.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui/views.rs')
-rw-r--r--src/tui/views.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tui/views.rs b/src/tui/views.rs
index 0e7971d..ef96a6a 100644
--- a/src/tui/views.rs
+++ b/src/tui/views.rs
@@ -155,6 +155,10 @@ impl ListView {
view.with_name(name)
}
+ pub fn get_current_selection(&mut self) -> Option<u32> {
+ self.call_on_inner(|sv| sv.selection().as_deref().copied())
+ }
+
pub fn reset_with_all<S, I>(&mut self, iter: I) -> Callback
where
S: Into<StyledString>,
@@ -399,6 +403,23 @@ impl LayoutView {
.expect("call on md view failed")
}
+ // There may be no questions and there may be no answers? There should be answers but w/e
+ pub fn get_focused_ids(&mut self) -> Option<(u32, Option<u32>)> {
+ let curr_question = self
+ .view
+ .call_on_name(NAME_QUESTION_LIST, |v: &mut ListView| {
+ v.get_current_selection()
+ })
+ .flatten()?;
+ let curr_answer = self
+ .view
+ .call_on_name(NAME_ANSWER_LIST, |v: &mut ListView| {
+ v.get_current_selection()
+ })
+ .flatten();
+ Some((curr_question, curr_answer))
+ }
+
fn get_constraints(&self, screen_size: Vec2) -> LayoutViewSizing {
let heuristic = 1;
let width = SizeConstraint::Fixed(screen_size.x / 2 - heuristic);