feat(ui): resize shortcuts (#4003)

* feat(ui): show resize and focus shortcuts when relevant

* update serialization and snapshots

* update e2e tests

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2025-02-18 11:11:58 +01:00 committed by GitHub
parent 5b6a0e6dc3
commit 544982dad4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 241 additions and 89 deletions

View file

@ -682,9 +682,22 @@ fn render_secondary_info(
}
}
fn should_show_focus_and_resize_shortcuts(tab_info: Option<&TabInfo>) -> bool {
let Some(tab_info) = tab_info else {
return false;
};
let are_floating_panes_visible = tab_info.are_floating_panes_visible;
if are_floating_panes_visible {
tab_info.selectable_floating_panes_count > 1
} else {
tab_info.selectable_tiled_panes_count > 1
}
}
fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usize) -> LinePart {
let mut secondary_info = LinePart::default();
let binds = &help.get_mode_keybinds();
let should_show_focus_and_resize_shortcuts = should_show_focus_and_resize_shortcuts(tab_info);
// New Pane
let new_pane_action_key = action_key(binds, &[Action::NewPane(None, None, false)]);
let mut new_pane_key_to_display = new_pane_action_key
@ -698,6 +711,25 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
vec![]
};
// Resize
let resize_increase_action_key = action_key(binds, &[Action::Resize(Resize::Increase, None)]);
let resize_increase_key = resize_increase_action_key
.iter()
.find(|k| k.bare_key == BareKey::Char('+'))
.or_else(|| resize_increase_action_key.iter().next());
let resize_decrease_action_key = action_key(binds, &[Action::Resize(Resize::Decrease, None)]);
let resize_decrease_key = resize_decrease_action_key
.iter()
.find(|k| k.bare_key == BareKey::Char('-'))
.or_else(|| resize_increase_action_key.iter().next());
let mut resize_shortcuts = vec![];
if let Some(resize_increase_key) = resize_increase_key {
resize_shortcuts.push(resize_increase_key.clone());
}
if let Some(resize_decrease_key) = resize_decrease_key {
resize_shortcuts.push(resize_decrease_key.clone());
}
// Move focus
let mut move_focus_shortcuts: Vec<KeyWithModifier> = vec![];
@ -757,6 +789,7 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
[
new_pane_key_to_display.clone(),
move_focus_shortcuts.clone(),
resize_shortcuts.clone(),
toggle_floating_key_to_display.clone(),
]
.iter()
@ -773,6 +806,7 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
false,
Some(0),
));
if should_show_focus_and_resize_shortcuts {
secondary_info.append(&add_shortcut(
help,
"Change Focus",
@ -780,6 +814,14 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
false,
Some(0),
));
secondary_info.append(&add_shortcut(
help,
"Resize",
&resize_shortcuts,
false,
Some(0),
));
}
secondary_info.append(&add_shortcut(
help,
"Floating",
@ -808,6 +850,10 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
.iter()
.map(|k| k.strip_common_modifiers(&common_modifiers))
.collect();
let resize_shortcuts: Vec<KeyWithModifier> = resize_shortcuts
.iter()
.map(|k| k.strip_common_modifiers(&common_modifiers))
.collect();
let toggle_floating_key_to_display: Vec<KeyWithModifier> = toggle_floating_key_to_display
.iter()
.map(|k| k.strip_common_modifiers(&common_modifiers))
@ -818,12 +864,20 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
new_pane_key_to_display,
false,
));
if should_show_focus_and_resize_shortcuts {
secondary_info.append(&add_shortcut_with_inline_key(
help,
"Change Focus",
move_focus_shortcuts,
false,
));
secondary_info.append(&add_shortcut_with_inline_key(
help,
"Resize",
resize_shortcuts,
false,
));
}
secondary_info.append(&add_shortcut_with_inline_key(
help,
"Floating",
@ -844,6 +898,7 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
false,
Some(0),
));
if should_show_focus_and_resize_shortcuts {
short_line.append(&add_shortcut(
help,
"Focus",
@ -851,6 +906,14 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
false,
Some(0),
));
short_line.append(&add_shortcut(
help,
"Resize",
&resize_shortcuts,
false,
Some(0),
));
}
short_line.append(&add_shortcut(
help,
"Floating",
@ -879,6 +942,10 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
.iter()
.map(|k| k.strip_common_modifiers(&common_modifiers))
.collect();
let resize_shortcuts: Vec<KeyWithModifier> = resize_shortcuts
.iter()
.map(|k| k.strip_common_modifiers(&common_modifiers))
.collect();
let toggle_floating_key_to_display: Vec<KeyWithModifier> =
toggle_floating_key_to_display
.iter()
@ -890,12 +957,20 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
new_pane_key_to_display,
false,
));
if should_show_focus_and_resize_shortcuts {
short_line.append(&add_shortcut_with_inline_key(
help,
"Focus",
move_focus_shortcuts,
false,
));
short_line.append(&add_shortcut_with_inline_key(
help,
"Resize",
resize_shortcuts,
false,
));
}
short_line.append(&add_shortcut_with_inline_key(
help,
"Floating",
@ -903,7 +978,21 @@ fn secondary_keybinds(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usiz
are_floating_panes_visible,
));
}
if short_line.len <= max_len {
short_line
} else {
let part = serialize_text(
&Text::new(format!(
"{:>width$}",
"...",
width = max_len.saturating_sub(3)
))
.color_range(0, ..)
.opaque(),
);
let len = max_len.saturating_sub(3);
LinePart { part, len }
}
}
}
@ -982,6 +1071,7 @@ fn add_shortcut_with_inline_key(
"←→" => "",
"↓↑" => "",
"[]" => "",
"+-" => "",
_ => "|",
};

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1975
assertion_line: 2000
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 243
assertion_line: 239
expression: last_snapshot
---
Zellij
@ -22,4 +22,4 @@ expression: last_snapshot
│ │
│ │
└──────┘
Ctrl +
...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 707
assertion_line: 714
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1138
assertion_line: 1154
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1352
assertion_line: 1373
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2426
assertion_line: 2424
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl g  UNLOCK  Alt +  <n> New Pane  <←↓↑→> Change Focus  <f> Floating 
Ctrl g  UNLOCK  Alt +  <n> New Pane  <f> Floating 

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1624
assertion_line: 1650
expression: first_runner_snapshot
---
Zellij (mirrored_sessions)  Tab #1  Tab #2 
@ -26,4 +26,4 @@ expression: first_runner_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 558
assertion_line: 562
expression: account_for_races_in_snapshot(last_snapshot)
---
Zellij (e2e-test)  Tab #1  Tab #3  Tab #2 
@ -26,4 +26,4 @@ expression: account_for_races_in_snapshot(last_snapshot)
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 620
assertion_line: 624
expression: account_for_races_in_snapshot(last_snapshot)
---
Zellij (e2e-test)  Tab #2  Tab #1  Tab #3 
@ -26,4 +26,4 @@ expression: account_for_races_in_snapshot(last_snapshot)
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 592
assertion_line: 596
expression: account_for_races_in_snapshot(last_snapshot)
---
Zellij (e2e-test)  Tab #1  Tab #3  Tab #2 
@ -26,4 +26,4 @@ expression: account_for_races_in_snapshot(last_snapshot)
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 644
assertion_line: 648
expression: account_for_races_in_snapshot(last_snapshot)
---
Zellij (e2e-test)  Tab #3  Tab #2  Tab #1 
@ -26,4 +26,4 @@ expression: account_for_races_in_snapshot(last_snapshot)
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1809
assertion_line: 1836
expression: second_runner_snapshot
---
Zellij (multiple_users_in_same_pane_and_tab)  Tab #1 [ ]
@ -26,4 +26,4 @@ expression: second_runner_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1808
assertion_line: 1835
expression: first_runner_snapshot
---
Zellij (multiple_users_in_same_pane_and_tab)  Tab #1 [ ]
@ -26,4 +26,4 @@ expression: first_runner_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1907
assertion_line: 1936
expression: second_runner_snapshot
---
Zellij (multiple_users_in_different_tabs)  Tab #1 [ ] Tab #2 
@ -26,4 +26,4 @@ expression: second_runner_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1906
assertion_line: 1935
expression: first_runner_snapshot
---
Zellij (multiple_users_in_different_tabs)  Tab #1  Tab #2 [ ]
@ -26,4 +26,4 @@ expression: first_runner_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1716
assertion_line: 1741
expression: second_runner_snapshot
---
Zellij (multiple_users_in_same_pane_and_tab)  Tab #1 [ ]
@ -26,4 +26,4 @@ expression: second_runner_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1718
assertion_line: 1740
expression: first_runner_snapshot
---
Zellij (multiple_users_in_same_pane_and_tab)  Tab #1 [ ]
@ -26,4 +26,4 @@ expression: first_runner_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 452
assertion_line: 454
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1  Tab #2 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2524
assertion_line: 2521
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 923
assertion_line: 935
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└────────────────────────────────────────────────────┘└────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└────────────────────────────────────────────────┘└────────────────────────────────────────────────┘
Ctrl + g  p  t  n  h  s  o  q  Alt +  <n> New  <←↓↑→> Focus  <f> Floating 
Ctrl + g  p  t  n  h  s  o  q  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1428
assertion_line: 1451
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││line18 │
│ ││li█e19 │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└─────────────────────────────────────────────────────────────────────────┘└ [ EXIT CODE: 0 ] <ENTER> re-run, <ESC> drop to shell, <Ctrl-c> exit ────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 194
assertion_line: 195
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1476
assertion_line: 1500
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ $ │
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2070
assertion_line: 2099
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 858
assertion_line: 867
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2240
assertion_line: 2263
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2183
assertion_line: 2206
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
@ -26,4 +26,4 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  ...

