diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-08-07 19:20:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-07 19:20:41 +0200 |
| commit | d44950a5bd15eb3dae6804ea527181204946ee5b (patch) | |
| tree | bfdf5e6c5bc46140e6eca533d8b48f1ae227d2a9 /zellij-server/src/tab | |
| parent | docs(changelog): floating_panes cwd fix (diff) | |
| download | sl0ppij-d44950a5bd15eb3dae6804ea527181204946ee5b.tar.gz sl0ppij-d44950a5bd15eb3dae6804ea527181204946ee5b.tar.xz sl0ppij-d44950a5bd15eb3dae6804ea527181204946ee5b.zip | |
feat(plugins): rerun_command_pane API (#3546)
* feat(plugins): rerun_command_pane API
* fix tests
Diffstat (limited to 'zellij-server/src/tab')
| -rw-r--r-- | zellij-server/src/tab/layout_applier.rs | 2 | ||||
| -rw-r--r-- | zellij-server/src/tab/mod.rs | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/zellij-server/src/tab/layout_applier.rs b/zellij-server/src/tab/layout_applier.rs index 0a001af3..ff33abb9 100644 --- a/zellij-server/src/tab/layout_applier.rs +++ b/zellij-server/src/tab/layout_applier.rs @@ -399,7 +399,7 @@ impl<'a> LayoutApplier<'a> { .with_context(err_context)? .clone(), pane_title, - layout_name.clone().unwrap_or_default(), + floating_pane_layout.name.clone().unwrap_or_default(), self.sixel_image_store.clone(), self.terminal_emulator_colors.clone(), self.terminal_emulator_color_codes.clone(), diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index 6b7a2192..e08110b0 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -489,6 +489,9 @@ pub trait Pane { fn serialize(&self, _scrollback_lines_to_serialize: Option<usize>) -> Option<String> { None } + fn rerun(&mut self) -> Option<RunCommand> { + None + } // only relevant to terminal panes } #[derive(Clone, Debug)] @@ -3921,6 +3924,33 @@ impl Tab { plugin_pane.request_permissions_from_user(permissions); } } + pub fn rerun_terminal_pane_with_id(&mut self, terminal_pane_id: u32) { + let pane_id = PaneId::Terminal(terminal_pane_id); + match self + .floating_panes + .get_mut(&pane_id) + .or_else(|| self.tiled_panes.get_pane_mut(pane_id)) + .or_else(|| self.suppressed_panes.get_mut(&pane_id).map(|p| &mut p.1)) + { + Some(pane_to_rerun) => { + if let Some(command_to_rerun) = pane_to_rerun.rerun() { + self.pids_waiting_resize.insert(terminal_pane_id); + let _ = self.senders.send_to_pty(PtyInstruction::ReRunCommandInPane( + pane_id, + command_to_rerun, + )); + } else { + log::error!("Pane is still running!") + } + }, + None => { + log::error!( + "Failed to find terminal pane with id {} to rerun in tab", + terminal_pane_id + ); + }, + } + } } pub fn pane_info_for_pane(pane_id: &PaneId, pane: &Box<dyn Pane>) -> PaneInfo { |
