blob: b97272879218fa38f8494a47b6e5162882ecf136 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
use zellij_tile::prelude::*;
pub fn hide_frames_on_single_pane(
tabs: Vec<TabInfo>,
pane_info: PaneManifest,
plugin_pane_id: PluginIds,
) {
let panes = get_current_panes(tabs, pane_info);
if panes.is_none() {
return;
}
let panes = panes.unwrap();
// check if we are running for the current tab since one plugin will run for
// each tab. If we do not prevent execution, the screen will start to flicker
// 'cause every plugin will try to toggle the frames
if !is_plugin_for_current_tab(panes.clone(), plugin_pane_id) {
return;
}
let panes: Vec<&PaneInfo> = panes.iter().filter(|p| !p.is_plugin).collect();
let first_content_pane = panes.first();
if first_content_pane.is_none() {
return;
}
let first_pane = first_content_pane.unwrap();
// frame is enabled, when content does no start at [0, 0]. With default frames
// it's [1, 1]
let frame_enabled = first_pane.pane_content_x > 0;
if panes.len() == 1 && frame_enabled {
toggle_pane_frames();
}
if panes.len() > 1 && !frame_enabled {
toggle_pane_frames();
}
}
fn is_plugin_for_current_tab(panes: Vec<PaneInfo>, plugin_pane_id: PluginIds) -> bool {
let plugin_pane = panes
.iter()
.find(|p| p.is_plugin && p.id == plugin_pane_id.plugin_id);
plugin_pane.is_some()
}
fn get_current_panes(tabs: Vec<TabInfo>, pane_info: PaneManifest) -> Option<Vec<PaneInfo>> {
let active_tab = tabs.iter().find(|t| t.active);
let active_tab = active_tab.as_ref()?;
pane_info
.panes
.get(&active_tab.position)
.map(|p| (*p).clone())
}
|