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

Add tabs to layouts #625

Merged
merged 35 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5ede25d
Add `tabs` to `layouts`
a-kenji Jul 9, 2021
485339c
Merge branch 'main' of https://github.com/zellij-org/zellij into tab-…
a-kenji Jul 23, 2021
f323880
!fixup cargo fmt
a-kenji Jul 23, 2021
806ffad
fixup! fix e2e fixtures
a-kenji Jul 23, 2021
fc7bc3c
Merge branch 'main' of https://github.com/zellij-org/zellij into tab-…
a-kenji Aug 1, 2021
9a5b669
Add example tab layouts
a-kenji Aug 1, 2021
2e17756
Change layout panics to errors
a-kenji Aug 2, 2021
5799ea4
feat(tab): add keybind to go to last tab visited
sagittarius-a Jul 21, 2021
7346366
fix: rename variable as stated in pull request
sagittarius-a Jul 22, 2021
404faf0
fix: fix toggle to previous tab when deleting tabs
sagittarius-a Jul 23, 2021
081c554
fix: rename action to ToggleTab
sagittarius-a Jul 23, 2021
aff9973
fix: fix clippy warning
sagittarius-a Jul 23, 2021
4f482f3
store tab history in a stack-like data structure
sagittarius-a Aug 2, 2021
24ef96b
fix cargo clippy lint
sagittarius-a Aug 3, 2021
426cee7
docs(governance): arbiter no-confidence vote
imsnif Aug 11, 2021
a37d3e5
feat(ui): pane frames (new pane UI) (#643)
imsnif Aug 12, 2021
da3f20c
fix(compatibility): support changing index colors with osc (#646)
imsnif Aug 13, 2021
e477f3b
fix(child-process): unexpected pane closing issue with nushell (#648)
tw4452852 Aug 16, 2021
fde38dc
docs(changelog): nushell fix
imsnif Aug 16, 2021
e889891
Fix scrolling (#650)
imsnif Aug 19, 2021
2100865
fix(performance): undo degredation introduced in 646 (#651)
imsnif Aug 19, 2021
a4e6e89
fix(compatibility): do not remove frame when clearing viewport (#652)
imsnif Aug 20, 2021
643b7df
fix(compatibility): properly paste multilines (#653)
imsnif Aug 20, 2021
88b4063
Add `template` section in `layout` file
a-kenji Aug 21, 2021
d1b5a69
eliminate unused imports warnings during compile (#654)
tw4452852 Aug 23, 2021
94f20cf
Indicate to the user when text is copied to the clipboard (#642)
tlinford Aug 23, 2021
01c5378
docs(changelog): copy to clipboard UI
imsnif Aug 23, 2021
d969bbf
fix(compatibility): docker-compose progress bar (#656)
imsnif Aug 23, 2021
b1906c8
Merge pull request #622 from sagittarius-a/feature/go-to-last-tab
a-kenji Aug 23, 2021
7a2f86d
docs(changelog): add `ToggleTab` action
a-kenji Aug 23, 2021
618c2c3
Merge branch 'tab-layout' of https://github.com/a-kenji/zellij into a…
imsnif Aug 24, 2021
06e3be6
test(layout): add borderless
imsnif Aug 24, 2021
cd0b011
Split tab-layout into `template` & `tabs` section
a-kenji Aug 26, 2021
8a78f9d
fixup! remove test file
a-kenji Aug 26, 2021
10abb70
fixup! adjust fixture layouts
a-kenji Aug 26, 2021
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
82 changes: 82 additions & 0 deletions example/multiple_tabs_layout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
direction: Horizontal
parts:
- direction: Vertical
split_size:
Fixed: 1
run:
plugin: tab-bar
- direction: Vertical
tabs:
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Horizontal
split_size:
Percent: 50
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
- direction: Vertical
- direction: Vertical
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 20
run:
plugin: strider
- direction: Horizontal
split_size:
Percent: 80
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 40
- direction: Horizontal
split_size:
Percent: 60
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Fixed: 2
run:
plugin: status-bar
85 changes: 85 additions & 0 deletions example/multiple_tabs_layout_htop_command.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
direction: Horizontal
parts:
- direction: Vertical
split_size:
Fixed: 1
run:
plugin: tab-bar
- direction: Vertical
tabs:
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
run:
command: {cmd: htop}
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Horizontal
split_size:
Percent: 50
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
- direction: Vertical
run:
command: {cmd: htop, args: ["-C"]}
- direction: Vertical
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 20
run:
plugin: strider
- direction: Horizontal
split_size:
Percent: 80
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 40
- direction: Horizontal
split_size:
Percent: 60
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Fixed: 2
run:
plugin: status-bar
24 changes: 16 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ pub fn main() {
list_sessions();
}

let (config, layout, config_options) = match Setup::from_options(&opts) {
Ok(results) => results,
Err(e) => {
eprintln!("{}", e);
process::exit(1);
}
};

atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
if let Some(path) = opts.server {
Expand Down Expand Up @@ -62,6 +54,14 @@ pub fn main() {
session_name = Some(get_active_session());
}

let (config, _, config_options) = match Setup::from_options(&opts) {
Ok(results) => results,
Err(e) => {
eprintln!("{}", e);
process::exit(1);
}
};

start_client(
Box::new(os_input),
opts,
Expand All @@ -70,6 +70,14 @@ pub fn main() {
None,
);
} else {
let (config, layout, _) = match Setup::from_options(&opts) {
Ok(results) => results,
Err(e) => {
eprintln!("{}", e);
process::exit(1);
}
};

let session_name = opts
.session
.clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- direction: Horizontal
split_size:
Percent: 50
tabs:
- direction: Horizontal
split_size:
Percent: 80
- direction: Vertical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- direction: Horizontal
split_size:
Percent: 90
- direction: Horizontal
tabs:
- direction: Horizontal
split_size:
Percent: 80
- direction: Vertical
Expand Down
24 changes: 13 additions & 11 deletions src/tests/fixtures/layouts/three-panes-with-nesting.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
direction: Horizontal
parts:
- direction: Vertical
tabs:
- direction: Horizontal
parts:
- direction: Horizontal
split_size:
Percent: 20
- direction: Horizontal
- direction: Vertical
parts:
- direction: Horizontal
split_size:
Percent: 20
- direction: Horizontal
split_size:
Percent: 80
split_size:
Percent: 80
split_size:
Percent: 80
- direction: Vertical
split_size:
Percent: 20
- direction: Vertical
split_size:
Percent: 20
2 changes: 1 addition & 1 deletion zellij-client/src/input_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl InputHandler {
}
Action::CloseFocus
| Action::NewPane(_)
| Action::NewTab
| Action::NewTab(_)
| Action::GoToNextTab
| Action::GoToPreviousTab
| Action::CloseTab
Expand Down
4 changes: 2 additions & 2 deletions zellij-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext},
consts::{SESSION_NAME, ZELLIJ_IPC_PIPE},
errors::{ClientContext, ContextType, ErrorInstruction},
input::{actions::Action, config::Config, layout::Layout, options::Options},
input::{actions::Action, config::Config, layout::MainLayout, options::Options},
ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg},
};

Expand Down Expand Up @@ -87,7 +87,7 @@ pub fn start_client(
opts: CliArgs,
config: Config,
info: ClientInfo,
layout: Option<Layout>,
layout: Option<MainLayout>,
) {
info!("Starting Zellij client!");
let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}12l\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l";
Expand Down
57 changes: 42 additions & 15 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ mod ui;
mod wasm_vm;

use log::info;
use std::{
path::PathBuf,
sync::{Arc, Mutex, RwLock},
thread,
};
use zellij_utils::zellij_tile;

use std::path::PathBuf;
use std::sync::{Arc, Mutex, RwLock};
use std::thread;
use wasmer::Store;
use zellij_tile::data::{Event, Palette, PluginCapabilities};

Expand All @@ -34,7 +36,7 @@ use zellij_utils::{
input::{
command::{RunCommand, TerminalAction},
get_mode_info,
layout::Layout,
layout::MainLayout,
options::Options,
},
ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg},
Expand All @@ -44,7 +46,12 @@ use zellij_utils::{
/// Instructions related to server-side application
#[derive(Debug, Clone)]
pub(crate) enum ServerInstruction {
NewClient(ClientAttributes, Box<CliArgs>, Box<Options>, Option<Layout>),
NewClient(
ClientAttributes,
Box<CliArgs>,
Box<Options>,
Option<MainLayout>,
),
Render(Option<String>),
UnblockInputThread,
ClientExit,
Expand Down Expand Up @@ -207,7 +214,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
to_server.clone(),
client_attributes,
session_state.clone(),
layout,
layout.clone(),
);
*session_data.write().unwrap() = Some(session);
*session_state.write().unwrap() = SessionState::Attached;
Expand All @@ -219,14 +226,34 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
})
});

session_data
.read()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_pty(PtyInstruction::NewTab(default_shell.clone()))
.unwrap();
let spawn_tabs = |tab_layout| {
session_data
.read()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_pty(PtyInstruction::NewTab(default_shell.clone(), tab_layout))
.unwrap()
};

match layout {
None => {
spawn_tabs(None);
}
Some(layout) => {
if !&layout.tabs.is_empty() {
for tab_layout in layout.tabs {
spawn_tabs(Some(tab_layout.clone()));
// Spawning tabs in too quick succession might mess up the layout
// TODO: investigate why
thread::sleep(std::time::Duration::from_millis(250));
}
} else {
spawn_tabs(None);
}
}
}
}
ServerInstruction::AttachClient(attrs, _, options) => {
*session_state.write().unwrap() = SessionState::Attached;
Expand Down Expand Up @@ -302,7 +329,7 @@ fn init_session(
to_server: SenderWithContext<ServerInstruction>,
client_attributes: ClientAttributes,
session_state: Arc<RwLock<SessionState>>,
layout: Option<Layout>,
layout: Option<MainLayout>,
) -> SessionMetaData {
let (to_screen, screen_receiver): ChannelWithContext<ScreenInstruction> = channels::unbounded();
let to_screen = SenderWithContext::new(to_screen);
Expand Down
Loading