View file

@ -1540,6 +1540,8 @@ impl Screen {
let (active_swap_layout_name, is_swap_layout_dirty) = tab.swap_layout_info();
let tab_viewport = tab.get_viewport();
let tab_display_area = tab.get_display_area();
let selectable_tiled_panes_count = tab.get_selectable_tiled_panes_count();
let selectable_floating_panes_count = tab.get_selectable_floating_panes_count();
let tab_info_for_screen = TabInfo {
position: tab.position,
name: tab.name.clone(),
@ -1555,6 +1557,8 @@ impl Screen {
viewport_columns: tab_viewport.cols,
display_area_rows: tab_display_area.rows,
display_area_columns: tab_display_area.cols,
selectable_tiled_panes_count,
selectable_floating_panes_count,
};
tab_infos_for_screen_state.insert(tab.position, tab_info_for_screen);
}
@ -1576,6 +1580,8 @@ impl Screen {
let (active_swap_layout_name, is_swap_layout_dirty) = tab.swap_layout_info();
let tab_viewport = tab.get_viewport();
let tab_display_area = tab.get_display_area();
let selectable_tiled_panes_count = tab.get_selectable_tiled_panes_count();
let selectable_floating_panes_count = tab.get_selectable_floating_panes_count();
let tab_info_for_plugins = TabInfo {
position: tab.position,
name: tab.name.clone(),
@ -1591,6 +1597,8 @@ impl Screen {
viewport_columns: tab_viewport.cols,
display_area_rows: tab_display_area.rows,
display_area_columns: tab_display_area.cols,
selectable_tiled_panes_count,
selectable_floating_panes_count,
};
plugin_tab_updates.push(tab_info_for_plugins);
}

View file

@ -2271,6 +2271,9 @@ impl Tab {
pub fn get_selectable_tiled_panes_count(&self) -> usize {
self.get_selectable_tiled_panes().count()
}
pub fn get_selectable_floating_panes_count(&self) -> usize {
self.get_selectable_floating_panes().count()
}
pub fn get_visible_selectable_floating_panes_count(&self) -> usize {
if self.are_floating_panes_visible() {
self.get_selectable_floating_panes().count()

View file

@ -1,6 +1,6 @@
---
source: zellij-server/src/./unit/screen_tests.rs
assertion_line: 2926
assertion_line: 2929
expression: "format!(\"{:#?}\", plugin_rename_tab_instruction)"
---
Some(
@ -30,6 +30,8 @@ Some(
viewport_columns: 80,
display_area_rows: 10,
display_area_columns: 80,
selectable_tiled_panes_count: 2,
selectable_floating_panes_count: 0,
},
],
),

View file

@ -1,6 +1,6 @@
---
source: zellij-server/src/./unit/screen_tests.rs
assertion_line: 2976
assertion_line: 2979
expression: "format!(\"{:#?}\", plugin_undo_rename_tab_instruction)"
---
Some(
@ -30,6 +30,8 @@ Some(
viewport_columns: 80,
display_area_rows: 10,
display_area_columns: 80,
selectable_tiled_panes_count: 2,
selectable_floating_panes_count: 0,
},
],
),

View file

@ -422,6 +422,10 @@ pub struct TabInfo {
pub display_area_rows: u32,
#[prost(uint32, tag = "14")]
pub display_area_columns: u32,
#[prost(uint32, tag = "15")]
pub selectable_tiled_panes_count: u32,
#[prost(uint32, tag = "16")]
pub selectable_floating_panes_count: u32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]

View file

@ -1663,6 +1663,10 @@ pub struct TabInfo {
/// Column count in the display area (including all panes, will typically be larger than the
/// viewport)
pub display_area_columns: usize,
/// The number of selectable (eg. not the UI bars) tiled panes currently in this tab
pub selectable_tiled_panes_count: usize,
/// The number of selectable (eg. not the UI bars) floating panes currently in this tab
pub selectable_floating_panes_count: usize,
}
/// The `PaneManifest` contains a dictionary of panes, indexed by the tab position (0 indexed).

View file

@ -4594,6 +4594,10 @@ impl TabInfo {
let display_area_rows = optional_int_node!("display_area_rows", usize).unwrap_or(0);
let display_area_columns = optional_int_node!("display_area_columns", usize).unwrap_or(0);
let is_swap_layout_dirty = bool_node!("is_swap_layout_dirty");
let selectable_tiled_panes_count =
optional_int_node!("selectable_tiled_panes_count", usize).unwrap_or(0);
let selectable_floating_panes_count =
optional_int_node!("selectable_floating_panes_count", usize).unwrap_or(0);
Ok(TabInfo {
position,
name,
@ -4609,6 +4613,8 @@ impl TabInfo {
viewport_columns,
display_area_rows,
display_area_columns,
selectable_tiled_panes_count,
selectable_floating_panes_count,
})
}
pub fn encode_to_kdl(&self) -> KdlDocument {
@ -4676,6 +4682,16 @@ impl TabInfo {
is_swap_layout_dirty.push(self.is_swap_layout_dirty);
kdl_doucment.nodes_mut().push(is_swap_layout_dirty);
let mut selectable_tiled_panes_count = KdlNode::new("selectable_tiled_panes_count");
selectable_tiled_panes_count.push(self.selectable_tiled_panes_count as i64);
kdl_doucment.nodes_mut().push(selectable_tiled_panes_count);
let mut selectable_floating_panes_count = KdlNode::new("selectable_floating_panes_count");
selectable_floating_panes_count.push(self.selectable_floating_panes_count as i64);
kdl_doucment
.nodes_mut()
.push(selectable_floating_panes_count);
kdl_doucment
}
}
@ -5020,6 +5036,8 @@ fn serialize_and_deserialize_session_info_with_data() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
TabInfo {
position: 1,
@ -5036,6 +5054,8 @@ fn serialize_and_deserialize_session_info_with_data() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
],
panes: PaneManifest { panes },

View file

@ -1,6 +1,6 @@
---
source: zellij-utils/src/kdl/mod.rs
assertion_line: 4728
assertion_line: 5070
expression: serialized
---
name "my session name"
@ -20,6 +20,8 @@ tabs {
display_area_columns 10
display_area_rows 10
is_swap_layout_dirty true
selectable_tiled_panes_count 10
selectable_floating_panes_count 10
}
tab {
position 1
@ -35,6 +37,8 @@ tabs {
display_area_columns 10
display_area_rows 10
is_swap_layout_dirty false
selectable_tiled_panes_count 10
selectable_floating_panes_count 10
}
}
panes {

View file

@ -315,6 +315,8 @@ message TabInfo {
uint32 viewport_columns = 12;
uint32 display_area_rows = 13;
uint32 display_area_columns = 14;
uint32 selectable_tiled_panes_count = 15;
uint32 selectable_floating_panes_count = 16;
}
message ModeUpdatePayload {

View file

@ -1109,6 +1109,9 @@ impl TryFrom<ProtobufTabInfo> for TabInfo {
viewport_columns: protobuf_tab_info.viewport_columns as usize,
display_area_rows: protobuf_tab_info.display_area_rows as usize,
display_area_columns: protobuf_tab_info.display_area_columns as usize,
selectable_tiled_panes_count: protobuf_tab_info.selectable_tiled_panes_count as usize,
selectable_floating_panes_count: protobuf_tab_info.selectable_floating_panes_count
as usize,
})
}
}
@ -1135,6 +1138,8 @@ impl TryFrom<TabInfo> for ProtobufTabInfo {
viewport_columns: tab_info.viewport_columns as u32,
display_area_rows: tab_info.display_area_rows as u32,
display_area_columns: tab_info.display_area_columns as u32,
selectable_tiled_panes_count: tab_info.selectable_tiled_panes_count as u32,
selectable_floating_panes_count: tab_info.selectable_floating_panes_count as u32,
})
}
}
@ -1540,6 +1545,8 @@ fn serialize_tab_update_event_with_non_default_values() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
TabInfo {
position: 1,
@ -1556,6 +1563,8 @@ fn serialize_tab_update_event_with_non_default_values() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
TabInfo::default(),
]);
@ -1827,6 +1836,8 @@ fn serialize_session_update_event_with_non_default_values() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
TabInfo {
position: 1,
@ -1843,6 +1854,8 @@ fn serialize_session_update_event_with_non_default_values() {
viewport_columns: 10,
display_area_rows: 10,
display_area_columns: 10,
selectable_tiled_panes_count: 10,
selectable_floating_panes_count: 10,
},
TabInfo::default(),
];