Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ cat report.md | mq-view --pager
| Key | Action |
| --- | --- |
| `j` / `k`, `↓` / `↑` | Scroll down / up |
| `Space` / `PageDown`, `PageUp` | Scroll a page down / up |
| `Ctrl-d` / `Ctrl-u` | Scroll half a page down / up |
| `g` / `G` | Jump to top / bottom |
| `Space` / `PageDown` / `f`, `PageUp` / `b` | Scroll a page down / up |
| `d` / `u` (with or without `Ctrl`) | Scroll half a page down / up |
| `g` / `Home`, `G` / `End` | Jump to top / bottom |
| `Tab` | Toggle the heading outline; `j`/`k` to move, `Enter` to jump |
| `/` | Search; `Enter` to confirm, `Esc` to cancel |
| `n` / `N` | Jump to the next / previous search match |
Expand Down
20 changes: 9 additions & 11 deletions src/pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use ratatui::Frame;
use ratatui::Terminal;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
use ratatui::crossterm::execute;
use ratatui::crossterm::terminal::{
self as crossterm_terminal, EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode,
Expand Down Expand Up @@ -330,18 +330,16 @@ fn handle_key(app: &mut App, key: KeyEvent, content_height: usize) -> bool {
KeyCode::Char('q') | KeyCode::Esc => return true,
KeyCode::Char('j') | KeyCode::Down => scroll_by(app, 1, content_height),
KeyCode::Char('k') | KeyCode::Up => scroll_by(app, -1, content_height),
KeyCode::Char(' ') | KeyCode::PageDown => {
KeyCode::Char(' ') | KeyCode::PageDown | KeyCode::Char('f') => {
scroll_by(app, content_height as isize, content_height)
}
KeyCode::PageUp => scroll_by(app, -(content_height as isize), content_height),
KeyCode::Char('d') if key.modifiers.contains(KeyModifiers::CONTROL) => {
scroll_by(app, (content_height / 2) as isize, content_height)
KeyCode::PageUp | KeyCode::Char('b') => {
scroll_by(app, -(content_height as isize), content_height)
}
KeyCode::Char('u') if key.modifiers.contains(KeyModifiers::CONTROL) => {
scroll_by(app, -((content_height as isize) / 2), content_height)
}
KeyCode::Char('g') => app.scroll = 0,
KeyCode::Char('G') => app.scroll = max_scroll(&app.doc, content_height),
KeyCode::Char('d') => scroll_by(app, (content_height / 2) as isize, content_height),
KeyCode::Char('u') => scroll_by(app, -((content_height as isize) / 2), content_height),
KeyCode::Char('g') | KeyCode::Home => app.scroll = 0,
KeyCode::Char('G') | KeyCode::End => app.scroll = max_scroll(&app.doc, content_height),
KeyCode::Tab => {
app.show_outline = true;
app.outline_state.select(nearest_heading_index(app));
Expand Down Expand Up @@ -475,7 +473,7 @@ fn draw_footer(frame: &mut Frame, area: Rect, app: &App, content_height: usize)
.split(area);
frame.render_widget(
Paragraph::new(
" q:quit j/k:scroll Tab:outline /:search n/N:next/prev match",
" q:quit j/k:scroll f/b/d/u:page g/G:top/bottom Tab:outline /:search n/N:next/prev match",
)
.style(Style::default().fg(Color::DarkGray)),
cols[0],
Expand Down