aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Jankowski <daniel.jankowski@rub.de>2025-01-02 20:41:41 +0100
committerDaniel Jankowski <daniel.jankowski@rub.de>2025-01-02 20:41:41 +0100
commitbc15143d662f2c22fced866b0376d360ebc5f36c (patch)
treea1c12d8afbc2b6f5dfeb2b8814aff456bd009433 /src
parentchore: bump version to v0.19.2 (diff)
downloadsl0pstatus-bc15143d662f2c22fced866b0376d360ebc5f36c.tar.gz
sl0pstatus-bc15143d662f2c22fced866b0376d360ebc5f36c.tar.xz
sl0pstatus-bc15143d662f2c22fced866b0376d360ebc5f36c.zip
chore: fix linting issue
Diffstat (limited to 'src')
-rw-r--r--src/bin/zjframes.rs24
-rw-r--r--src/bin/zjstatus.rs16
-rw-r--r--src/frames.rs41
3 files changed, 56 insertions, 25 deletions
diff --git a/src/bin/zjframes.rs b/src/bin/zjframes.rs
index 79611b4..b8edbb8 100644
--- a/src/bin/zjframes.rs
+++ b/src/bin/zjframes.rs
@@ -136,9 +136,11 @@ impl State {
self.state.mode = mode_info;
frames::hide_frames_conditionally(
- self.hide_frame_for_single_pane,
- self.hide_frame_except_for_search,
- self.hide_frame_except_for_fullscreen,
+ &frames::FrameConfig::new(
+ self.hide_frame_for_single_pane,
+ self.hide_frame_except_for_search,
+ self.hide_frame_except_for_fullscreen,
+ ),
&self.state.tabs,
&self.state.panes,
&self.state.mode,
@@ -153,9 +155,11 @@ impl State {
self.state.panes = pane_info;
frames::hide_frames_conditionally(
- self.hide_frame_for_single_pane,
- self.hide_frame_except_for_search,
- self.hide_frame_except_for_fullscreen,
+ &frames::FrameConfig::new(
+ self.hide_frame_for_single_pane,
+ self.hide_frame_except_for_search,
+ self.hide_frame_except_for_fullscreen,
+ ),
&self.state.tabs,
&self.state.panes,
&self.state.mode,
@@ -176,9 +180,11 @@ impl State {
if let Some(current_session) = current_session {
frames::hide_frames_conditionally(
- self.hide_frame_for_single_pane,
- self.hide_frame_except_for_search,
- self.hide_frame_except_for_fullscreen,
+ &frames::FrameConfig::new(
+ self.hide_frame_for_single_pane,
+ self.hide_frame_except_for_search,
+ self.hide_frame_except_for_fullscreen,
+ ),
&current_session.tabs,
&current_session.panes,
&self.state.mode,
diff --git a/src/bin/zjstatus.rs b/src/bin/zjstatus.rs
index aa95ecf..30a40b0 100644
--- a/src/bin/zjstatus.rs
+++ b/src/bin/zjstatus.rs
@@ -201,9 +201,11 @@ impl State {
tracing::debug!(pane_count = ?pane_info.panes.len());
frames::hide_frames_conditionally(
- self.module_config.hide_frame_for_single_pane,
- self.module_config.hide_frame_except_for_search,
- self.module_config.hide_frame_except_for_fullscreen,
+ &frames::FrameConfig::new(
+ self.module_config.hide_frame_for_single_pane,
+ self.module_config.hide_frame_except_for_search,
+ self.module_config.hide_frame_except_for_fullscreen,
+ ),
&self.state.tabs,
&pane_info,
&self.state.mode,
@@ -261,9 +263,11 @@ impl State {
if let Some(current_session) = current_session {
frames::hide_frames_conditionally(
- self.module_config.hide_frame_for_single_pane,
- self.module_config.hide_frame_except_for_search,
- self.module_config.hide_frame_except_for_fullscreen,
+ &frames::FrameConfig::new(
+ self.module_config.hide_frame_for_single_pane,
+ self.module_config.hide_frame_except_for_search,
+ self.module_config.hide_frame_except_for_fullscreen,
+ ),
&current_session.tabs,
&current_session.panes,
&self.state.mode,
diff --git a/src/frames.rs b/src/frames.rs
index 368d598..4ad1f9c 100644
--- a/src/frames.rs
+++ b/src/frames.rs
@@ -1,20 +1,41 @@
use zellij_tile::prelude::*;
+pub struct FrameConfig {
+ pub hide_frames_for_single_pane: bool,
+ pub hide_frames_except_for_search: bool,
+ pub hide_frames_except_for_fullscreen: bool,
+}
+
+impl FrameConfig {
+ pub fn new(
+ hide_frames_for_single_pane: bool,
+ hide_frames_except_for_search: bool,
+ hide_frames_except_for_fullscreen: bool,
+ ) -> Self {
+ Self {
+ hide_frames_for_single_pane,
+ hide_frames_except_for_search,
+ hide_frames_except_for_fullscreen,
+ }
+ }
+
+ pub fn is_disabled(&self) -> bool {
+ !self.hide_frames_for_single_pane
+ && !self.hide_frames_except_for_search
+ && !self.hide_frames_except_for_fullscreen
+ }
+}
+
#[tracing::instrument(skip_all)]
pub fn hide_frames_conditionally(
- cfg_hide_frames_for_single_pane: bool,
- cfg_hide_frames_except_for_search: bool,
- cfg_hide_frames_except_for_fullscreen: bool,
+ config: &FrameConfig,
tabs: &[TabInfo],
pane_info: &PaneManifest,
mode_info: &ModeInfo,
plugin_pane_id: PluginIds,
is_zjframes: bool,
) {
- if !cfg_hide_frames_for_single_pane
- && !cfg_hide_frames_except_for_search
- && !cfg_hide_frames_except_for_fullscreen
- {
+ if config.is_disabled() {
return;
}
@@ -41,11 +62,11 @@ pub fn hide_frames_conditionally(
let frame_enabled = panes.iter().any(|p| p.pane_content_x - p.pane_x > 0);
let frames_for_search =
- cfg_hide_frames_except_for_search && should_show_frames_for_search(mode_info);
+ config.hide_frames_except_for_search && should_show_frames_for_search(mode_info);
let frames_for_fullscreen =
- cfg_hide_frames_except_for_fullscreen && should_show_frames_for_fullscreen(&panes);
+ config.hide_frames_except_for_fullscreen && should_show_frames_for_fullscreen(&panes);
let frames_for_single_pane =
- cfg_hide_frames_for_single_pane && should_show_frames_for_multiple_panes(mode_info, &panes);
+ config.hide_frames_for_single_pane && should_show_frames_for_multiple_panes(mode_info, &panes);
if (frames_for_search || frames_for_fullscreen || frames_for_single_pane) && !frame_enabled {
toggle_pane_frames();