From a7d95540384c0b37e75a4bedb0bff688fee7dcf1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 1 Nov 2018 17:23:49 +0000 Subject: Rework cursor configuration There are a couple of cursor-related options in the Alacritty config file now, however they aren't grouped together in any way. To resolve this a new `cursor` field has been added where all cursor configuration options (besides colors) have been moved. The `custom_cursor_colors` option has also been removed, since it's not necessary anymore. Simply making the `colors.cursor.*` fields optional, allows overriding the cursor colors whenever one of them is present. Like that the user doesn't have to think about a relation between two separate configuration options. This PR initially put the `hide_cursor_when_typing` variable under `cursor.hide_when_typing`. However this field is completely unrelated to the cursor, but instead relates to the mouse cursor. Since the word `cursor` is already used for the active cell in the grid of a terminal emulator, all occurences of the word `cursor` when talking about the mouse have been replaced with the word `mouse`. The configuration option has also been moved to `mouse.hide_when_typing`, to make it clear what this option is changing. This fixes #1080. --- src/term/mod.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 3b238a41..971755af 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -278,16 +278,9 @@ impl<'a> RenderableCellsIter<'a> { } fn populate_block_cursor(&mut self) { - let (text_color, cursor_color) = if self.config.custom_cursor_colors() { - ( - Color::Named(NamedColor::CursorText), - Color::Named(NamedColor::Cursor) - ) - } else { - // Swap fg, bg - let cell = &self.grid[self.cursor]; - (cell.bg, cell.fg) - }; + let cell = &self.grid[self.cursor]; + let text_color = self.config.cursor_text_color().unwrap_or(cell.bg); + let cursor_color = self.config.cursor_cursor_color().unwrap_or(cell.fg); let original_cell = self.grid[self.cursor]; @@ -305,7 +298,7 @@ impl<'a> RenderableCellsIter<'a> { let original_cell = self.grid[self.cursor]; let mut cursor_cell = self.grid[self.cursor]; - let cursor_color = self.text_cursor_color(&cursor_cell); + let cursor_color = self.config.cursor_cursor_color().unwrap_or(cursor_cell.fg); cursor_cell.c = cursor_cell_char; cursor_cell.fg = cursor_color; @@ -332,15 +325,6 @@ impl<'a> RenderableCellsIter<'a> { cell.flags.contains(cell::Flags::WIDE_CHAR) && (self.cursor.col + 1) < self.grid.num_cols() } - fn text_cursor_color(&self, cell: &Cell) -> Color { - if self.config.custom_cursor_colors() { - Color::Named(NamedColor::Cursor) - } else { - // Cursor is same color as text - cell.fg - } - } - /// Populates list of cursor cells with the original cell fn populate_no_cursor(&mut self) { self.cursor_cells.push_back(Indexed { -- cgit v1.2.3-54-g00ecf