Scrolling help

This commit is contained in:
Ian Keane 2025-11-23 12:21:03 -05:00
parent eb7790ff8f
commit 857362b558
2 changed files with 118 additions and 34 deletions

View file

@ -60,6 +60,7 @@ pub struct App {
pub log_view_content: Vec<String>,
pub log_view_scroll: usize,
pub log_view_selected: usize,
pub help_scroll: usize,
pub clipboard: Option<arboard::Clipboard>,
pub status_message: Option<(String, std::time::Instant)>,
}
@ -97,6 +98,7 @@ impl App {
log_view_content: Vec::new(),
log_view_scroll: 0,
log_view_selected: 0,
help_scroll: 0,
clipboard: arboard::Clipboard::new().ok(),
status_message: None,
})
@ -141,7 +143,10 @@ impl App {
(KeyCode::Char('p'), KeyModifiers::CONTROL) => self.change_pane(-1),
(KeyCode::Enter, _) => self.toggle_current_item()?,
(KeyCode::Char('e'), KeyModifiers::CONTROL) => self.edit_config()?,
(KeyCode::Char('?'), _) => self.current_screen = Screen::Help,
(KeyCode::Char('?'), _) => {
self.help_scroll = 0;
self.current_screen = Screen::Help;
}
(KeyCode::Char('c'), _) => self.edit_app_config()?,
(KeyCode::Char('n'), _) => self.start_new_entry(),
(KeyCode::Char('p'), _) => self.start_reassign_project(),
@ -245,8 +250,26 @@ impl App {
fn handle_help_event(&mut self, event: Event) -> anyhow::Result<bool> {
match event {
Event::Key(KeyEvent { code, .. }) => match code {
KeyCode::Char('c') => self.current_screen = Screen::ConfigHelp,
KeyCode::Esc | KeyCode::Char('q') => self.current_screen = Screen::Main,
KeyCode::Char('c') => {
self.help_scroll = 0;
self.current_screen = Screen::ConfigHelp;
}
KeyCode::Char('j') | KeyCode::Down => {
self.help_scroll = self.help_scroll.saturating_add(1);
}
KeyCode::Char('k') | KeyCode::Up => {
self.help_scroll = self.help_scroll.saturating_sub(1);
}
KeyCode::PageDown => {
self.help_scroll = self.help_scroll.saturating_add(10);
}
KeyCode::PageUp => {
self.help_scroll = self.help_scroll.saturating_sub(10);
}
KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('?') => {
self.help_scroll = 0;
self.current_screen = Screen::Main;
}
_ => {}
},
_ => {}
@ -257,7 +280,22 @@ impl App {
fn handle_config_help_event(&mut self, event: Event) -> anyhow::Result<bool> {
match event {
Event::Key(KeyEvent { code, .. }) => match code {
KeyCode::Esc | KeyCode::Char('q') => self.current_screen = Screen::Help,
KeyCode::Char('j') | KeyCode::Down => {
self.help_scroll = self.help_scroll.saturating_add(1);
}
KeyCode::Char('k') | KeyCode::Up => {
self.help_scroll = self.help_scroll.saturating_sub(1);
}
KeyCode::PageDown => {
self.help_scroll = self.help_scroll.saturating_add(10);
}
KeyCode::PageUp => {
self.help_scroll = self.help_scroll.saturating_sub(10);
}
KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('?') => {
self.help_scroll = 0;
self.current_screen = Screen::Help;
}
_ => {}
},
_ => {}
@ -268,7 +306,20 @@ impl App {
fn handle_log_view_help_event(&mut self, event: Event) -> anyhow::Result<bool> {
match event {
Event::Key(KeyEvent { code, .. }) => match code {
KeyCode::Char('j') | KeyCode::Down => {
self.help_scroll = self.help_scroll.saturating_add(1);
}
KeyCode::Char('k') | KeyCode::Up => {
self.help_scroll = self.help_scroll.saturating_sub(1);
}
KeyCode::PageDown => {
self.help_scroll = self.help_scroll.saturating_add(10);
}
KeyCode::PageUp => {
self.help_scroll = self.help_scroll.saturating_sub(10);
}
KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('?') => {
self.help_scroll = 0;
self.current_screen = Screen::LogView;
}
_ => {}
@ -332,6 +383,7 @@ impl App {
self.needs_clear = true;
}
KeyCode::Char('?') => {
self.help_scroll = 0;
self.current_screen = Screen::LogViewHelp;
}
KeyCode::Char('d') => {