From 52f6fd90867881300aa64034dc2c698c3fda1f34 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 8 Oct 2021 23:00:53 -0600 Subject: Add configurable crosshairs to Alacritty. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows the user to put semitransparent rectangles around the current cursor line and column, รก la Vim's cursor line/column, but for the whole terminal. --- alacritty/src/display/content.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'alacritty/src/display/content.rs') diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index 297aefd6..cb249ecd 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -4,7 +4,7 @@ use std::mem; use std::ops::{Deref, DerefMut, RangeInclusive}; use alacritty_terminal::ansi::{Color, CursorShape, NamedColor}; -use alacritty_terminal::config::Config; +use alacritty_terminal::config::{Config, CursorCrosshairs}; use alacritty_terminal::event::EventListener; use alacritty_terminal::graphics::GraphicCell; use alacritty_terminal::grid::{Dimensions, Indexed}; @@ -36,6 +36,7 @@ pub struct RenderableContent<'a> { config: &'a Config, colors: &'a List, focused_match: Option<&'a Match>, + cursor_crosshairs: CursorCrosshairs, } impl<'a> RenderableContent<'a> { @@ -64,6 +65,7 @@ impl<'a> RenderableContent<'a> { // Convert terminal cursor point to viewport position. let cursor_point = terminal_content.cursor.point; let display_offset = terminal_content.display_offset; + let crosshairs = config.cursor.cursor_crosshairs; let cursor_point = display::point_to_viewport(display_offset, cursor_point).unwrap(); let hint = if display.hint_state.active() { @@ -76,6 +78,7 @@ impl<'a> RenderableContent<'a> { Self { colors: &display.colors, cursor: None, + cursor_crosshairs: config.cursor.cursor_crosshairs, terminal_content, focused_match, cursor_shape, @@ -86,6 +89,10 @@ impl<'a> RenderableContent<'a> { } } + pub fn cursor_crosshairs(&self) -> CursorCrosshairs { + self.cursor_crosshairs + } + /// Viewport offset. pub fn display_offset(&self) -> usize { self.terminal_content.display_offset @@ -108,9 +115,9 @@ impl<'a> RenderableContent<'a> { /// /// This will return `None` when there is no cursor visible. fn renderable_cursor(&mut self, cell: &RenderableCell) -> Option { - if self.cursor_shape == CursorShape::Hidden { - return None; - } + // if self.cursor_shape == CursorShape::Hidden { + // return None; + // } // Cursor colors. let color = if self.terminal_content.mode.contains(TermMode::VI) { @@ -139,6 +146,7 @@ impl<'a> RenderableContent<'a> { is_wide: cell.flags.contains(Flags::WIDE_CHAR), shape: self.cursor_shape, point: self.cursor_point, + cursor_crosshairs: self.cursor_crosshairs, cursor_color, text_color, }) @@ -378,16 +386,21 @@ impl RenderableCell { } /// Cursor storing all information relevant for rendering. -#[derive(Debug, Eq, PartialEq, Copy, Clone)] +#[derive(Debug, PartialEq, Copy, Clone)] pub struct RenderableCursor { shape: CursorShape, cursor_color: Rgb, text_color: Rgb, is_wide: bool, point: Point, + cursor_crosshairs: CursorCrosshairs, } impl RenderableCursor { + pub fn cursor_crosshairs(&self) -> CursorCrosshairs { + self.cursor_crosshairs + } + pub fn color(&self) -> Rgb { self.cursor_color } -- cgit