mx-bookmarks

A small bookmarks tui based on the matrix protocol and MSC2771
git clone git://archive.git.mtrnord.blog/MTRNord/mx-bookmarks.git
Log | Files | Refs | LICENSE

tui_utils.rs (472B)


      1 pub struct TabsState<'a> {
      2     pub titles: Vec<&'a str>,
      3     pub index: usize,
      4 }
      5 
      6 impl<'a> TabsState<'a> {
      7     pub fn new(titles: Vec<&'a str>) -> TabsState {
      8         TabsState { titles, index: 0 }
      9     }
     10     pub fn next(&mut self) {
     11         self.index = (self.index + 1) % self.titles.len();
     12     }
     13 
     14     pub fn previous(&mut self) {
     15         if self.index > 0 {
     16             self.index -= 1;
     17         } else {
     18             self.index = self.titles.len() - 1;
     19         }
     20     }
     21 }