mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-26 18:55:26 +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);
|
pty.set_active_pane(pane_id);
|
||||||
}
|
}
|
||||||
PtyInstruction::NewTab(terminal_action, tab_layout) => {
|
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);
|
let merged_layout = layout.template.clone().insert_tab_layout(tab_layout);
|
||||||
pty.spawn_terminals_for_layout(merged_layout.into(), terminal_action.clone());
|
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) => {
|
PtyInstruction::ClosePane(id) => {
|
||||||
pty.close_pane(id);
|
pty.close_pane(id);
|
||||||
|
@ -224,6 +224,8 @@ pub struct TabLayout {
|
|||||||
pub parts: Vec<TabLayout>,
|
pub parts: Vec<TabLayout>,
|
||||||
pub split_size: Option<SplitSize>,
|
pub split_size: Option<SplitSize>,
|
||||||
pub run: Option<Run>,
|
pub run: Option<Run>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layout {
|
impl Layout {
|
||||||
@ -427,6 +429,7 @@ impl Default for TabLayout {
|
|||||||
parts: vec![],
|
parts: vec![],
|
||||||
split_size: None,
|
split_size: None,
|
||||||
run: None,
|
run: None,
|
||||||
|
name: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user