summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNacho114 <17376073+Nacho114@users.noreply.github.com>2023-07-28 17:24:31 +0200
committerGitHub <noreply@github.com>2023-07-28 17:24:31 +0200
commit963120402829393f009247773dfe6fb6f8304fb8 (patch)
treea58200b692bafee533d1702d8c35c9b51cbe68a5
parent859d633f5b89b1c4d0dbe207a9ba514d964f8fa5 (diff)
feat(plugins): utility functions to find active pane and tab (#2652)
-rw-r--r--zellij-tile/src/shim.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs
index bba146894..c12a61528 100644
--- a/zellij-tile/src/shim.rs
+++ b/zellij-tile/src/shim.rs
@@ -372,6 +372,31 @@ pub fn rename_tab<S: AsRef<str>>(tab_position: i32, new_name: S) {
unsafe { host_rename_tab() };
}
+// Utility Functions
+
+/// Returns the `TabInfo` corresponding to the currently active tab
+fn get_focused_tab(tab_infos: &Vec<TabInfo>) -> Option<TabInfo> {
+ for tab_info in tab_infos {
+ if tab_info.active {
+ return Some(tab_info.clone());
+ }
+ }
+ return None;
+}
+
+/// Returns the `PaneInfo` corresponding to the currently active pane (ignoring plugins)
+fn get_focused_pane(tab_position: usize, pane_manifest: &PaneManifest) -> Option<PaneInfo> {
+ let panes = pane_manifest.panes.get(&tab_position);
+ if let Some(panes) = panes {
+ for pane in panes {
+ if pane.is_focused & !pane.is_plugin {
+ return Some(pane.clone());
+ }
+ }
+ }
+ None
+}
+
// Internal Functions
#[doc(hidden)]