1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix hidden cursor inverting cell colors

Since the block cursor inverts the background and foreground colors of a
cell, the hidden cursor has done the same thing without rendering a
cursor since it was using the block cursor shape.

A new `Hidden` cursor style has been introduced for explicitly handling
the invisible cursor differently.

This fixes #2342.
This commit is contained in:
Christian Duerr 2019-04-22 00:38:59 +02:00
parent d3cfda0371
commit 43c8578910
No known key found for this signature in database
GPG key ID: 85CDAE3C164BA7B4
3 changed files with 7 additions and 1 deletions

View file

@ -356,6 +356,9 @@ pub enum CursorStyle {
/// Cursor is a box like `☐` /// Cursor is a box like `☐`
HollowBlock, HollowBlock,
/// Invisible cursor
Hidden,
} }
impl Default for CursorStyle { impl Default for CursorStyle {

View file

@ -45,6 +45,7 @@ pub fn get_cursor_glyph(
CursorStyle::Underline => get_underline_cursor_glyph(width, line_width), CursorStyle::Underline => get_underline_cursor_glyph(width, line_width),
CursorStyle::Beam => get_beam_cursor_glyph(height, line_width), CursorStyle::Beam => get_beam_cursor_glyph(height, line_width),
CursorStyle::Block => get_block_cursor_glyph(height, width), CursorStyle::Block => get_block_cursor_glyph(height, width),
CursorStyle::Hidden => RasterizedGlyph::default(),
} }
} }

View file

@ -175,7 +175,7 @@ impl<'a> RenderableCellsIter<'a> {
term: &'b Term, term: &'b Term,
config: &'b Config, config: &'b Config,
selection: Option<Locations>, selection: Option<Locations>,
cursor_style: CursorStyle, mut cursor_style: CursorStyle,
metrics: font::Metrics, metrics: font::Metrics,
) -> RenderableCellsIter<'b> { ) -> RenderableCellsIter<'b> {
let grid = &term.grid; let grid = &term.grid;
@ -236,6 +236,8 @@ impl<'a> RenderableCellsIter<'a> {
&& (cursor.col + 1) < grid.num_cols(); && (cursor.col + 1) < grid.num_cols();
Some(cursor::get_cursor_glyph(cursor_style, metrics, offset_x, offset_y, is_wide)) Some(cursor::get_cursor_glyph(cursor_style, metrics, offset_x, offset_y, is_wide))
} else { } else {
// Use hidden cursor so text will not get inverted
cursor_style = CursorStyle::Hidden;
None None
}; };