* 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
15 changed files with 28 additions and 10 deletions
|
|
@ -223,6 +223,7 @@ pub fn tab_line(
|
||||||
cols: usize,
|
cols: usize,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
capabilities: PluginCapabilities,
|
capabilities: PluginCapabilities,
|
||||||
|
hide_session_name: bool,
|
||||||
) -> Vec<LinePart> {
|
) -> Vec<LinePart> {
|
||||||
let mut tabs_after_active = all_tabs.split_off(active_tab_index);
|
let mut tabs_after_active = all_tabs.split_off(active_tab_index);
|
||||||
let mut tabs_before_active = all_tabs;
|
let mut tabs_before_active = all_tabs;
|
||||||
|
|
@ -231,7 +232,10 @@ pub fn tab_line(
|
||||||
} else {
|
} else {
|
||||||
tabs_before_active.pop().unwrap()
|
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);
|
let prefix_len = get_current_title_len(&prefix);
|
||||||
|
|
||||||
// if active tab alone won't fit in cols, don't draw any tabs
|
// 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),
|
cols.saturating_sub(1),
|
||||||
self.mode_info.style.colors,
|
self.mode_info.style.colors,
|
||||||
self.mode_info.capabilities,
|
self.mode_info.capabilities,
|
||||||
|
self.mode_info.style.hide_session_name,
|
||||||
);
|
);
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let mut len_cnt = 0;
|
let mut len_cnt = 0;
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ pub fn start_client(
|
||||||
style: Style {
|
style: Style {
|
||||||
colors: palette,
|
colors: palette,
|
||||||
rounded_corners: config.ui.pane_frames.rounded_corners,
|
rounded_corners: config.ui.pane_frames.rounded_corners,
|
||||||
|
hide_session_name: config.ui.pane_frames.hide_session_name,
|
||||||
},
|
},
|
||||||
keybinds: config.keybinds.clone(),
|
keybinds: config.keybinds.clone(),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2629
|
|
||||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -136,6 +135,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
capabilities: PluginCapabilities {
|
capabilities: PluginCapabilities {
|
||||||
arrow_fonts: false,
|
arrow_fonts: false,
|
||||||
|
|
@ -292,6 +292,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
capabilities: PluginCapabilities {
|
capabilities: PluginCapabilities {
|
||||||
arrow_fonts: false,
|
arrow_fonts: false,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2672
|
|
||||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -136,6 +135,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
capabilities: PluginCapabilities {
|
capabilities: PluginCapabilities {
|
||||||
arrow_fonts: false,
|
arrow_fonts: false,
|
||||||
|
|
@ -292,6 +292,7 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
capabilities: PluginCapabilities {
|
capabilities: PluginCapabilities {
|
||||||
arrow_fonts: false,
|
arrow_fonts: false,
|
||||||
|
|
|
||||||
|
|
@ -643,6 +643,7 @@ pub struct Palette {
|
||||||
pub struct Style {
|
pub struct Style {
|
||||||
pub colors: Palette,
|
pub colors: Palette,
|
||||||
pub rounded_corners: bool,
|
pub rounded_corners: bool,
|
||||||
|
pub hide_session_name: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Poor devs hashtable since HashTable can't derive `Default`...
|
// FIXME: Poor devs hashtable since HashTable can't derive `Default`...
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,7 @@ mod config_test {
|
||||||
ui {
|
ui {
|
||||||
pane_frames {
|
pane_frames {
|
||||||
rounded_corners true
|
rounded_corners true
|
||||||
|
hide_session_name true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
@ -646,6 +647,7 @@ mod config_test {
|
||||||
let expected_ui_config = UiConfig {
|
let expected_ui_config = UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: true,
|
rounded_corners: true,
|
||||||
|
hide_session_name: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert_eq!(config.ui, expected_ui_config, "Ui config defined in config");
|
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)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct FrameConfig {
|
pub struct FrameConfig {
|
||||||
pub rounded_corners: bool,
|
pub rounded_corners: bool,
|
||||||
|
pub hide_session_name: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FrameConfig {
|
impl FrameConfig {
|
||||||
pub fn merge(&self, other: FrameConfig) -> Self {
|
pub fn merge(&self, other: FrameConfig) -> Self {
|
||||||
let mut merged = self.clone();
|
let mut merged = self.clone();
|
||||||
merged.rounded_corners = other.rounded_corners;
|
merged.rounded_corners = other.rounded_corners;
|
||||||
|
merged.hide_session_name = other.hide_session_name;
|
||||||
merged
|
merged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1701,7 +1701,12 @@ impl UiConfig {
|
||||||
let rounded_corners =
|
let rounded_corners =
|
||||||
kdl_children_property_first_arg_as_bool!(pane_frames, "rounded_corners")
|
kdl_children_property_first_arg_as_bool!(pane_frames, "rounded_corners")
|
||||||
.unwrap_or(false);
|
.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;
|
ui_config.pane_frames = frame_config;
|
||||||
}
|
}
|
||||||
Ok(ui_config)
|
Ok(ui_config)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 621
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -3604,6 +3603,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 679
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -3604,6 +3603,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 696
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -144,6 +143,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 707
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -3618,6 +3617,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 721
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -3908,6 +3907,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: false,
|
rounded_corners: false,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/setup.rs
|
source: zellij-utils/src/setup.rs
|
||||||
assertion_line: 693
|
|
||||||
expression: "format!(\"{:#?}\", config)"
|
expression: "format!(\"{:#?}\", config)"
|
||||||
---
|
---
|
||||||
Config {
|
Config {
|
||||||
|
|
@ -3604,6 +3603,7 @@ Config {
|
||||||
ui: UiConfig {
|
ui: UiConfig {
|
||||||
pane_frames: FrameConfig {
|
pane_frames: FrameConfig {
|
||||||
rounded_corners: true,
|
rounded_corners: true,
|
||||||
|
hide_session_name: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue