diff options
| author | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-05-31 11:07:57 +0200 |
|---|---|---|
| committer | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-05-31 11:07:57 +0200 |
| commit | ec98a29dbc88fcd1f42a7b91c9231da8d8a9ac77 (patch) | |
| tree | f019f95eba11e4a95460be57b3cce9b3f7037bf0 /src | |
| parent | chore: update cargo deps (diff) | |
| download | sl0pstatus-ec98a29dbc88fcd1f42a7b91c9231da8d8a9ac77.tar.gz sl0pstatus-ec98a29dbc88fcd1f42a7b91c9231da8d8a9ac77.tar.xz sl0pstatus-ec98a29dbc88fcd1f42a7b91c9231da8d8a9ac77.zip | |
feat: toggle hide format overlength
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/config.rs b/src/config.rs index 9c7cbd5..f1eb111 100644 --- a/src/config.rs +++ b/src/config.rs @@ -79,6 +79,7 @@ pub struct ModuleConfig { pub hide_frame_for_single_pane: bool, pub border: BorderConfig, pub format_precedence: Vec<Part>, + pub hide_on_overlength: bool, } impl ModuleConfig { @@ -125,6 +126,11 @@ impl ModuleConfig { None => vec![Part::Left, Part::Center, Part::Right], }; + let hide_on_overlength = match config.get("format_hide_on_overlength") { + Some(opt) => opt == "true", + None => false, + }; + let border_config = match parse_border_config(config.clone()) { Some(bc) => bc, None => BorderConfig::default(), @@ -141,6 +147,7 @@ impl ModuleConfig { hide_frame_for_single_pane, border: border_config, format_precedence, + hide_on_overlength, }) } @@ -189,8 +196,10 @@ impl ModuleConfig { ) }); - let (output_left, output_center, output_right) = - self.trim_output(&output_left, &output_center, &output_right, state.cols); + let (output_left, output_center, output_right) = match self.hide_on_overlength { + true => self.trim_output(&output_left, &output_center, &output_right, state.cols), + false => (output_left, output_center, output_right), + }; let mut offset = console::measure_text_width(&output_left); @@ -318,8 +327,10 @@ impl ModuleConfig { ) }); - let (output_left, output_center, output_right) = - self.trim_output(&output_left, &output_center, &output_right, state.cols); + let (output_left, output_center, output_right) = match self.hide_on_overlength { + true => self.trim_output(&output_left, &output_center, &output_right, state.cols), + false => (output_left, output_center, output_right), + }; if self.border.enabled { let mut border_top = "".to_owned(); |
