-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add moving tab to other position (#3047)
* feat: add moving tab to other position * docs(changelog): revert changes * test: update config snapshots * refactor: get rid of HorizontalDirection enum * refactor: cleanup code order * refactor: use debug! instead of info! * refactor: use more defensive way to switch tabs * refactor: revert tip changes * refactor: code formatting * refactor: improve invalid input notification * refactor: inline fns for calculating target index --------- Co-authored-by: Jae-Heon Ji <atx6419@gmail.com>
- Loading branch information
Showing
31 changed files
with
2,007 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use ansi_term::{ | ||
unstyled_len, ANSIString, ANSIStrings, | ||
Color::{Fixed, RGB}, | ||
Style, | ||
}; | ||
|
||
use zellij_tile::prelude::*; | ||
use zellij_tile_utils::palette_match; | ||
|
||
use crate::LinePart; | ||
|
||
macro_rules! strings { | ||
($ANSIStrings:expr) => {{ | ||
let strings: &[ANSIString] = $ANSIStrings; | ||
|
||
let ansi_strings = ANSIStrings(strings); | ||
|
||
LinePart { | ||
part: format!("{}", ansi_strings), | ||
len: unstyled_len(&ansi_strings), | ||
} | ||
}}; | ||
} | ||
|
||
pub fn move_tabs_full(help: &ModeInfo) -> LinePart { | ||
// Tip: Wrong order of tabs? You can move them to left and right with: | ||
// Alt + i (left) and Alt + o (right) | ||
let green_color = palette_match!(help.style.colors.green); | ||
|
||
let bits = vec![ | ||
Style::new().paint(" Tip: "), | ||
Style::new().paint("Wrong order of tabs? You can move them to left and right with: "), | ||
Style::new().fg(green_color).bold().paint("Alt + i"), | ||
Style::new().paint(" (left) and "), | ||
Style::new().fg(green_color).bold().paint("Alt + o"), | ||
Style::new().paint(" (right)"), | ||
]; | ||
strings!(&bits) | ||
} | ||
|
||
pub fn move_tabs_medium(help: &ModeInfo) -> LinePart { | ||
// Tip: You can move tabs to left and right with: | ||
// Alt + i (left) and Alt + o (right) | ||
let green_color = palette_match!(help.style.colors.green); | ||
|
||
let bits = vec![ | ||
Style::new().paint(" Tip: "), | ||
Style::new().paint("You can move tabs to left and right with: "), | ||
Style::new().fg(green_color).bold().paint("Alt + i"), | ||
Style::new().paint(" (left) and "), | ||
Style::new().fg(green_color).bold().paint("Alt + o"), | ||
Style::new().paint(" (right)"), | ||
]; | ||
strings!(&bits) | ||
} | ||
|
||
pub fn move_tabs_short(help: &ModeInfo) -> LinePart { | ||
// Move tabs with: Alt + i (left) and Alt + o (right) | ||
let green_color = palette_match!(help.style.colors.green); | ||
|
||
let bits = vec![ | ||
Style::new().paint(" Move tabs with: "), | ||
Style::new().fg(green_color).bold().paint("Alt + i"), | ||
Style::new().paint(" (left) and "), | ||
Style::new().fg(green_color).bold().paint("Alt + o"), | ||
Style::new().paint(" (right)"), | ||
]; | ||
strings!(&bits) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod cases; | ||
mod remote_runner; | ||
mod steps; |
29 changes: 29 additions & 0 deletions
29
src/tests/e2e/snapshots/zellij__tests__e2e__cases__move_tab_to_left.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
source: src/tests/e2e/cases.rs | ||
assertion_line: 531 | ||
expression: account_for_races_in_snapshot(last_snapshot) | ||
--- | ||
Zellij (e2e-test) Tab #1 Tab #3 Tab #2 | ||
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│$ █ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
Ctrl + <g> LOCK <p> PANE <t> TAB <n> RESIZE <h> MOVE <s> SEARCH <o> SESSION <q> QUIT | ||
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane. |
28 changes: 28 additions & 0 deletions
28
...ests/e2e/snapshots/zellij__tests__e2e__cases__move_tab_to_left_until_it_wraps_around.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
source: src/tests/e2e/cases.rs | ||
expression: account_for_races_in_snapshot(last_snapshot) | ||
--- | ||
Zellij (e2e-test) Tab #2 Tab #1 Tab #3 | ||
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│$ █ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
Ctrl + <g> LOCK <p> PANE <t> TAB <n> RESIZE <h> MOVE <s> SEARCH <o> SESSION <q> QUIT | ||
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane. |
29 changes: 29 additions & 0 deletions
29
src/tests/e2e/snapshots/zellij__tests__e2e__cases__move_tab_to_right.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
source: src/tests/e2e/cases.rs | ||
assertion_line: 624 | ||
expression: account_for_races_in_snapshot(last_snapshot) | ||
--- | ||
Zellij (e2e-test) Tab #1 Tab #3 Tab #2 | ||
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│$ Tab #2 content█ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
│ │ | ||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
Ctrl + <g> LOCK <p> PANE <t> TAB <n> RESIZE <h> MOVE <s> SEARCH <o> SESSION <q> QUIT | ||
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane. |
Oops, something went wrong.