Skip to content

Commit

Permalink
properly handle opaque method to activate background
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaconDesperado committed Nov 1, 2024
1 parent 4ecd624 commit f944d62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions zellij-server/src/panes/terminal_character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,7 @@ impl Display for CharacterStyles {

impl From<StyleDeclaration> for CharacterStyles {
fn from(declaration: StyleDeclaration) -> Self {
RESET_STYLES
.foreground(Some(declaration.base.into()))
.background(Some(declaration.background.into()))
RESET_STYLES.foreground(Some(declaration.base.into()))
}
}

Expand Down
15 changes: 9 additions & 6 deletions zellij-server/src/ui/components/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ pub fn text(content: Text, style: &Style, component_coordinates: Option<Coordina
} else {
style.colors.text_unselected
};
let base_text_style = if content.selected {
CharacterStyles::from(declaration).background(Some(declaration.background.into()))
} else {
CharacterStyles::from(declaration).foreground(Some(AnsiCode::ColorIndex(39)))
};

let base_text_style = CharacterStyles::from(declaration);

let (text, _text_width) = stringify_text(
&content,
None,
Expand All @@ -41,10 +39,15 @@ pub fn stringify_text(
left_padding: Option<usize>,
coordinates: &Option<Coordinates>,
style: &StyleDeclaration,
base_text_style: CharacterStyles,
component_text_style: CharacterStyles,
) -> (String, usize) {
let mut text_width = 0;
let mut stringified = String::new();
let base_text_style = if text.opaque {
component_text_style.background(Some(style.background.into()))
} else {
component_text_style
};
for (i, character) in text.text.chars().enumerate() {
let character_width = character.width().unwrap_or(0);
if is_too_wide(
Expand Down

0 comments on commit f944d62

Please sign in to comment.