diff options
| author | Tw <tw19881113@gmail.com> | 2021-09-13 17:56:33 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-13 11:56:33 +0200 |
| commit | da2a9b5c18eeff329d635004644664dadf3634bb (patch) | |
| tree | fe4bf515712ecd7568e5b3a8af7dc5d8b8e069b0 | |
| parent | docs(changelog): fix automated builds that use `setup` (diff) | |
| download | sl0ppij-da2a9b5c18eeff329d635004644664dadf3634bb.tar.gz sl0ppij-da2a9b5c18eeff329d635004644664dadf3634bb.tar.xz sl0ppij-da2a9b5c18eeff329d635004644664dadf3634bb.zip | |
feat(screen): support specifying tab's name in layout (#715)
Signed-off-by: Tw <tw19881113@gmail.com>
| -rw-r--r-- | zellij-server/src/pty.rs | 20 | ||||
| -rw-r--r-- | zellij-utils/src/input/layout.rs | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs index c6857258..e37e6062 100644 --- a/zellij-server/src/pty.rs +++ b/zellij-server/src/pty.rs @@ -95,8 +95,28 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: LayoutFromYaml) { pty.set_active_pane(pane_id); } PtyInstruction::NewTab(terminal_action, tab_layout) => { + let tab_name = tab_layout.as_ref().and_then(|layout| { + if layout.name.is_empty() { + None + } else { + Some(layout.name.clone()) + } + }); + let merged_layout = layout.template.clone().insert_tab_layout(tab_layout); pty.spawn_terminals_for_layout(merged_layout.into(), terminal_action.clone()); + + if let Some(tab_name) = tab_name { + // clear current name at first + pty.bus + .senders + .send_to_screen(ScreenInstruction::UpdateTabName(vec![0])) + .unwrap(); + pty.bus + .senders + .send_to_screen(ScreenInstruction::UpdateTabName(tab_name.into_bytes())) + .unwrap(); + } } PtyInstruction::ClosePane(id) => { pty.close_pane(id); diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 5d4b3492..7d102451 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -224,6 +224,8 @@ pub struct TabLayout { pub parts: Vec<TabLayout>, pub split_size: Option<SplitSize>, pub run: Option<Run>, + #[serde(default)] + pub name: String, } impl Layout { @@ -427,6 +429,7 @@ impl Default for TabLayout { parts: vec![], split_size: None, run: None, + name: String::new(), } } } |
