Skip to content

Commit

Permalink
chore: fix linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dj95 committed Jan 2, 2025
1 parent e7fdc9b commit bc15143
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 25 deletions.
24 changes: 15 additions & 9 deletions src/bin/zjframes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
16 changes: 10 additions & 6 deletions src/bin/zjstatus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
41 changes: 31 additions & 10 deletions src/frames.rs
Original file line number Diff line number Diff line change
@@ -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;
}

Expand All @@ -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();
Expand Down

0 comments on commit bc15143

Please sign in to comment.