diff options
author | Brooks Rady <b.j.rady@gmail.com> | 2021-06-03 13:15:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 13:15:56 +0100 |
commit | c65987a285b32658de935d92b61d2186f4548982 (patch) | |
tree | 16d91c5252767523293d5c420c205e90fec43f37 | |
parent | 24165b617874501edc36c5f523e7dc9dcec097af (diff) | |
parent | a9ce13c1d2ff02981ccb552bf3da9355ec63273b (diff) |
feat(ui): laying the groundwork for a new resize algorithm
34 files changed, 552 insertions, 285 deletions
diff --git a/Cargo.lock b/Cargo.lock index dc862d534..31e038a0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,6 +272,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] name = "cc" version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2345,6 +2351,7 @@ version = "0.13.0" dependencies = [ "ansi_term 0.12.1", "async-trait", + "cassowary", "daemonize", "insta", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 64077b586..4d6434d17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,3 +57,4 @@ assets = [ [features] disable_automatic_asset_installation = [] +parametric_resize_beta = [] diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index cf9445d6a..83eb50c9a 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -135,7 +135,7 @@ impl ZellijPlugin for State { fn load(&mut self) { set_selectable(false); set_invisible_borders(true); - set_max_height(2); + set_fixed_height(2); subscribe(&[EventType::ModeUpdate]); } diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 46336be3d..1f83dcde6 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -26,7 +26,7 @@ impl ZellijPlugin for State { fn load(&mut self) { set_selectable(false); set_invisible_borders(true); - set_max_height(1); + set_fixed_height(1); subscribe(&[EventType::TabUpdate, EventType::ModeUpdate]); } @@ -57,7 +57,6 @@ impl ZellijPlugin for State { let tab = tab_style( tabname, t.active, - t.position, t.is_sync_panes_active, self.mode_info.palette, self.mode_info.capabilities, diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs index 7e83e85bb..9edfba13f 100644 --- a/default-plugins/tab-bar/src/tab.rs +++ b/default-plugins/tab-bar/src/tab.rs @@ -40,7 +40,6 @@ pub fn non_active_tab(text: String, palette: Palette, separator: &str) -> LinePa pub fn tab_style( text: String, is_active_tab: bool, - position: usize, is_sync_panes_active: bool, palette: Palette, capabilities: PluginCapabilities, diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs index 640b1c553..155ff8b16 100644 --- a/src/tests/integration/basic.rs +++ b/src/tests/integration/basic.rs @@ -20,7 +20,7 @@ fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { #[test] pub fn starts_with_one_terminal() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -48,7 +48,7 @@ pub fn starts_with_one_terminal() { #[test] pub fn split_terminals_vertically() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -76,7 +76,7 @@ pub fn split_terminals_vertically() { #[test] pub fn split_terminals_horizontally() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -105,7 +105,7 @@ pub fn split_terminals_horizontally() { pub fn split_largest_terminal() { // this finds the largest pane and splits along its longest edge (vertically or horizontally) let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -139,7 +139,7 @@ pub fn split_largest_terminal() { #[test] pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() { let fake_win_size = PositionAndSize { - columns: 8, + cols: 8, rows: 20, x: 0, y: 0, @@ -167,7 +167,7 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() { #[test] pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 4, x: 0, y: 0, @@ -195,7 +195,7 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() { #[test] pub fn cannot_split_largest_terminal_when_there_is_no_room() { let fake_win_size = PositionAndSize { - columns: 8, + cols: 8, rows: 4, x: 0, y: 0, @@ -223,7 +223,7 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() { #[test] pub fn scrolling_up_inside_a_pane() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -259,7 +259,7 @@ pub fn scrolling_up_inside_a_pane() { #[test] pub fn scrolling_down_inside_a_pane() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -297,7 +297,7 @@ pub fn scrolling_down_inside_a_pane() { #[test] pub fn scrolling_page_up_inside_a_pane() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -332,7 +332,7 @@ pub fn scrolling_page_up_inside_a_pane() { #[test] pub fn scrolling_page_down_inside_a_pane() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -372,7 +372,7 @@ pub fn max_panes() { // with the --max-panes option, we only allow a certain amount of panes on screen // simultaneously, new panes beyond this limit will close older panes on screen let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -409,7 +409,7 @@ pub fn max_panes() { #[test] pub fn toggle_focused_pane_fullscreen() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -452,7 +452,7 @@ pub fn bracketed_paste() { // since it's inside a bracketed paste block, while the "QUIT" command is, since it is already // past the block let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, diff --git a/src/tests/integration/close_pane.rs b/src/tests/integration/close_pane.rs index 598815145..afdc3f2ee 100644 --- a/src/tests/integration/close_pane.rs +++ b/src/tests/integration/close_pane.rs @@ -28,7 +28,7 @@ pub fn close_pane_with_another_pane_above_it() { // └───────────┘ └───────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -70,7 +70,7 @@ pub fn close_pane_with_another_pane_below_it() { // └───────────┘ └───────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -111,7 +111,7 @@ pub fn close_pane_with_another_pane_to_the_left() { // └─────┴─────┘ └──────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -151,7 +151,7 @@ pub fn close_pane_with_another_pane_to_the_right() { // └─────┴─────┘ └──────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -194,7 +194,7 @@ pub fn close_pane_with_multiple_panes_above_it() { // └───────────┘ └─────┴─────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -240,7 +240,7 @@ pub fn close_pane_with_multiple_panes_below_it() { // └─────┴─────┘ └─────┴─────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -284,7 +284,7 @@ pub fn close_pane_with_multiple_panes_to_the_left() { // └─────┴─────┘ └──────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -330,7 +330,7 @@ pub fn close_pane_with_multiple_panes_to_the_right() { // └─────┴─────┘ └──────────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -374,7 +374,7 @@ pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() { // └───┴───────┴───┘ └───┴───┴───┴───┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -441,7 +441,7 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() { // └───┴───┴───┴───┘ └───┴───┴───┴───┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, @@ -506,7 +506,7 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() { // └────┴──────┘ └────┴──────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 30, x: 0, y: 0, @@ -571,7 +571,7 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() { // └────┴──────┘ └────┴──────┘ // █ == pane being closed let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 30, x: 0, y: 0, @@ -626,7 +626,7 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() { #[test] pub fn closing_last_pane_exits_app() { let fake_win_size = PositionAndSize { - columns: 121, + cols: 121, rows: 20, x: 0, y: 0, diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs index ec983b095..06a409ff5 100644 --- a/src/tests/integration/compatibility.rs +++ b/src/tests/integration/compatibility.rs @@ -27,14 +27,14 @@ use zellij_utils::input::config::Config; fn get_fake_os_input(fake_win_size: &PositionAndSize, fixture_name: &str) -> FakeInputOutput { let mut tty_inputs = HashMap::new(); let fixture_bytes = Bytes::from_file_in_fixtures(&fixture_name); - tty_inputs.insert(fake_win_size.columns as u16, fixture_bytes); + tty_inputs.insert(fake_win_size.cols as u16, fixture_bytes); FakeInputOutput::new(fake_win_size.clone()).with_tty_inputs(tty_inputs) } #[test] pub fn run_bandwhich_from_fish_shell() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -64,7 +64,7 @@ pub fn run_bandwhich_from_fish_shell() { #[test] pub fn fish_tab_completion_options() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -98,7 +98,7 @@ pub fn fish_select_tab_completion_options() { // this is not clearly seen in the snapshot because it does not include styles, // but we can see the command line change and the cursor staying in place let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -136,7 +136,7 @@ pub fn vim_scroll_region_down() { // file // experience appear to the user let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -171,7 +171,7 @@ pub fn vim_ctrl_d() { // end of the scroll region // vim makes sure to fill these empty lines with the rest of the file let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -205,7 +205,7 @@ pub fn vim_ctrl_u() { // this causes the effect of scrolling up X lines (vim replaces the lines with the ones in the // file above the current content) let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -234,7 +234,7 @@ pub fn vim_ctrl_u() { #[test] pub fn htop() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -263,7 +263,7 @@ pub fn htop() { #[test] pub fn htop_scrolling() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -292,7 +292,7 @@ pub fn htop_scrolling() { #[test] pub fn htop_right_scrolling() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -329,7 +329,7 @@ pub fn vim_overwrite() { // * confirm you would like to change the file by pressing 'y' and then ENTER // * if everything looks fine, this test passed :) let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -361,7 +361,7 @@ pub fn clear_scroll_region() { // this means that when vim exits, we get back the previous scroll // buffer let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -390,7 +390,7 @@ pub fn clear_scroll_region() { #[test] pub fn display_tab_characters_properly() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -419,7 +419,7 @@ pub fn display_tab_characters_properly() { #[test] pub fn neovim_insert_mode() { let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -450,7 +450,7 @@ pub fn bash_cursor_linewrap() { // this test makes sure that when we enter a command that is beyond the screen border, that it // immediately goes down one line let fake_win_size = PositionAndSize { - columns: 116, + cols: 116, rows: 28, x: 0, y: 0, @@ -481,7 +481,7 @@ pub fn fish_paste_multiline() { // here we paste a multiline command in fish shell, making sure we support it // going up and changing the colors of our line-wrapped pasted text let fake_win_size = PositionAndSize { - columns: 149, + cols: 149, rows: 28, x: 0, y: 0, @@ -510,7 +510,7 @@ pub fn fish_paste_multiline() { #[test] pub fn git_log() { let fake_win_size = PositionAndSize { - columns: 149, + cols: 149, rows: 28, x: 0, y: 0, @@ -541,7 +541,7 @@ pub fn git_diff_scrollup() { // this tests makes sure that when we have a git diff that exceeds the screen size // we are able to scroll up let fake_win_size = PositionAndSize { - columns: 149, + cols: 149, rows: 28, x: 0, y: 0, @@ -570,7 +570,7 @@ pub fn git_diff_scrollup() { #[test] pub fn emacs_longbuf() { let fake_win_size = PositionAndSize { - columns: 284, + cols: 284, rows: 60, x: 0, |