summaryrefslogtreecommitdiffstats
path: root/alacritty_terminal
diff options
context:
space:
mode:
authorKirill Chibisov <wchibisovkirill@gmail.com>2019-07-11 00:24:04 +0300
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-07-10 21:24:04 +0000
commit9a159a77604e0354f1176b02ff700bc11da19c86 (patch)
treef430d60b8431e7862479a0579918e737289a2f38 /alacritty_terminal
parentc4d2725e14ca9488b1b086024bf827c66945ae7b (diff)
Fix cursor color setting with escape sequence
The cursor rework introduced a regression where cursor color was always picked from a config file, rather then using `ansi::NamedColor::Cursor` for this purpose. This commit also removes `CursorText` option from `NamedColor` enum, since we can't speculate with `CursorText` during runtime. Cursor rework commits: cfc20d4f34dca535654cc32df18e785296af4cc5 371d13f8ef95157c97f7de9964bcbc89d4a8e930 0d060d5d801e3abb55035269138d819d38fc175b
Diffstat (limited to 'alacritty_terminal')
-rw-r--r--alacritty_terminal/src/ansi.rs2
-rw-r--r--alacritty_terminal/src/config/mod.rs15
-rw-r--r--alacritty_terminal/src/term/color.rs10
-rw-r--r--alacritty_terminal/src/term/mod.rs6
4 files changed, 21 insertions, 12 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 07fc18ea..b4cf4476 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -539,8 +539,6 @@ pub enum NamedColor {
Background,
/// Color for the cursor itself
Cursor,
- /// Color for the text under the cursor
- CursorText,
/// Dim black
DimBlack,
/// Dim red
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs
index 63f0aace..e7155e0c 100644
--- a/alacritty_terminal/src/config/mod.rs
+++ b/alacritty_terminal/src/config/mod.rs
@@ -32,7 +32,7 @@ mod test;
mod visual_bell;
mod window;
-use crate::ansi::CursorStyle;
+use crate::ansi::{Color, CursorStyle, NamedColor};
use crate::input::{Binding, KeyBinding, MouseBinding};
pub use crate::config::bindings::Key;
@@ -44,6 +44,7 @@ pub use crate::config::mouse::{ClickHandler, Mouse};
pub use crate::config::scrolling::Scrolling;
pub use crate::config::visual_bell::{VisualBellAnimation, VisualBellConfig};
pub use crate::config::window::{Decorations, Dimensions, StartupMode, WindowConfig};
+use crate::term::color::Rgb;
pub static DEFAULT_ALACRITTY_CONFIG: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../alacritty.yml"));
@@ -190,6 +191,18 @@ impl Config {
self.dynamic_title.0
}
+ /// Cursor foreground color
+ #[inline]
+ pub fn cursor_text_color(&self) -> Option<Rgb> {
+ self.colors.cursor.text
+ }
+
+ /// Cursor background color
+ #[inline]
+ pub fn cursor_cursor_color(&self) -> Option<Color> {
+ self.colors.cursor.cursor.map(|_| Color::Named(NamedColor::Cursor))
+ }
+
#[inline]
pub fn set_dynamic_title(&mut self, dynamic_title: bool) {
self.dynamic_title.0 = dynamic_title;
diff --git a/alacritty_terminal/src/term/color.rs b/alacritty_terminal/src/term/color.rs
index 481b281c..877d89e5 100644
--- a/alacritty_terminal/src/term/color.rs
+++ b/alacritty_terminal/src/term/color.rs
@@ -8,7 +8,7 @@ use serde::{Deserialize, Deserializer};
use crate::ansi;
use crate::config::Colors;
-pub const COUNT: usize = 270;
+pub const COUNT: usize = 269;
pub const RED: Rgb = Rgb { r: 0xff, g: 0x0, b: 0x0 };
pub const YELLOW: Rgb = Rgb { r: 0xff, g: 0xff, b: 0x0 };
@@ -135,9 +135,8 @@ impl FromStr for Rgb {
/// The first 16 entries are the standard ansi named colors. Items 16..232 are
/// the color cube. Items 233..256 are the grayscale ramp. Item 256 is
/// the configured foreground color, item 257 is the configured background
-/// color, item 258 is the cursor foreground color, item 259 is the cursor
-/// background color. Following that are 8 positions for dim colors.
-/// Item 268 is the bright foreground color, 269 the dim foreground.
+/// color, item 258 is the cursor color. Following that are 8 positions for dim colors.
+/// Item 267 is the bright foreground color, 268 the dim foreground.
#[derive(Copy, Clone)]
pub struct List([Rgb; COUNT]);
@@ -182,8 +181,7 @@ impl List {
self[ansi::NamedColor::Foreground] = colors.primary.foreground;
self[ansi::NamedColor::Background] = colors.primary.background;
- // Foreground and background for custom cursor colors
- self[ansi::NamedColor::CursorText] = colors.cursor.text.unwrap_or_else(Rgb::default);
+ // Background for custom cursor colors
self[ansi::NamedColor::Cursor] = colors.cursor.cursor.unwrap_or_else(Rgb::default);
// Dims
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 7de82a8d..34d06b21 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -447,8 +447,8 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
renderable_cell.inner = RenderableCellContent::Cursor(cursor_key);
- if let Some(color) = self.config.colors.cursor.cursor {
- renderable_cell.fg = color;
+ if let Some(color) = self.config.cursor_cursor_color() {
+ renderable_cell.fg = RenderableCell::compute_bg_rgb(self.colors, color);
}
return Some(renderable_cell);
@@ -459,7 +459,7 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
if self.cursor_style == CursorStyle::Block {
std::mem::swap(&mut cell.bg, &mut cell.fg);
- if let Some(color) = self.config.colors.cursor.text {
+ if let Some(color) = self.config.cursor_text_color() {
cell.fg = color;
}
}