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

Reimplement resize code #1990

Merged
merged 34 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6cf47ec
server/floating_panes: Start removing `unwrap`s
har7an Nov 24, 2022
2b4ac5e
server/panes: Remove more `unwrap`s
har7an Nov 30, 2022
4234c29
utils/data: Unify `Direction` type
har7an Nov 30, 2022
fa54dc3
server: Implement new resize handling
har7an Nov 30, 2022
40eaf58
utils/layout: Add conversion for SplitDirection
har7an Dec 1, 2022
eba5e8a
utils/data: Add impl for `Direction`
har7an Dec 1, 2022
cd13147
server/panes: Rework tiled pane resizing
har7an Dec 1, 2022
233f599
server/panes/tiled_panes: Add debug assertion
har7an Dec 3, 2022
e06d7d0
server/panes/tiled/grid: Fix resize bug
har7an Dec 3, 2022
3e0306c
utils/data: Add `invert` for `Resize`
har7an Dec 4, 2022
c674445
utils/data: Add member to `ResizeStrategy`
har7an Dec 4, 2022
9b4ebb0
server/screen: Handle new attribute
har7an Dec 4, 2022
207e5b5
server/panes/resizer: Return `anyhow::Error`
har7an Dec 4, 2022
fa87b2b
server/panes/tiled: Implement resize increase/decrease
har7an Dec 4, 2022
21ca240
server/pane/tiled/grid: Don't return early
har7an Dec 5, 2022
6164113
server/pane/tiled/grid: Fix resize bug
har7an Dec 5, 2022
7833ade
server/panes/tiled/grid: Cleanup code
har7an Dec 5, 2022
66163d2
server/panes/float/grid: Invert resize
har7an Dec 5, 2022
3670287
plugins/status-bar: Add hints for new resize
har7an Dec 5, 2022
7e96a6a
server: Use new resize method
har7an Dec 5, 2022
a757838
server: Fix tests
har7an Dec 5, 2022
809acf6
apply rustfmt
har7an Dec 5, 2022
44eeafe
utils: Apply rustfmt
har7an Dec 5, 2022
347e655
server/panes/floating: Fix resize increase
har7an Dec 7, 2022
81181a2
server/panes/tiled: Use correct resize increments
har7an Dec 7, 2022
756ab2e
server/panes/tiled: Fix resize checks
har7an Dec 7, 2022
e92213e
utils/assets/config: Update default config
har7an Dec 7, 2022
ff8c165
server/panes/tiled: Fix resize check
har7an Dec 7, 2022
6bb3fd7
server/panes/tiled: Use shortener for `Direction`
har7an Dec 7, 2022
d8bc8ed
server/panes/tiled: Restore resize behavior
har7an Dec 7, 2022
a7e9d20
server/panes/floating: Fix resize increment
har7an Dec 7, 2022
008ef2f
utils/data: Fix doctest
har7an Dec 7, 2022
54336ae
utils: Fix test snapshots
har7an Dec 7, 2022
cb08b2c
changelog: Add PR #1990
har7an Dec 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* refactor(messaging): reduce extraneous cross-thread messaging (https://github.com/zellij-org/zellij/pull/1996)
* errors: preserve caller location in `to_log` (https://github.com/zellij-org/zellij/pull/1994)
* feat: show loading screen on startup (https://github.com/zellij-org/zellij/pull/1997)
* feat: Allow "reducing" resizes, refactor resizing code (https://github.com/zellij-org/zellij/pull/1990)

## [0.33.0] - 2022-11-10

Expand Down
2 changes: 2 additions & 0 deletions default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ pub fn action_key_group(keymap: &[(Key, Vec<Action>)], actions: &[&[Action]]) ->
/// separator between them:
///
/// - "hjkl"
/// - "HJKL"
/// - "←↓↑→"
/// - "←→"
/// - "↓↑"
Expand Down Expand Up @@ -423,6 +424,7 @@ pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette) -> Vec<ANSIStr
// Special handling of some pre-defined keygroups
let key_string = key.join("");
let key_separator = match &key_string[..] {
"HJKL" => "",
"hjkl" => "",
"←↓↑→" => "",
"←→" => "",
Expand Down
65 changes: 29 additions & 36 deletions default-plugins/status-bar/src/second_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ fn full_shortcut_list_nonstandard_mode(help: &ModeInfo) -> LinePart {
fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec<Key>)> {
use Action as A;
use InputMode as IM;
use actions::Direction as Dir;
use actions::ResizeDirection as RDir;
use Direction as Dir;
use actions::SearchDirection as SDir;
use actions::SearchOption as SOpt;

Expand Down Expand Up @@ -188,11 +187,23 @@ fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec<Key>)> {
(s("Toggle"), s("Toggle"), action_key(&km, &[A::ToggleTab])),
(s("Select pane"), s("Select"), to_normal_key),
]} else if mi.mode == IM::Resize { vec![
(s("Resize"), s("Resize"), action_key_group(&km, &[
&[A::Resize(RDir::Left)], &[A::Resize(RDir::Down)],
&[A::Resize(RDir::Up)], &[A::Resize(RDir::Right)]])),
(s("Increase to"), s("Increase"), action_key_group(&km, &[
&[A::Resize(Resize::Increase, Some(Dir::Left))],
&[A::Resize(Resize::Increase, Some(Dir::Down))],
&[A::Resize(Resize::Increase, Some(Dir::Up))],
&[A::Resize(Resize::Increase, Some(Dir::Right))]
])),
(s("Decrease from"), s("Decrease"), action_key_group(&km, &[
&[A::Resize(Resize::Decrease, Some(Dir::Left))],
&[A::Resize(Resize::Decrease, Some(Dir::Down))],
&[A::Resize(Resize::Decrease, Some(Dir::Up))],
&[A::Resize(Resize::Decrease, Some(Dir::Right))]
])),
(s("Increase/Decrease size"), s("Increase/Decrease"),
action_key_group(&km, &[&[A::Resize(RDir::Increase)], &[A::Resize(RDir::Decrease)]])),
action_key_group(&km, &[
&[A::Resize(Resize::Increase, None)],
&[A::Resize(Resize::Decrease, None)]
])),
(s("Select pane"), s("Select"), to_normal_key),
]} else if mi.mode == IM::Move { vec![
(s("Move"), s("Move"), action_key_group(&km, &[
Expand Down Expand Up @@ -666,13 +677,10 @@ mod tests {
keybinds: vec![(
InputMode::Pane,
vec![
(Key::Left, vec![Action::MoveFocus(actions::Direction::Left)]),
(Key::Down, vec![Action::MoveFocus(actions::Direction::Down)]),
(Key::Up, vec![Action::MoveFocus(actions::Direction::Up)]),
(
Key::Right,
vec![Action::MoveFocus(actions::Direction::Right)],
),
(Key::Left, vec![Action::MoveFocus(Direction::Left)]),
(Key::Down, vec![Action::MoveFocus(Direction::Down)]),
(Key::Up, vec![Action::MoveFocus(Direction::Up)]),
(Key::Right, vec![Action::MoveFocus(Direction::Right)]),
(Key::Char('n'), vec![Action::NewPane(None, None), TO_NORMAL]),
(Key::Char('x'), vec![Action::CloseFocus, TO_NORMAL]),
(
Expand Down Expand Up @@ -701,13 +709,10 @@ mod tests {
keybinds: vec![(
InputMode::Pane,
vec![
(Key::Left, vec![Action::MoveFocus(actions::Direction::Left)]),
(Key::Down, vec![Action::MoveFocus(actions::Direction::Down)]),
(Key::Up, vec![Action::MoveFocus(actions::Direction::Up)]),
(
Key::Right,
vec![Action::MoveFocus(actions::Direction::Right)],
),
(Key::Left, vec![Action::MoveFocus(Direction::Left)]),
(Key::Down, vec![Action::MoveFocus(Direction::Down)]),
(Key::Up, vec![Action::MoveFocus(Direction::Up)]),
(Key::Right, vec![Action::MoveFocus(Direction::Right)]),
(Key::Char('n'), vec![Action::NewPane(None, None), TO_NORMAL]),
(Key::Char('x'), vec![Action::CloseFocus, TO_NORMAL]),
(
Expand All @@ -732,22 +737,10 @@ mod tests {
keybinds: vec![(
InputMode::Pane,
vec![
(
Key::Ctrl('a'),
vec![Action::MoveFocus(actions::Direction::Left)],
),
(
Key::Ctrl('\n'),
vec![Action::MoveFocus(actions::Direction::Down)],
),
(
Key::Ctrl('1'),
vec![Action::MoveFocus(actions::Direction::Up)],
),
(
Key::Ctrl(' '),
vec![Action::MoveFocus(actions::Direction::Right)],
),
(Key::Ctrl('a'), vec![Action::MoveFocus(Direction::Left)]),
(Key::Ctrl('\n'), vec![Action::MoveFocus(Direction::Down)]),
(Key::Ctrl('1'), vec![Action::MoveFocus(Direction::Up)]),
(Key::Ctrl(' '), vec![Action::MoveFocus(Direction::Right)]),
(Key::Backspace, vec![Action::NewPane(None, None), TO_NORMAL]),
(Key::Esc, vec![Action::CloseFocus, TO_NORMAL]),
(Key::End, vec![Action::ToggleFocusFullscreen, TO_NORMAL]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use ansi_term::{unstyled_len, ANSIString, ANSIStrings, Style};

use crate::{action_key_group, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{
actions::{Action, Direction},
*,
};
use zellij_tile::prelude::{actions::Action, *};

macro_rules! strings {
($ANSIStrings:expr) => {{
Expand Down
9 changes: 3 additions & 6 deletions default-plugins/status-bar/src/tip/data/quicknav.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use ansi_term::{unstyled_len, ANSIString, ANSIStrings, Style};

use crate::{action_key, action_key_group, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{
actions::{Action, Direction, ResizeDirection},
*,
};
use zellij_tile::prelude::{actions::Action, *};

macro_rules! strings {
($ANSIStrings:expr) => {{
Expand Down Expand Up @@ -75,8 +72,8 @@ fn add_keybinds(help: &ModeInfo) -> Keygroups {
let mut resize_keys = action_key_group(
&normal_keymap,
&[
&[Action::Resize(ResizeDirection::Increase)],
&[Action::Resize(ResizeDirection::Decrease)],
&[Action::Resize(Resize::Increase, None)],
&[Action::Resize(Resize::Decrease, None)],
],
);
if resize_keys.contains(&Key::Alt(CharOrArrow::Char('=')))
Expand Down
4 changes: 2 additions & 2 deletions zellij-client/src/unit/stdin_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::input_loop;
use crate::stdin_ansi_parser::StdinAnsiParser;
use crate::stdin_loop;
use zellij_utils::anyhow::Result;
use zellij_utils::data::{InputMode, Palette};
use zellij_utils::input::actions::{Action, Direction};
use zellij_utils::data::{Direction, InputMode, Palette};
use zellij_utils::input::actions::Action;
use zellij_utils::input::config::Config;
use zellij_utils::input::options::Options;
use zellij_utils::nix;
Expand Down
Loading