mirror of
https://github.com/sayanarijit/xplr
synced 2024-11-10 07:10:45 +00:00
Fix UI style priority
Fixes: https://github.com/sayanarijit/xplr/issues/68
This commit is contained in:
parent
54bad4aa09
commit
3ab9bcb4c9
@ -38,7 +38,7 @@ pub struct NodeTypeConfig {
|
||||
|
||||
impl NodeTypeConfig {
|
||||
pub fn extend(mut self, other: Self) -> Self {
|
||||
self.style = other.style.extend(self.style);
|
||||
self.style = self.style.extend(other.style);
|
||||
self.meta.extend(other.meta);
|
||||
self
|
||||
}
|
||||
|
39
src/ui.rs
39
src/ui.rs
@ -180,14 +180,6 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
|
||||
// TODO : Optimize
|
||||
let is_selected = app.selection().contains(&node);
|
||||
|
||||
let ui = if is_focused {
|
||||
&config.general.focus_ui
|
||||
} else if is_selected {
|
||||
&config.general.selection_ui
|
||||
} else {
|
||||
&config.general.default_ui
|
||||
};
|
||||
|
||||
let is_first = index == 0;
|
||||
let is_last = index == dir.total.max(1) - 1;
|
||||
|
||||
@ -230,6 +222,25 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
|
||||
Ordering::Equal => (0, false, false),
|
||||
};
|
||||
|
||||
let (mut prefix, mut suffix, mut style) = {
|
||||
let ui = config.general.default_ui.clone();
|
||||
(ui.prefix, ui.suffix, ui.style.extend(node_type.style))
|
||||
};
|
||||
|
||||
if is_selected {
|
||||
let ui = config.general.selection_ui.clone();
|
||||
prefix = ui.prefix.or(prefix);
|
||||
suffix = ui.suffix.or(suffix);
|
||||
style = style.extend(ui.style);
|
||||
};
|
||||
|
||||
if is_focused {
|
||||
let ui = config.general.focus_ui.clone();
|
||||
prefix = ui.prefix.or(prefix);
|
||||
suffix = ui.suffix.or(suffix);
|
||||
style = style.extend(ui.style);
|
||||
};
|
||||
|
||||
let meta = NodeUiMetadata::new(
|
||||
&node,
|
||||
index,
|
||||
@ -237,8 +248,8 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
|
||||
is_before_focus,
|
||||
is_after_focus,
|
||||
tree.unwrap_or_default(),
|
||||
ui.prefix.to_owned().unwrap_or_default(),
|
||||
ui.suffix.to_owned().unwrap_or_default(),
|
||||
prefix.unwrap_or_default(),
|
||||
suffix.unwrap_or_default(),
|
||||
is_selected,
|
||||
is_focused,
|
||||
dir.total,
|
||||
@ -253,14 +264,6 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
|
||||
.map(|x| Cell::from(x.to_string()))
|
||||
.collect::<Vec<Cell>>();
|
||||
|
||||
let style = if is_focused {
|
||||
config.general.focus_ui.style.extend(node_type.style)
|
||||
} else if is_selected {
|
||||
config.general.selection_ui.style.extend(node_type.style)
|
||||
} else {
|
||||
config.general.default_ui.style.extend(node_type.style)
|
||||
};
|
||||
|
||||
Row::new(cols).style(style.into())
|
||||
})
|
||||
.collect::<Vec<Row>>()
|
||||
|
Loading…
Reference in New Issue
Block a user