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

feat(screen): support specifying tab's name in layout #715

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions zellij-server/src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions zellij-utils/src/input/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -427,6 +429,7 @@ impl Default for TabLayout {
parts: vec![],
split_size: None,
run: None,
name: String::new(),
}
}
}
Expand Down