mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-26 10:55:12 +03:00
* feat(tab-bar): add option to hide prefix (#2172) * feat(tab-bar): only hide session_name * fix(snapshots): update snapshots with new config-var naming --------- Co-authored-by: Marcel Baur <marcel@baur.gg>
This commit is contained in:
parent
7f1dde5520
commit
6ea5c3666f
@ -223,6 +223,7 @@ pub fn tab_line(
|
||||
cols: usize,
|
||||
palette: Palette,
|
||||
capabilities: PluginCapabilities,
|
||||
hide_session_name: bool,
|
||||
) -> Vec<LinePart> {
|
||||
let mut tabs_after_active = all_tabs.split_off(active_tab_index);
|
||||
let mut tabs_before_active = all_tabs;
|
||||
@ -231,7 +232,10 @@ pub fn tab_line(
|
||||
} else {
|
||||
tabs_before_active.pop().unwrap()
|
||||
};
|
||||
let mut prefix = tab_line_prefix(session_name, palette, cols);
|
||||
let mut prefix = match hide_session_name {
|
||||
true => tab_line_prefix(None, palette, cols),
|
||||
false => tab_line_prefix(session_name, palette, cols),
|
||||
};
|
||||
let prefix_len = get_current_title_len(&prefix);
|
||||
|
||||
// if active tab alone won't fit in cols, don't draw any tabs
|
||||
|
@ -120,6 +120,7 @@ impl ZellijPlugin for State {
|
||||
cols.saturating_sub(1),
|
||||
self.mode_info.style.colors,
|
||||
self.mode_info.capabilities,
|
||||
self.mode_info.style.hide_session_name,
|
||||
);
|
||||
let mut s = String::new();
|
||||
let mut len_cnt = 0;
|
||||
|
@ -167,6 +167,7 @@ pub fn start_client(
|
||||
style: Style {
|
||||
colors: palette,
|
||||
rounded_corners: config.ui.pane_frames.rounded_corners,
|
||||
hide_session_name: config.ui.pane_frames.hide_session_name,
|
||||
},
|
||||
keybinds: config.keybinds.clone(),
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-server/src/./unit/screen_tests.rs
|
||||
assertion_line: 2629
|
||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
---
|
||||
[
|
||||
@ -136,6 +135,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
),
|
||||
},
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
capabilities: PluginCapabilities {
|
||||
arrow_fonts: false,
|
||||
@ -292,6 +292,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
),
|
||||
},
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
capabilities: PluginCapabilities {
|
||||
arrow_fonts: false,
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-server/src/./unit/screen_tests.rs
|
||||
assertion_line: 2672
|
||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
---
|
||||
[
|
||||
@ -136,6 +135,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
),
|
||||
},
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
capabilities: PluginCapabilities {
|
||||
arrow_fonts: false,
|
||||
@ -292,6 +292,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||
),
|
||||
},
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
capabilities: PluginCapabilities {
|
||||
arrow_fonts: false,
|
||||
|
@ -643,6 +643,7 @@ pub struct Palette {
|
||||
pub struct Style {
|
||||
pub colors: Palette,
|
||||
pub rounded_corners: bool,
|
||||
pub hide_session_name: bool,
|
||||
}
|
||||
|
||||
// FIXME: Poor devs hashtable since HashTable can't derive `Default`...
|
||||
|
@ -639,6 +639,7 @@ mod config_test {
|
||||
ui {
|
||||
pane_frames {
|
||||
rounded_corners true
|
||||
hide_session_name true
|
||||
}
|
||||
}
|
||||
"#;
|
||||
@ -646,6 +647,7 @@ mod config_test {
|
||||
let expected_ui_config = UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: true,
|
||||
hide_session_name: true,
|
||||
},
|
||||
};
|
||||
assert_eq!(config.ui, expected_ui_config, "Ui config defined in config");
|
||||
|
@ -25,12 +25,14 @@ impl UiConfig {
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)]
|
||||
pub struct FrameConfig {
|
||||
pub rounded_corners: bool,
|
||||
pub hide_session_name: bool,
|
||||
}
|
||||
|
||||
impl FrameConfig {
|
||||
pub fn merge(&self, other: FrameConfig) -> Self {
|
||||
let mut merged = self.clone();
|
||||
merged.rounded_corners = other.rounded_corners;
|
||||
merged.hide_session_name = other.hide_session_name;
|
||||
merged
|
||||
}
|
||||
}
|
||||
|
@ -1701,7 +1701,12 @@ impl UiConfig {
|
||||
let rounded_corners =
|
||||
kdl_children_property_first_arg_as_bool!(pane_frames, "rounded_corners")
|
||||
.unwrap_or(false);
|
||||
let frame_config = FrameConfig { rounded_corners };
|
||||
let hide_session_name =
|
||||
kdl_get_child_entry_bool_value!(pane_frames, "hide_session_name").unwrap_or(false);
|
||||
let frame_config = FrameConfig {
|
||||
rounded_corners,
|
||||
hide_session_name,
|
||||
};
|
||||
ui_config.pane_frames = frame_config;
|
||||
}
|
||||
Ok(ui_config)
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 621
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -3604,6 +3603,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 679
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -3604,6 +3603,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 696
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -144,6 +143,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 707
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -3618,6 +3617,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 721
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -3908,6 +3907,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: false,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
source: zellij-utils/src/setup.rs
|
||||
assertion_line: 693
|
||||
expression: "format!(\"{:#?}\", config)"
|
||||
---
|
||||
Config {
|
||||
@ -3604,6 +3603,7 @@ Config {
|
||||
ui: UiConfig {
|
||||
pane_frames: FrameConfig {
|
||||
rounded_corners: true,
|
||||
hide_session_name: false,
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
|
Loading…
Reference in New Issue
Block a user