diff options
author | 哇呜哇呜呀咦耶 <pingao777@gmail.com> | 2023-02-07 22:45:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 15:45:59 +0100 |
commit | 99e8d56adb50b1b2921d4af01972c4b9fd8b6105 (patch) | |
tree | 4dc9da5729cd083c5ff1219aa1b4ec3b3573db15 /zellij-utils | |
parent | 601eee8bb3e1d57d8a5df2b04d15506bc2aa92eb (diff) |
feat(cli): add `GoToTabName` action to switch tab by name (#2120)
* Add `GoToTabName` action to switch tab by name
* rm blank file
* add --create option
* format
* add some doc
* add test case
* format
* add test case
* change variable name
Diffstat (limited to 'zellij-utils')
-rw-r--r-- | zellij-utils/src/cli.rs | 7 | ||||
-rw-r--r-- | zellij-utils/src/errors.rs | 1 | ||||
-rw-r--r-- | zellij-utils/src/input/actions.rs | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 82c34eecd..1ef43e27f 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -315,6 +315,13 @@ pub enum CliAction { CloseTab, /// Go to tab with index [index] GoToTab { index: u32 }, + /// Go to tab with name [name] + GoToTabName { + name: String, + /// Create a tab if one does not exist. + #[clap(short, long, value_parser)] + create: bool, + }, /// Renames the focused pane RenameTab { name: String }, /// Remove a previously set tab name diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index 50c8f9b28..a7986de8d 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -285,6 +285,7 @@ pub enum ScreenContext { SwitchTabPrev, CloseTab, GoToTab, + GoToTabName, UpdateTabName, UndoRenameTab, TerminalResize, diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index 1207023aa..b5d6acb13 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -174,6 +174,7 @@ pub enum Action { /// Close the current tab. CloseTab, GoToTab(u32), + GoToTabName(String, bool), ToggleTab, TabNameInput(Vec<u8>), UndoRenameTab, @@ -321,6 +322,7 @@ impl Action { CliAction::GoToPreviousTab => Ok(vec![Action::GoToPreviousTab]), CliAction::CloseTab => Ok(vec![Action::CloseTab]), CliAction::GoToTab { index } => Ok(vec![Action::GoToTab(index)]), + CliAction::GoToTabName { name, create } => Ok(vec![Action::GoToTabName(name, create)]), CliAction::RenameTab { name } => Ok(vec![ Action::TabNameInput(vec![0]), Action::TabNameInput(name.as_bytes().to_vec()), |