mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-27 14:34:32 +03:00
commit
19fc0496a3
@ -174,6 +174,10 @@ keybinds:
|
||||
key: [Char: 'j', Down,]
|
||||
- action: [ScrollUp,]
|
||||
key: [Char: 'k', Up,]
|
||||
- action: [PageScrollDown,]
|
||||
key: [Ctrl: 'f', PageDown,]
|
||||
- action: [PageScrollUp,]
|
||||
key: [Ctrl: 'b', PageUp,]
|
||||
- action: [NewPane: ,]
|
||||
key: [ Alt: 'n',]
|
||||
- action: [MoveFocus: Left,]
|
||||
|
@ -2174,6 +2174,30 @@ impl Tab {
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn scroll_active_terminal_up_page(&mut self) {
|
||||
if let Some(active_terminal_id) = self.get_active_terminal_id() {
|
||||
let active_terminal = self
|
||||
.panes
|
||||
.get_mut(&PaneId::Terminal(active_terminal_id))
|
||||
.unwrap();
|
||||
// prevent overflow when row == 0
|
||||
let scroll_columns = active_terminal.rows().max(1) - 1;
|
||||
active_terminal.scroll_up(scroll_columns);
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn scroll_active_terminal_down_page(&mut self) {
|
||||
if let Some(active_terminal_id) = self.get_active_terminal_id() {
|
||||
let active_terminal = self
|
||||
.panes
|
||||
.get_mut(&PaneId::Terminal(active_terminal_id))
|
||||
.unwrap();
|
||||
// prevent overflow when row == 0
|
||||
let scroll_columns = active_terminal.rows().max(1) - 1;
|
||||
active_terminal.scroll_down(scroll_columns);
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn clear_active_terminal_scroll(&mut self) {
|
||||
if let Some(active_terminal_id) = self.get_active_terminal_id() {
|
||||
let active_terminal = self
|
||||
|
@ -196,6 +196,8 @@ pub enum ScreenContext {
|
||||
Quit,
|
||||
ScrollUp,
|
||||
ScrollDown,
|
||||
PageScrollUp,
|
||||
PageScrollDown,
|
||||
ClearScroll,
|
||||
CloseFocusedPane,
|
||||
ToggleActiveTerminalFullscreen,
|
||||
@ -238,6 +240,8 @@ impl From<&ScreenInstruction> for ScreenContext {
|
||||
ScreenInstruction::Quit => ScreenContext::Quit,
|
||||
ScreenInstruction::ScrollUp => ScreenContext::ScrollUp,
|
||||
ScreenInstruction::ScrollDown => ScreenContext::ScrollDown,
|
||||
ScreenInstruction::PageScrollUp => ScreenContext::PageScrollUp,
|
||||
ScreenInstruction::PageScrollDown => ScreenContext::PageScrollDown,
|
||||
ScreenInstruction::ClearScroll => ScreenContext::ClearScroll,
|
||||
ScreenInstruction::CloseFocusedPane => ScreenContext::CloseFocusedPane,
|
||||
ScreenInstruction::ToggleActiveTerminalFullscreen => {
|
||||
|
@ -33,6 +33,10 @@ pub enum Action {
|
||||
ScrollUp,
|
||||
/// Scroll down in focus pane.
|
||||
ScrollDown,
|
||||
/// Scroll up one page in focus pane.
|
||||
PageScrollUp,
|
||||
/// Scroll down one page in focus pane.
|
||||
PageScrollDown,
|
||||
/// Toggle between fullscreen focus pane and normal layout.
|
||||
ToggleFocusFullscreen,
|
||||
/// Open a new pane in the specified direction (relative to focus).
|
||||
|
@ -184,6 +184,16 @@ impl InputHandler {
|
||||
.send(ScreenInstruction::ScrollDown)
|
||||
.unwrap();
|
||||
}
|
||||
Action::PageScrollUp => {
|
||||
self.send_screen_instructions
|
||||
.send(ScreenInstruction::PageScrollUp)
|
||||
.unwrap();
|
||||
}
|
||||
Action::PageScrollDown => {
|
||||
self.send_screen_instructions
|
||||
.send(ScreenInstruction::PageScrollDown)
|
||||
.unwrap();
|
||||
}
|
||||
Action::ToggleFocusFullscreen => {
|
||||
self.send_screen_instructions
|
||||
.send(ScreenInstruction::ToggleActiveTerminalFullscreen)
|
||||
@ -293,6 +303,7 @@ pub fn get_mode_info(mode: InputMode) -> ModeInfo {
|
||||
}
|
||||
InputMode::Scroll => {
|
||||
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
|
||||
keybinds.push(("PGUP/PGDN".to_string(), "Scroll Page".to_string()));
|
||||
}
|
||||
InputMode::RenameTab => {
|
||||
keybinds.push(("Enter".to_string(), "when done".to_string()));
|
||||
|
@ -340,6 +340,11 @@ impl Keybinds {
|
||||
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Ctrl('f'), vec![Action::PageScrollDown]);
|
||||
defaults.insert(Key::Ctrl('b'), vec![Action::PageScrollUp]);
|
||||
defaults.insert(Key::PageDown, vec![Action::PageScrollDown]);
|
||||
defaults.insert(Key::PageUp, vec![Action::PageScrollUp]);
|
||||
|
||||
defaults.insert(Key::Down, vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Up, vec![Action::ScrollUp]);
|
||||
|
||||
|
@ -369,6 +369,18 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||
.unwrap()
|
||||
.scroll_active_terminal_down();
|
||||
}
|
||||
ScreenInstruction::PageScrollUp => {
|
||||
screen
|
||||
.get_active_tab_mut()
|
||||
.unwrap()
|
||||
.scroll_active_terminal_up_page();
|
||||
}
|
||||
ScreenInstruction::PageScrollDown => {
|
||||
screen
|
||||
.get_active_tab_mut()
|
||||
.unwrap()
|
||||
.scroll_active_terminal_down_page();
|
||||
}
|
||||
ScreenInstruction::ClearScroll => {
|
||||
screen
|
||||
.get_active_tab_mut()
|
||||
|
@ -38,6 +38,8 @@ pub enum ScreenInstruction {
|
||||
Quit,
|
||||
ScrollUp,
|
||||
ScrollDown,
|
||||
PageScrollUp,
|
||||
PageScrollDown,
|
||||
ClearScroll,
|
||||
CloseFocusedPane,
|
||||
ToggleActiveTerminalFullscreen,
|
||||
|
@ -3,8 +3,9 @@ use ::insta::assert_snapshot;
|
||||
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::commands::{
|
||||
PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, SCROLL_MODE, SCROLL_UP_IN_SCROLL_MODE,
|
||||
SPAWN_TERMINAL_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, SCROLL_MODE, SCROLL_PAGE_DOWN_IN_SCROLL_MODE,
|
||||
SCROLL_PAGE_UP_IN_SCROLL_MODE, SCROLL_UP_IN_SCROLL_MODE, SPAWN_TERMINAL_IN_PANE_MODE,
|
||||
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
|
||||
};
|
||||
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
|
||||
@ -237,6 +238,67 @@ pub fn scrolling_down_inside_a_pane() {
|
||||
assert_snapshot!(snapshot_before_quit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn scrolling_page_up_inside_a_pane() {
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
&PANE_MODE,
|
||||
&SPLIT_DOWN_IN_PANE_MODE,
|
||||
&SPLIT_RIGHT_IN_PANE_MODE,
|
||||
&SCROLL_MODE,
|
||||
&SCROLL_PAGE_UP_IN_SCROLL_MODE,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
let output_frames = fake_input_output
|
||||
.stdout_writer
|
||||
.output_frames
|
||||
.lock()
|
||||
.unwrap();
|
||||
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
||||
let snapshot_before_quit =
|
||||
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
||||
assert_snapshot!(snapshot_before_quit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn scrolling_page_down_inside_a_pane() {
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
&PANE_MODE,
|
||||
&SPLIT_DOWN_IN_PANE_MODE,
|
||||
&SPLIT_RIGHT_IN_PANE_MODE,
|
||||
&SCROLL_MODE,
|
||||
&SCROLL_PAGE_UP_IN_SCROLL_MODE,
|
||||
&SCROLL_PAGE_UP_IN_SCROLL_MODE,
|
||||
&SCROLL_PAGE_DOWN_IN_SCROLL_MODE,
|
||||
&SCROLL_PAGE_DOWN_IN_SCROLL_MODE,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
let output_frames = fake_input_output
|
||||
.stdout_writer
|
||||
.output_frames
|
||||
.lock()
|
||||
.unwrap();
|
||||
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
||||
let snapshot_before_quit =
|
||||
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
||||
assert_snapshot!(snapshot_before_quit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn max_panes() {
|
||||
// with the --max-panes option, we only allow a certain amount of panes on screen
|
||||
|
@ -0,0 +1,25 @@
|
||||
---
|
||||
source: src/tests/integration/basic.rs
|
||||
expression: snapshot_before_quit
|
||||
|
||||
---
|
||||
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line13-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line14-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line15-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line16-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line17-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line19-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
prompt $
|
||||
────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line13-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line14-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line15-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line16-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
line19-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
prompt $ │prompt $ █
|
@ -0,0 +1,25 @@
|
||||
---
|
||||
source: src/tests/integration/basic.rs
|
||||
expression: snapshot_before_quit
|
||||
|
||||
---
|
||||
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line13-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line14-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line15-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line16-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line17-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
line19-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
prompt $
|
||||
────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line4-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line5-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line6-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line7-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line8-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
line19-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line9-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line10-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a │line11-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
prompt $ │line12-bb█bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
@ -63,6 +63,8 @@ pub mod commands {
|
||||
pub const SCROLL_MODE: [u8; 1] = [19]; // ctrl-s
|
||||
pub const SCROLL_UP_IN_SCROLL_MODE: [u8; 1] = [107]; // k
|
||||
pub const SCROLL_DOWN_IN_SCROLL_MODE: [u8; 1] = [106]; // j
|
||||
pub const SCROLL_PAGE_UP_IN_SCROLL_MODE: [u8; 1] = [2]; // ctrl-b
|
||||
pub const SCROLL_PAGE_DOWN_IN_SCROLL_MODE: [u8; 1] = [6]; // ctrl-f
|
||||
|
||||
pub const RESIZE_MODE: [u8; 1] = [18]; // ctrl-r
|
||||
pub const RESIZE_DOWN_IN_RESIZE_MODE: [u8; 1] = [106]; // j
|
||||
|
Loading…
Reference in New Issue
Block a user