Struct ratatui::widgets::TableState
source · pub struct TableState { /* private fields */ }
Implementations§
source§impl TableState
impl TableState
pub fn offset(&self) -> usize
pub fn offset_mut(&mut self) -> &mut usize
pub fn with_selected(self, selected: Option<usize>) -> Self
pub fn with_offset(self, offset: usize) -> Self
sourcepub fn selected(&self) -> Option<usize>
pub fn selected(&self) -> Option<usize>
Examples found in repository?
examples/table.rs (line 48)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
pub fn next(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i >= self.items.len() - 1 {
0
} else {
i + 1
}
}
None => 0,
};
self.state.select(Some(i));
}
pub fn previous(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
self.items.len() - 1
} else {
i - 1
}
}
None => 0,
};
self.state.select(Some(i));
}
sourcepub fn select(&mut self, index: Option<usize>)
pub fn select(&mut self, index: Option<usize>)
Examples found in repository?
examples/table.rs (line 58)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
pub fn next(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i >= self.items.len() - 1 {
0
} else {
i + 1
}
}
None => 0,
};
self.state.select(Some(i));
}
pub fn previous(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
self.items.len() - 1
} else {
i - 1
}
}
None => 0,
};
self.state.select(Some(i));
}
Trait Implementations§
source§impl Clone for TableState
impl Clone for TableState
source§fn clone(&self) -> TableState
fn clone(&self) -> TableState
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TableState
impl Debug for TableState
source§impl Default for TableState
impl Default for TableState
source§fn default() -> TableState
fn default() -> TableState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for TableState
impl Send for TableState
impl Sync for TableState
impl Unpin for TableState
impl UnwindSafe for TableState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more