From 847fd7d800ebee5dd00ca8389d979192254bc79e Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sun, 11 Feb 2018 19:26:44 -0800 Subject: [PATCH] Add SelectView::selected --- src/views/select_view.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/views/select_view.rs b/src/views/select_view.rs index 5dd47ef..d6ce2f3 100644 --- a/src/views/select_view.rs +++ b/src/views/select_view.rs @@ -324,6 +324,13 @@ impl SelectView { self.scrollbase.scroll_to(i); } + /// Sets the selection to the given position. + /// + /// Chainable variant. + pub fn selected(self, i: usize) -> Self { + self.with(|s| s.set_selection(i)) + } + /// Moves the selection up by the given number of rows. pub fn select_up(&mut self, n: usize) { self.focus_up(n);