diff --git a/src/core/json/render.rs b/src/core/json/render.rs index 1c0b5c4b..7ae33e67 100644 --- a/src/core/json/render.rs +++ b/src/core/json/render.rs @@ -3,7 +3,7 @@ use std::any::Any; use crate::{ crossterm::{ event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers}, - style::{Color, ContentStyle}, + style::{Attribute, Attributes, ContentStyle}, }, grapheme::{trim, Graphemes}, pane::Pane, @@ -34,11 +34,6 @@ pub struct Renderer { /// Style for boolean values. pub boolean_value_style: ContentStyle, - /// Style for the selected line. - pub active_item_background_color: Color, - /// Style for un-selected lines. - pub inactive_item_background_color: Color, - /// Number of lines available for rendering. pub lines: Option, @@ -178,10 +173,9 @@ impl Renderable for Renderer { .map(|(i, kind)| { if i == self.json.position() { Graphemes::from_iter([Graphemes::from(" ".repeat(indent(kind))), syntax(kind)]) - .stylize_all_backgrounds(self.active_item_background_color) } else { Graphemes::from_iter([Graphemes::from(" ".repeat(indent(kind))), syntax(kind)]) - .stylize_all_backgrounds(self.inactive_item_background_color) + .stylize_all_attributes(Attributes::from(Attribute::Dim)) } }) .collect::>(); diff --git a/src/grapheme.rs b/src/grapheme.rs index 693880e0..2a0d4c62 100644 --- a/src/grapheme.rs +++ b/src/grapheme.rs @@ -37,6 +37,7 @@ use std::{ ops::{Deref, DerefMut}, }; +use crossterm::style::Attributes; use unicode_width::UnicodeWidthChar; use crate::crossterm::style::{Color, ContentStyle}; @@ -122,6 +123,13 @@ impl Graphemes { self } + pub fn stylize_all_attributes(mut self, attrs: Attributes) -> Self { + for grapheme in &mut self.0 { + grapheme.style.attributes = attrs; + } + self + } + pub fn styled_display(&self) -> StyledGraphemesDisplay<'_> { StyledGraphemesDisplay { graphemes: self } } diff --git a/src/preset/json.rs b/src/preset/json.rs index 7c832e59..b9166562 100644 --- a/src/preset/json.rs +++ b/src/preset/json.rs @@ -39,8 +39,6 @@ impl Json { string_value_style: Style::new().fgc(Color::DarkGreen).build(), number_value_style: Style::new().build(), boolean_value_style: Style::new().build(), - active_item_background_color: Color::DarkYellow, - inactive_item_background_color: Color::Reset, lines: Default::default(), indent: 2, }, @@ -59,18 +57,6 @@ impl Json { self } - /// Sets the background color for active items in the JSON rendering. - pub fn active_item_background_color(mut self, color: Color) -> Self { - self.json_renderer.active_item_background_color = color; - self - } - - /// Sets the background color for inactive items in the JSON rendering. - pub fn inactive_item_background_color(mut self, color: Color) -> Self { - self.json_renderer.inactive_item_background_color = color; - self - } - /// Sets the number of lines to be used for rendering the JSON data. pub fn json_lines(mut self, lines: usize) -> Self { self.json_renderer.lines = Some(lines);