parent
1bd5c45b14
commit
35e4f2096a
|
@ -77,6 +77,10 @@ impl Cell {
|
||||||
self.flags.contains(BOLD)
|
self.flags.contains(BOLD)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn inverse(&self) -> bool {
|
||||||
|
self.flags.contains(INVERSE)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(c: char, fg: Color, bg: Color) -> Cell {
|
pub fn new(c: char, fg: Color, bg: Color) -> Cell {
|
||||||
Cell {
|
Cell {
|
||||||
c: c.into(),
|
c: c.into(),
|
||||||
|
@ -86,17 +90,6 @@ impl Cell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get foreground and background colors adjusted for INVERSE flag
|
|
||||||
///
|
|
||||||
/// First color is the foreground, second color is the background.
|
|
||||||
pub fn colors(&self, force_invert: bool) -> (&Color, &Color) {
|
|
||||||
if self.flags.contains(INVERSE) || force_invert {
|
|
||||||
(&self.bg, &self.fg)
|
|
||||||
} else {
|
|
||||||
(&self.fg, &self.bg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.c == ' ' &&
|
self.c == ' ' &&
|
||||||
|
|
|
@ -309,12 +309,12 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
|
||||||
(*cell, selected)
|
(*cell, selected)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `Color` fg, bg
|
// Apply inversion and lookup RGB values
|
||||||
let (fg, bg) = cell.colors(selected);
|
let (fg, bg) = if selected || cell.inverse() {
|
||||||
|
(self.compute_bg_rgb(&cell.bg), self.compute_fg_rgb(&cell.fg, &cell))
|
||||||
// `Rgb` fg, bg
|
} else {
|
||||||
let fg = self.compute_fg_rgb(fg, &cell);
|
(self.compute_fg_rgb(&cell.fg, &cell), self.compute_bg_rgb(&cell.bg))
|
||||||
let bg = self.compute_bg_rgb(bg);
|
};
|
||||||
|
|
||||||
return Some(RenderableCell {
|
return Some(RenderableCell {
|
||||||
line: line,
|
line: line,
|
||||||
|
|
Loading…
Reference in New Issue