Add Home/End navigation to text views.

This commit is contained in:
Alexandre Bury 2015-05-28 17:48:21 -07:00
parent 8ee04c525f
commit e07a0319f2

View File

@ -207,6 +207,8 @@ impl View for TextView {
} }
match event { match event {
Event::KeyEvent(Key::Home) => self.start_line = 0,
Event::KeyEvent(Key::End) => self.start_line = self.rows.len() - self.view_height,
Event::KeyEvent(Key::Up) if self.start_line > 0 => self.start_line -= 1, Event::KeyEvent(Key::Up) if self.start_line > 0 => self.start_line -= 1,
Event::KeyEvent(Key::Down) if self.start_line+self.view_height < self.rows.len() => self.start_line += 1, Event::KeyEvent(Key::Down) if self.start_line+self.view_height < self.rows.len() => self.start_line += 1,
Event::KeyEvent(Key::PageDown) => self.start_line = min(self.start_line+10, self.rows.len()-self.view_height), Event::KeyEvent(Key::PageDown) => self.start_line = min(self.start_line+10, self.rows.len()-self.view_height),