Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ux): pin floating panes #3876

Merged
merged 15 commits into from
Dec 16, 2024
6 changes: 6 additions & 0 deletions default-plugins/configuration/src/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Locked"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Locked"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Locked"; }}
}}
move {{
bind "m" {{ SwitchToMode "Normal"; }}
Expand Down Expand Up @@ -233,6 +234,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Normal"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Normal"; }}
}}
move {{
bind "{primary_modifier} h" {{ SwitchToMode "Normal"; }}
Expand Down Expand Up @@ -440,6 +442,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Normal"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Normal"; }}
}}
move {{
bind "n" "Tab" {{ MovePane; }}
Expand Down Expand Up @@ -618,6 +621,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Normal"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Normal"; }}
}}
move {{
bind "{primary_modifier} h" {{ SwitchToMode "Normal"; }}
Expand Down Expand Up @@ -805,6 +809,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Normal"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Normal"; }}
}}
move {{
bind "n" "Tab" {{ MovePane; }}
Expand Down Expand Up @@ -967,6 +972,7 @@ keybinds clear-defaults=true {{
bind "w" {{ ToggleFloatingPanes; SwitchToMode "Normal"; }}
bind "e" {{ TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }}
bind "c" {{ SwitchToMode "RenamePane"; PaneNameInput 0;}}
bind "i" {{ TogglePanePinned; SwitchToMode "Normal"; }}
}}
move {{
bind "{primary_modifier} m" {{ SwitchToMode "Normal"; }}
Expand Down
1 change: 1 addition & 0 deletions example/default.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ keybinds {
bind "w" { ToggleFloatingPanes; SwitchToMode "Normal"; }
bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }
bind "c" { SwitchToMode "RenamePane"; PaneNameInput 0;}
bind "i" { TogglePanePinned; SwitchToMode "Normal"; }
}
move {
bind "Ctrl h" { SwitchToMode "Normal"; }
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn main() {
y,
width,
height,
pinned,
})) = opts.command
{
let cwd = cwd.or_else(|| std::env::current_dir().ok());
Expand All @@ -57,6 +58,7 @@ fn main() {
y,
width,
height,
pinned,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
Expand All @@ -71,6 +73,7 @@ fn main() {
y,
width,
height,
pinned,
})) = opts.command
{
let cwd = None;
Expand All @@ -90,6 +93,7 @@ fn main() {
y,
width,
height,
pinned,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
Expand All @@ -105,6 +109,7 @@ fn main() {
y,
width,
height,
pinned,
})) = opts.command
{
let mut file = file;
Expand All @@ -125,6 +130,7 @@ fn main() {
y,
width,
height,
pinned,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
Expand Down
97 changes: 97 additions & 0 deletions src/tests/e2e/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2423,3 +2423,100 @@ pub fn load_plugins_in_background_on_startup() {
);
assert_snapshot!(last_snapshot);
}

#[test]
#[ignore]
pub fn pin_floating_panes() {
let fake_win_size = Size {
cols: 120,
rows: 24,
};
let mut test_attempts = 10;
let last_snapshot = loop {
RemoteRunner::kill_running_sessions(fake_win_size);
let mut runner = RemoteRunner::new(fake_win_size)
.add_step(Step {
name: "Toggle floating panes",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.status_bar_appears()
&& remote_terminal.cursor_position_is(3, 2)
{
remote_terminal.send_key(&PANE_MODE);
std::thread::sleep(std::time::Duration::from_millis(100));
remote_terminal.send_key(&TOGGLE_FLOATING_PANES);
step_is_complete = true;
}
step_is_complete
},
})
.add_step(Step {
name: "Pin floating pane",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.snapshot_contains("PIN [ ]") {
remote_terminal.send_key(&sgr_mouse_report(Position::new(8, 87), 0));
step_is_complete = true;
}
step_is_complete
},
})
.add_step(Step {
name: "Focus underlying pane",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.snapshot_contains("PIN [+]") {
remote_terminal.send_key(&PANE_MODE);
std::thread::sleep(std::time::Duration::from_millis(100));
remote_terminal.send_key(&TOGGLE_FLOATING_PANES);
step_is_complete = true;
}
step_is_complete
},
})
.add_step(Step {
name: "Fill tiled pane with text",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(3, 2) {
remote_terminal.load_fixture("e2e/fill_for_pinned_pane");
step_is_complete = true;
}
step_is_complete
},
})
.add_step(Step {
name: "Move cursor behind pinned pane",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.snapshot_contains("line") {
remote_terminal
.send_key(&format!(" hide_me").as_bytes().to_vec());
step_is_complete = true;
}
step_is_complete
},
});

