refactor(tui): use more intuitive direction for section scroll

This commit is contained in:
Orhun Parmaksız 2022-02-07 19:27:58 +03:00
parent 9c2383ad9d
commit 99c2394345
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
3 changed files with 10 additions and 10 deletions

View file

@ -267,8 +267,8 @@ impl<'a> App<'a> {
}
Command::Scroll(ScrollArea::Section, direction, _) => {
match direction {
Direction::Up => self.section_list.previous(),
_ => self.section_list.next(),
Direction::Right => self.section_list.next(),
_ => self.section_list.previous(),
}
self.search();
if self.parameter_list.items.is_empty() {

View file

@ -86,8 +86,8 @@ impl Command {
Key::Char('b') => Command::Scroll(ScrollArea::List, Direction::Bottom, 0),
Key::Left => Command::Scroll(ScrollArea::Documentation, Direction::Up, 1),
Key::Right => Command::Scroll(ScrollArea::Documentation, Direction::Down, 1),
Key::Char('`') => Command::Scroll(ScrollArea::Section, Direction::Up, 1),
Key::Char('\t') => Command::Scroll(ScrollArea::Section, Direction::Down, 1),
Key::Char('`') => Command::Scroll(ScrollArea::Section, Direction::Left, 1),
Key::Char('\t') => Command::Scroll(ScrollArea::Section, Direction::Right, 1),
Key::Char(':') => Command::UpdateInput(' '),
Key::Char('/') => Command::Search,
Key::Char('\n') => Command::Select,
@ -164,8 +164,8 @@ mod tests {
Key::Char('b') => Command::Scroll(ScrollArea::List, Direction::Bottom, 0),
Key::Left => Command::Scroll(ScrollArea::Documentation, Direction::Up, 1),
Key::Right => Command::Scroll(ScrollArea::Documentation, Direction::Down, 1),
Key::Char('`') => Command::Scroll(ScrollArea::Section, Direction::Up, 1),
Key::Char('\t') => Command::Scroll(ScrollArea::Section, Direction::Down, 1),
Key::Char('`') => Command::Scroll(ScrollArea::Section, Direction::Left, 1),
Key::Char('\t') => Command::Scroll(ScrollArea::Section, Direction::Right, 1),
Key::Char(':') => Command::UpdateInput(' '),
Key::Char('/') => Command::Search,
Key::Char('\n') => Command::Select,

View file

@ -203,8 +203,8 @@ fn test_render_tui() -> Result<()> {
thread::sleep(Duration::from_millis(2000));
app.tick();
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Up, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Up, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Left, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Left, 1))?;
terminal.draw(|frame| render(frame, &mut app))?;
assert_buffer(
Buffer::with_lines(vec![
@ -221,8 +221,8 @@ fn test_render_tui() -> Result<()> {
]),
terminal.backend(),
)?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Down, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Down, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Right, 1))?;
app.run_command(Command::Scroll(ScrollArea::Section, Direction::Right, 1))?;
app.input = Some(String::new());
app.run_command(Command::Search)?;