mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-26 02:32:21 +03:00
feat(screen): support specifying tab's name in layout (#715)
Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
parent
7c959ee3a2
commit
da2a9b5c18
@ -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);
|
||||
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user