pub struct TabsState<T: ToString + Default + Copy> { /* private fields */ }
Implementations§
Source§impl<T: ToString + Default + Copy> TabsState<T>
impl<T: ToString + Default + Copy> TabsState<T>
Source§impl<T: ToString + Default + Copy> TabsState<T>
impl<T: ToString + Default + Copy> TabsState<T>
Sourcepub fn next(&mut self)
pub fn next(&mut self)
Examples found in repository?
examples/basic.rs (line 84)
75 fn run(mut self, terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> io::Result<()> {
76 loop {
77 terminal.draw(|frame| frame.render_widget(&mut self, frame.area()))?;
78
79 if event::poll(Duration::from_millis(10))? {
80 if let Event::Key(key) = event::read()? {
81 match key.code {
82 KeyCode::Char('q') => break,
83 KeyCode::Char('h') => self.tabs_state.prev(),
84 KeyCode::Char('l') => self.tabs_state.next(),
85 KeyCode::Char('1') => self.tabs_state.set(1),
86 KeyCode::Char('2') => self.tabs_state.set(2),
87 KeyCode::Char('3') => self.tabs_state.set(3),
88 _ => (),
89 }
90 }
91 }
92 }
93
94 Ok(())
95 }
Sourcepub fn prev(&mut self)
pub fn prev(&mut self)
Examples found in repository?
examples/basic.rs (line 83)
75 fn run(mut self, terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> io::Result<()> {
76 loop {
77 terminal.draw(|frame| frame.render_widget(&mut self, frame.area()))?;
78
79 if event::poll(Duration::from_millis(10))? {
80 if let Event::Key(key) = event::read()? {
81 match key.code {
82 KeyCode::Char('q') => break,
83 KeyCode::Char('h') => self.tabs_state.prev(),
84 KeyCode::Char('l') => self.tabs_state.next(),
85 KeyCode::Char('1') => self.tabs_state.set(1),
86 KeyCode::Char('2') => self.tabs_state.set(2),
87 KeyCode::Char('3') => self.tabs_state.set(3),
88 _ => (),
89 }
90 }
91 }
92 }
93
94 Ok(())
95 }
Sourcepub fn set(&mut self, idx: usize)
pub fn set(&mut self, idx: usize)
Examples found in repository?
examples/basic.rs (line 85)
75 fn run(mut self, terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> io::Result<()> {
76 loop {
77 terminal.draw(|frame| frame.render_widget(&mut self, frame.area()))?;
78
79 if event::poll(Duration::from_millis(10))? {
80 if let Event::Key(key) = event::read()? {
81 match key.code {
82 KeyCode::Char('q') => break,
83 KeyCode::Char('h') => self.tabs_state.prev(),
84 KeyCode::Char('l') => self.tabs_state.next(),
85 KeyCode::Char('1') => self.tabs_state.set(1),
86 KeyCode::Char('2') => self.tabs_state.set(2),
87 KeyCode::Char('3') => self.tabs_state.set(3),
88 _ => (),
89 }
90 }
91 }
92 }
93
94 Ok(())
95 }
pub fn current(&self) -> T
Auto Trait Implementations§
impl<T> Freeze for TabsState<T>
impl<T> RefUnwindSafe for TabsState<T>where
T: RefUnwindSafe,
impl<T> Send for TabsState<T>where
T: Send,
impl<T> Sync for TabsState<T>where
T: Sync,
impl<T> Unpin for TabsState<T>where
T: Unpin,
impl<T> UnwindSafe for TabsState<T>where
T: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more