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 1 commit
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
Prev Previous commit
Next Next commit
utils: Apply rustfmt
  • Loading branch information
har7an committed Dec 7, 2022
commit 44eeafe397fce8ee832b471a8a9b33eb9ef83e09
7 changes: 5 additions & 2 deletions zellij-utils/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::{InputMode, Direction, Resize};
use crate::data::{Direction, InputMode, Resize};
use crate::setup::Setup;
use crate::{
consts::{ZELLIJ_CONFIG_DIR_ENV, ZELLIJ_CONFIG_FILE_ENV},
Expand Down Expand Up @@ -184,7 +184,10 @@ pub enum CliAction {
/// Write characters to the terminal.
WriteChars { chars: String },
/// [increase|decrease] the focused panes area at the [left|down|up|right] border.
Resize { resize: Resize, direction: Option<Direction> },
Resize {
resize: Resize,
direction: Option<Direction>,
},
/// Change focus to the next pane
FocusNextPane,
/// Change focus to the previous pane
Expand Down
11 changes: 9 additions & 2 deletions zellij-utils/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ impl From<Resize> for ResizeStrategy {

impl ResizeStrategy {
pub fn new(resize: Resize, direction: Option<Direction>) -> Self {
ResizeStrategy { resize, direction, invert_on_boundaries: true}
ResizeStrategy {
resize,
direction,
invert_on_boundaries: true,
}
}

pub fn invert(&self) -> ResizeStrategy {
Expand All @@ -361,7 +365,10 @@ impl ResizeStrategy {
}

pub fn direction_horizontal(&self) -> bool {
matches!(self.direction, Some(Direction::Left) | Some(Direction::Right))
matches!(
self.direction,
Some(Direction::Left) | Some(Direction::Right)
)
}

pub fn direction_vertical(&self) -> bool {
Expand Down
4 changes: 1 addition & 3 deletions zellij-utils/src/input/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ impl Action {
match cli_action {
CliAction::Write { bytes } => Ok(vec![Action::Write(bytes)]),
CliAction::WriteChars { chars } => Ok(vec![Action::WriteChars(chars)]),
CliAction::Resize { resize, direction } => {
Ok(vec![Action::Resize(resize, direction)])
},
CliAction::Resize { resize, direction } => Ok(vec![Action::Resize(resize, direction)]),
CliAction::FocusNextPane => Ok(vec![Action::FocusNextPane]),
CliAction::FocusPreviousPane => Ok(vec![Action::FocusPreviousPane]),
CliAction::MoveFocus { direction } => Ok(vec![Action::MoveFocus(direction)]),
Expand Down
2 changes: 1 addition & 1 deletion zellij-utils/src/input/unit/keybinds_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::super::actions::*;
use super::super::keybinds::*;
use crate::data::{self, CharOrArrow, Key, Direction};
use crate::data::{self, CharOrArrow, Direction, Key};
use crate::input::config::Config;
use insta::assert_snapshot;
use strum::IntoEnumIterator;
Expand Down
12 changes: 7 additions & 5 deletions zellij-utils/src/kdl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,16 @@ impl Action {
Ok(value) => resize = Some(value),
Err(_) => match Direction::from_str(word) {
Ok(value) => direction = Some(value),
Err(_) => return Err(ConfigError::new_kdl_error(
format!(
Err(_) => {
return Err(ConfigError::new_kdl_error(
format!(
"failed to read either of resize type or direction from '{}'",
word
),
action_node.span().offset(),
action_node.span().len(),
)),
action_node.span().offset(),
action_node.span().len(),
))
},
},
}
}
Expand Down