Inverse, underlined, and hidden cells

This commit is contained in:
mars 2022-10-04 17:23:26 -06:00
parent e7b61d2275
commit f024522675
1 changed files with 26 additions and 6 deletions

View File

@ -174,7 +174,13 @@ impl App {
let mut missing_chars = std::collections::HashSet::new();
use alacritty_terminal::term::cell::Flags as CellFlags;
for cell in content.display_iter.into_iter() {
if cell.flags.contains(CellFlags::HIDDEN) {
continue;
}
if let Some(glyph) = self.font.glyphs().get(&cell.c) {
let term_row = cell.point.line.0 as usize;
let term_col = cell.point.column.0 as usize;
@ -185,13 +191,20 @@ impl App {
continue;
}
let bg = self.color_to_u32(&cell.bg);
let fg = self.color_to_u32(&cell.fg);
let (bg, fg) = if cell.flags.contains(CellFlags::INVERSE) {
(&cell.fg, &cell.bg)
} else {
(&cell.bg, &cell.fg)
};
let mut px_row = term_row * width * self.cell_height;
let bg = self.color_to_u32(&bg);
let fg = self.color_to_u32(&fg);
let px_row = term_row * width * self.cell_height;
let px_start = px_row + term_col * self.cell_width;
for y in 0..self.cell_height {
let px_start = px_row + term_col * self.cell_width;
let px_start = px_start + y * width;
for x in 0..self.cell_width {
let color = if glyph.get(x as u32, y as u32) {
fg
@ -201,8 +214,14 @@ impl App {
buffer[px_start + x as usize] = color;
}
}
px_row += width;
if cell.flags.contains(CellFlags::UNDERLINE) {
let px_start = px_start + (self.cell_height - 1) * width;
for x in 0..self.cell_width {
buffer[px_start + x as usize] = fg;
}
}
} else {
missing_chars.insert(cell.c);
@ -219,7 +238,8 @@ impl App {
if (term_row + 1) * self.cell_height < height && (term_col + 1) * self.cell_width < width {
let mut px_row = term_row * width * self.cell_height + term_col * self.cell_width;
let cursor_color = 0x00ff00ff;
let cursor_color = Color::Named(NamedColor::Foreground);
let cursor_color = self.color_to_u32(&cursor_color);
use alacritty_terminal::ansi::CursorShape;
match content.cursor.shape {