diff --git a/crates/nu-explore/src/pager/mod.rs b/crates/nu-explore/src/pager/mod.rs index 41d4f3510e..e71e8ca5db 100644 --- a/crates/nu-explore/src/pager/mod.rs +++ b/crates/nu-explore/src/pager/mod.rs @@ -742,10 +742,6 @@ fn handle_exit_key_event(key: &KeyEvent) -> bool { matches!( key, KeyEvent { - code: KeyCode::Char('d'), - modifiers: KeyModifiers::CONTROL, - .. - } | KeyEvent { code: KeyCode::Char('z'), modifiers: KeyModifiers::CONTROL, .. diff --git a/crates/nu-explore/src/views/record/mod.rs b/crates/nu-explore/src/views/record/mod.rs index 20e5b47bb1..cfd640aca4 100644 --- a/crates/nu-explore/src/views/record/mod.rs +++ b/crates/nu-explore/src/views/record/mod.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use std::collections::HashMap; -use crossterm::event::{KeyCode, KeyEvent}; +use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; use nu_color_config::{get_color_map, StyleComputer}; use nu_protocol::{ engine::{EngineState, Stack}, @@ -451,6 +451,36 @@ impl<'a> RecordLayer<'a> { } fn handle_key_event_view_mode(view: &mut RecordView, key: &KeyEvent) -> Option { + match key { + KeyEvent { + code: KeyCode::Char('u'), + modifiers: KeyModifiers::CONTROL, + .. + } + | KeyEvent { + code: KeyCode::PageUp, + .. + } => { + view.get_layer_last_mut().cursor.prev_row_page(); + + return Some(Transition::Ok); + } + KeyEvent { + code: KeyCode::Char('d'), + modifiers: KeyModifiers::CONTROL, + .. + } + | KeyEvent { + code: KeyCode::PageDown, + .. + } => { + view.get_layer_last_mut().cursor.next_row_page(); + + return Some(Transition::Ok); + } + _ => {} + } + match key.code { KeyCode::Esc => { if view.layer_stack.len() > 1 { @@ -473,42 +503,32 @@ fn handle_key_event_view_mode(view: &mut RecordView, key: &KeyEvent) -> Option Some(Transition::Cmd(String::from("expand"))), - KeyCode::Up => { + KeyCode::Up | KeyCode::Char('k') => { view.get_layer_last_mut().cursor.prev_row_i(); Some(Transition::Ok) } - KeyCode::Down => { + KeyCode::Down | KeyCode::Char('j') => { view.get_layer_last_mut().cursor.next_row_i(); Some(Transition::Ok) } - KeyCode::Left => { + KeyCode::Left | KeyCode::Char('h') => { view.get_layer_last_mut().cursor.prev_column_i(); Some(Transition::Ok) } - KeyCode::Right => { + KeyCode::Right | KeyCode::Char('l') => { view.get_layer_last_mut().cursor.next_column_i(); Some(Transition::Ok) } - KeyCode::PageUp => { - view.get_layer_last_mut().cursor.prev_row_page(); - - Some(Transition::Ok) - } - KeyCode::PageDown => { - view.get_layer_last_mut().cursor.next_row_page(); - - Some(Transition::Ok) - } - KeyCode::Home => { + KeyCode::Home | KeyCode::Char('g') => { view.get_layer_last_mut().cursor.row_move_to_start(); Some(Transition::Ok) } - KeyCode::End => { + KeyCode::End | KeyCode::Char('G') => { view.get_layer_last_mut().cursor.row_move_to_end(); Some(Transition::Ok) @@ -518,48 +538,68 @@ fn handle_key_event_view_mode(view: &mut RecordView, key: &KeyEvent) -> Option Option { + match key { + KeyEvent { + code: KeyCode::Char('u'), + modifiers: KeyModifiers::CONTROL, + .. + } + | KeyEvent { + code: KeyCode::PageUp, + .. + } => { + view.get_layer_last_mut().cursor.prev_row_page(); + + return Some(Transition::Ok); + } + KeyEvent { + code: KeyCode::Char('d'), + modifiers: KeyModifiers::CONTROL, + .. + } + | KeyEvent { + code: KeyCode::PageDown, + .. + } => { + view.get_layer_last_mut().cursor.next_row_page(); + + return Some(Transition::Ok); + } + _ => {} + } + match key.code { KeyCode::Esc => { view.set_view_mode(); Some(Transition::Ok) } - KeyCode::Up => { + KeyCode::Up | KeyCode::Char('k') => { view.get_layer_last_mut().cursor.prev_row(); Some(Transition::Ok) } - KeyCode::Down => { + KeyCode::Down | KeyCode::Char('j') => { view.get_layer_last_mut().cursor.next_row(); Some(Transition::Ok) } - KeyCode::Left => { + KeyCode::Left | KeyCode::Char('h') => { view.get_layer_last_mut().cursor.prev_column(); Some(Transition::Ok) } - KeyCode::Right => { + KeyCode::Right | KeyCode::Char('l') => { view.get_layer_last_mut().cursor.next_column(); Some(Transition::Ok) } - KeyCode::PageUp => { - view.get_layer_last_mut().cursor.prev_row_page(); - - Some(Transition::Ok) - } - KeyCode::PageDown => { - view.get_layer_last_mut().cursor.next_row_page(); - - Some(Transition::Ok) - } - KeyCode::Home => { + KeyCode::Home | KeyCode::Char('g') => { view.get_layer_last_mut().cursor.row_move_to_start(); Some(Transition::Ok) } - KeyCode::End => { + KeyCode::End | KeyCode::Char('G') => { view.get_layer_last_mut().cursor.row_move_to_end(); Some(Transition::Ok)