runner.run_all_steps();
let last_snapshot = runner.take_snapshot_after(Step {
name: "Wait for cursor to be behind pinned pane",
instruction: |remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.snapshot_contains("hide") {
// terminal has been filled with fixture text
step_is_complete = true;
}
step_is_complete
},
});
if runner.test_timed_out && test_attempts > 0 {
test_attempts -= 1;
continue;
} else {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}
8 changes: 8 additions & 0 deletions src/tests/e2e/remote_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij(&mut channel);
Expand Down Expand Up @@ -492,6 +493,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_mirrored_session(&mut channel);
Expand Down Expand Up @@ -528,6 +530,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_mirrored_session_with_layout(&mut channel, layout_file_name);
Expand Down Expand Up @@ -567,6 +570,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_mirrored_session_with_layout_and_viewport_serialization(
Expand Down Expand Up @@ -613,6 +617,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_in_session(&mut channel, session_name, mirrored);
Expand Down Expand Up @@ -649,6 +654,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
attach_to_existing_session(&mut channel, session_name);
Expand Down Expand Up @@ -685,6 +691,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_without_frames(&mut channel);
Expand Down Expand Up @@ -722,6 +729,7 @@ impl RemoteRunner {
rows,
cols,
is_stacked: false,
is_pinned: false,
};
setup_remote_environment(&mut channel, win_size);
start_zellij_with_config(&mut channel, &remote_path.to_string_lossy());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2524
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│$ cat /usr/src/zellij/fixtures/e2e/fill_for_pinned_pane │
│line1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line5aaaaaaaaaaaaaaaaaaaaaaaa┌ Pane #2 ──────────────────────────────────────── PIN [+] ┐aaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line6aaaaaaaaaaaaaaaaaaaaaaaa│$ │aaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line7aaaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line8aaaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line9aaaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaa │
│line10aaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaaa│
│line11aaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaaa│
│line12aaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaaa│
│line13aaaaaaaaaaaaaaaaaaaaaaa│ │aaaaaaaaaaaaaaaaaaaaaaaaaaaaa│
│$ hide_m│ │ │
│ └──────────────────────────────────────────────────────────┘ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1191
assertion_line: 1212
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1  Tab #2  Tab #3  Tab #4
Expand All @@ -9,11 +9,11 @@ expression: last_snapshot
│ ││ │
│ ││ │
│ ││ │
│ ┌ Pane #4 ───────────────────────────────────────────────┐ │
│ ┌ Pane #4 ────────────────────────────────────── PIN [ ] ┐ │
│ │$ │ │
│ │ ┌ top ───────────────────────────────────────────────────┐ │
│ │ ┌ top ────────────────────────────────────────── PIN [ ] ┐ │
│ │ │ │ │
│ │ │ │┐ │
│ │ │ │ ┐ │
│ │ │ │ │────────────────────────────┘
│ │ │ Waiting to run: top │ │────────────────────────────┐
│ │ │ │ │ │
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1252
assertion_line: 1273
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1  Tab #2  Tab #3  Tab #4 
Expand All @@ -9,11 +9,11 @@ expression: last_snapshot
│$ ││$ │
│$ ││$ │
│ ││ │
│ ┌ Pane #4 ───────────────────────────────────────────────┐ │
│ ┌ Pane #4 ────────────────────────────────────── PIN [ ] ┐ │
│ │ │ │
│ │$┌ top ───────────────────────────────────────────────────┐ │
│ │$┌ top ────────────────────────────────────────── PIN [ ] ┐ │
│ │$│ │ │
│ │ │ │┐ │
│ │ │ │ ┐ │
│ │ │ │ │────────────────────────────┘
│ │ │ Waiting to run: top │ │────────────────────────────┐
│ │ │ │ │ │
Expand Down
Loading
Loading