summaryrefslogtreecommitdiffstats
path: root/src/term
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-09-19 19:18:51 +0000
committerGitHub <noreply@github.com>2018-09-19 19:18:51 +0000
commitd387ebe1d7fe9f9fe9d840039aba68efffe5a233 (patch)
tree626999eaf8ff0e848d574953135c4a93b8041121 /src/term
parentf0ce64e24b2ad3cce0a223d17f04413cd6c49810 (diff)
Add hidden escape sequence
This adds support for the `hidden` escape sequence `\e[8m`, which will render the text as invisible. This has also raised a few questions about the rendering of foreground and background colors and their interaction with the different escape sequences. Previously, Alacritty has oriented itself after URxvt, which has some strange and unexpected behavior. The new implementation of color inversion is modeled after XTerm, which has a consistent pattern of always inverting the foreground and background colors. This should hopefully lead to less confusion for the user and a more consistent behavior. A full matrix showcasing the new way Alacritty inverses text can be found here: https://i.imgur.com/d1XavG7.png This fixes #1454 and fixes #1455.
Diffstat (limited to 'src/term')
-rw-r--r--src/term/cell.rs19
-rw-r--r--src/term/mod.rs30
2 files changed, 20 insertions, 29 deletions
diff --git a/src/term/cell.rs b/src/term/cell.rs
index a04eb8e1..ef8509dc 100644
--- a/src/term/cell.rs
+++ b/src/term/cell.rs
@@ -18,15 +18,16 @@ use index::Column;
bitflags! {
#[derive(Serialize, Deserialize)]
pub struct Flags: u32 {
- const INVERSE = 0b0000_0001;
- const BOLD = 0b0000_0010;
- const ITALIC = 0b0000_0100;
- const UNDERLINE = 0b0000_1000;
- const WRAPLINE = 0b0001_0000;
- const WIDE_CHAR = 0b0010_0000;
- const WIDE_CHAR_SPACER = 0b0100_0000;
- const DIM = 0b1000_0000;
- const DIM_BOLD = 0b1000_0010;
+ const INVERSE = 0b0_0000_0001;
+ const BOLD = 0b0_0000_0010;
+ const ITALIC = 0b0_0000_0100;
+ const UNDERLINE = 0b0_0000_1000;
+ const WRAPLINE = 0b0_0001_0000;
+ const WIDE_CHAR = 0b0_0010_0000;
+ const WIDE_CHAR_SPACER = 0b0_0100_0000;
+ const DIM = 0b0_1000_0000;
+ const DIM_BOLD = 0b0_1000_0010;
+ const HIDDEN = 0b1_0000_0000;
}
}
diff --git a/src/term/mod.rs b/src/term/mod.rs
index f4ebf1c9..c2759802 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -14,9 +14,8 @@
//
//! Exports the `Term` type which is a high-level API for the Grid
use std::ops::{Range, Index, IndexMut};
-use std::ptr;
+use std::{ptr, io, mem};
use std::cmp::{min, max};
-use std::io;
use std::time::{Duration, Instant};
use arraydeque::ArrayDeque;
@@ -424,26 +423,15 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
};
// Apply inversion and lookup RGB values
- let mut bg_alpha = 1.0;
- let fg_rgb;
- let bg_rgb;
+ let mut fg_rgb = self.compute_fg_rgb(cell.fg, &cell);
+ let mut bg_rgb = self.compute_bg_rgb(cell.bg);
- let invert = selected ^ cell.inverse();
-
- if invert {
- if cell.fg == cell.bg {
- bg_rgb = self.colors[NamedColor::Foreground];
- fg_rgb = self.colors[NamedColor::Background];
- bg_alpha = 1.0
- } else {
- bg_rgb = self.compute_fg_rgb(cell.fg, &cell);
- fg_rgb = self.compute_bg_rgb(cell.bg);
- }
+ let bg_alpha = if selected ^ cell.inverse() {
+ mem::swap(&mut fg_rgb, &mut bg_rgb);
+ self.compute_bg_alpha(cell.fg)
} else {
- fg_rgb = self.compute_fg_rgb(cell.fg, &cell);
- bg_rgb = self.compute_bg_rgb(cell.bg);
- bg_alpha = self.compute_bg_alpha(cell.bg);
- }
+ self.compute_bg_alpha(cell.bg)
+ };
return Some(RenderableCell {
line: cell.line,
@@ -1877,6 +1865,8 @@ impl ansi::Handler for Term {
Attr::CancelItalic => self.cursor.template.flags.remove(cell::Flags::ITALIC),
Attr::Underscore => self.cursor.template.flags.insert(cell::Flags::UNDERLINE),
Attr::CancelUnderline => self.cursor.template.flags.remove(cell::Flags::UNDERLINE),
+ Attr::Hidden => self.cursor.template.flags.insert(cell::Flags::HIDDEN),
+ Attr::CancelHidden => self.cursor.template.flags.remove(cell::Flags::HIDDEN),
_ => {
debug!("Term got unhandled attr: {:?}", attr);
}