mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Replace SelectView::focus
with selected_id
Returns None if the list is empty. Also add `SelectView::len`
This commit is contained in:
parent
16dea393c9
commit
484f81861a
@ -240,7 +240,22 @@ impl<T: 'static> SelectView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the id of the item currently selected.
|
/// Returns the id of the item currently selected.
|
||||||
pub fn focus(&self) -> usize {
|
///
|
||||||
|
/// Returns `None` if the list is empty.
|
||||||
|
pub fn selected_id(&self) -> Option<usize> {
|
||||||
|
if self.items.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(self.focus())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the number of items in this list.
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
self.items.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn focus(&self) -> usize {
|
||||||
self.focus.get()
|
self.focus.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user