Skip to content

Commit bc15143

Browse files
committed
chore: fix linting issue
1 parent e7fdc9b commit bc15143

File tree

3 files changed

+56
-25
lines changed

3 files changed

+56
-25
lines changed

src/bin/zjframes.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ impl State {
136136
self.state.mode = mode_info;
137137

138138
frames::hide_frames_conditionally(
139-
self.hide_frame_for_single_pane,
140-
self.hide_frame_except_for_search,
141-
self.hide_frame_except_for_fullscreen,
139+
&frames::FrameConfig::new(
140+
self.hide_frame_for_single_pane,
141+
self.hide_frame_except_for_search,
142+
self.hide_frame_except_for_fullscreen,
143+
),
142144
&self.state.tabs,
143145
&self.state.panes,
144146
&self.state.mode,
@@ -153,9 +155,11 @@ impl State {
153155
self.state.panes = pane_info;
154156

155157
frames::hide_frames_conditionally(
156-
self.hide_frame_for_single_pane,
157-
self.hide_frame_except_for_search,
158-
self.hide_frame_except_for_fullscreen,
158+
&frames::FrameConfig::new(
159+
self.hide_frame_for_single_pane,
160+
self.hide_frame_except_for_search,
161+
self.hide_frame_except_for_fullscreen,
162+
),
159163
&self.state.tabs,
160164
&self.state.panes,
161165
&self.state.mode,
@@ -176,9 +180,11 @@ impl State {
176180

177181
if let Some(current_session) = current_session {
178182
frames::hide_frames_conditionally(
179-
self.hide_frame_for_single_pane,
180-
self.hide_frame_except_for_search,
181-
self.hide_frame_except_for_fullscreen,
183+
&frames::FrameConfig::new(
184+
self.hide_frame_for_single_pane,
185+
self.hide_frame_except_for_search,
186+
self.hide_frame_except_for_fullscreen,
187+
),
182188
&current_session.tabs,
183189
&current_session.panes,
184190
&self.state.mode,

src/bin/zjstatus.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,11 @@ impl State {
201201
tracing::debug!(pane_count = ?pane_info.panes.len());
202202

203203
frames::hide_frames_conditionally(
204-
self.module_config.hide_frame_for_single_pane,
205-
self.module_config.hide_frame_except_for_search,
206-
self.module_config.hide_frame_except_for_fullscreen,
204+
&frames::FrameConfig::new(
205+
self.module_config.hide_frame_for_single_pane,
206+
self.module_config.hide_frame_except_for_search,
207+
self.module_config.hide_frame_except_for_fullscreen,
208+
),
207209
&self.state.tabs,
208210
&pane_info,
209211
&self.state.mode,
@@ -261,9 +263,11 @@ impl State {
261263

262264
if let Some(current_session) = current_session {
263265
frames::hide_frames_conditionally(
264-
self.module_config.hide_frame_for_single_pane,
265-
self.module_config.hide_frame_except_for_search,
266-
self.module_config.hide_frame_except_for_fullscreen,
266+
&frames::FrameConfig::new(
267+
self.module_config.hide_frame_for_single_pane,
268+
self.module_config.hide_frame_except_for_search,
269+
self.module_config.hide_frame_except_for_fullscreen,
270+
),
267271
&current_session.tabs,
268272
&current_session.panes,
269273
&self.state.mode,

src/frames.rs

+31-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
use zellij_tile::prelude::*;
22

3+
pub struct FrameConfig {
4+
pub hide_frames_for_single_pane: bool,
5+
pub hide_frames_except_for_search: bool,
6+
pub hide_frames_except_for_fullscreen: bool,
7+
}
8+
9+
impl FrameConfig {
10+
pub fn new(
11+
hide_frames_for_single_pane: bool,
12+
hide_frames_except_for_search: bool,
13+
hide_frames_except_for_fullscreen: bool,
14+
) -> Self {
15+
Self {
16+
hide_frames_for_single_pane,
17+
hide_frames_except_for_search,
18+
hide_frames_except_for_fullscreen,
19+
}
20+
}
21+
22+
pub fn is_disabled(&self) -> bool {
23+
!self.hide_frames_for_single_pane
24+
&& !self.hide_frames_except_for_search
25+
&& !self.hide_frames_except_for_fullscreen
26+
}
27+
}
28+
329
#[tracing::instrument(skip_all)]
430
pub fn hide_frames_conditionally(
5-
cfg_hide_frames_for_single_pane: bool,
6-
cfg_hide_frames_except_for_search: bool,
7-
cfg_hide_frames_except_for_fullscreen: bool,
31+
config: &FrameConfig,
832
tabs: &[TabInfo],
933
pane_info: &PaneManifest,
1034
mode_info: &ModeInfo,
1135
plugin_pane_id: PluginIds,
1236
is_zjframes: bool,
1337
) {
14-
if !cfg_hide_frames_for_single_pane
15-
&& !cfg_hide_frames_except_for_search
16-
&& !cfg_hide_frames_except_for_fullscreen
17-
{
38+
if config.is_disabled() {
1839
return;
1940
}
2041

@@ -41,11 +62,11 @@ pub fn hide_frames_conditionally(
4162
let frame_enabled = panes.iter().any(|p| p.pane_content_x - p.pane_x > 0);
4263

4364
let frames_for_search =
44-
cfg_hide_frames_except_for_search && should_show_frames_for_search(mode_info);
65+
config.hide_frames_except_for_search && should_show_frames_for_search(mode_info);
4566
let frames_for_fullscreen =
46-
cfg_hide_frames_except_for_fullscreen && should_show_frames_for_fullscreen(&panes);
67+
config.hide_frames_except_for_fullscreen && should_show_frames_for_fullscreen(&panes);
4768
let frames_for_single_pane =
48-
cfg_hide_frames_for_single_pane && should_show_frames_for_multiple_panes(mode_info, &panes);
69+
config.hide_frames_for_single_pane && should_show_frames_for_multiple_panes(mode_info, &panes);
4970

5071
if (frames_for_search || frames_for_fullscreen || frames_for_single_pane) && !frame_enabled {
5172
toggle_pane_frames();

0 commit comments

Comments
 (0)