mirror of
https://github.com/FliegendeWurst/inboxid.git
synced 2024-11-22 00:45:01 +00:00
browse: workaround ScrollView issues
This commit is contained in:
parent
39a63ad966
commit
636e103303
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
use std::{cell::RefCell, cmp, collections::{HashMap, HashSet}, env, fmt::Display, io, sync::Arc};
|
use std::{cell::RefCell, cmp, collections::{HashMap, HashSet}, env, fmt::Display, io, sync::Arc};
|
||||||
|
|
||||||
use cursive::{Cursive, CursiveExt, Vec2};
|
use cursive::{Cursive, Vec2};
|
||||||
use cursive::align::HAlign;
|
use cursive::align::HAlign;
|
||||||
use cursive::event::{Event, Key};
|
use cursive::event::{Event, Key};
|
||||||
use cursive::traits::Identifiable;
|
use cursive::traits::Identifiable;
|
||||||
use cursive::view::{Scrollable, ScrollStrategy, SizeConstraint, View};
|
use cursive::view::{Scrollable, SizeConstraint, View};
|
||||||
use cursive::views::{Checkbox, LinearLayout, OnEventView, Panel, ResizedView, SelectView, TextView};
|
use cursive::views::{Checkbox, LinearLayout, NamedView, OnEventView, Panel, ResizedView, ScrollView, SelectView, TextView};
|
||||||
use cursive_tree_view::{Placement, TreeEntry, TreeView};
|
use cursive_tree_view::{Placement, TreeEntry, TreeView};
|
||||||
use inboxid::*;
|
use inboxid::*;
|
||||||
use io::Write;
|
use io::Write;
|
||||||
@ -221,12 +221,10 @@ fn show_listing(mailbox: &str) -> Result<()> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tree.set_on_select(tree_on_select);
|
|
||||||
tree.set_on_submit(|siv, _row| {
|
tree.set_on_submit(|siv, _row| {
|
||||||
siv.focus_name("mail").unwrap();
|
siv.focus_name("mail").unwrap();
|
||||||
});
|
});
|
||||||
let mut tree = tree.with_name("tree").scrollable();
|
let tree = tree.on_select(tree_on_select).with_name("tree").scrollable().with_name("tree_scroller");
|
||||||
tree.set_scroll_strategy(ScrollStrategy::StickToBottom);
|
|
||||||
let update_flags2 = Arc::clone(&update_flags);
|
let update_flags2 = Arc::clone(&update_flags);
|
||||||
let update_flags3 = Arc::clone(&update_flags);
|
let update_flags3 = Arc::clone(&update_flags);
|
||||||
let tree = OnEventView::new(tree)
|
let tree = OnEventView::new(tree)
|
||||||
@ -330,7 +328,16 @@ fn show_listing(mailbox: &str) -> Result<()> {
|
|||||||
|
|
||||||
siv.add_global_callback('q', |s| s.quit());
|
siv.add_global_callback('q', |s| s.quit());
|
||||||
|
|
||||||
siv.run();
|
// manual event loop (to scroll to end of ScrollView)
|
||||||
|
let mut siv = siv.into_runner(cursive::backends::termion::Backend::init()?);
|
||||||
|
siv.refresh();
|
||||||
|
siv.call_on_name("tree_scroller", |tree: &mut ScrollView<NamedView<MailTreeView>>| {
|
||||||
|
tree.on_event(Event::Key(Key::End))
|
||||||
|
}).unwrap().process(&mut siv);
|
||||||
|
siv.refresh();
|
||||||
|
while siv.is_running() {
|
||||||
|
siv.step();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user