mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add SelectView::set_selection
This commit is contained in:
parent
09202f55c8
commit
7c95114955
@ -275,6 +275,13 @@ impl<T: 'static> SelectView<T> {
|
||||
self.focus.get()
|
||||
}
|
||||
|
||||
/// Moves the selection to the given position.
|
||||
pub fn set_selection(&mut self, i: usize) {
|
||||
// TODO: Check if `i > self.len()` ?
|
||||
self.focus.set(i);
|
||||
self.scrollbase.scroll_to(i);
|
||||
}
|
||||
|
||||
fn focus_up(&mut self, n: usize) {
|
||||
let focus = self.focus();
|
||||
let n = min(focus, n);
|
||||
|
Loading…
Reference in New Issue
Block a user