aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/display/content.rs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-10-08 23:00:53 -0600
committerJosh Rahm <rahm@google.com>2021-10-08 23:00:53 -0600
commit52f6fd90867881300aa64034dc2c698c3fda1f34 (patch)
tree9cbcc697284a46b2e25e4bc1a8c12d882ce04945 /alacritty/src/display/content.rs
parent750d1e196875a7063da5aa38673d0792911e8ad3 (diff)
downloadr-alacritty-52f6fd90867881300aa64034dc2c698c3fda1f34.tar.gz
r-alacritty-52f6fd90867881300aa64034dc2c698c3fda1f34.tar.bz2
r-alacritty-52f6fd90867881300aa64034dc2c698c3fda1f34.zip
Add configurable crosshairs to Alacritty.
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.
Diffstat (limited to 'alacritty/src/display/content.rs')
-rw-r--r--alacritty/src/display/content.rs23
1 files changed, 18 insertions, 5 deletions
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<UiConfig>,
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<RenderableCursor> {
- 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<usize>,
+ cursor_crosshairs: CursorCrosshairs,
}
impl RenderableCursor {
+ pub fn cursor_crosshairs(&self) -> CursorCrosshairs {
+ self.cursor_crosshairs
+ }
+
pub fn color(&self) -> Rgb {
self.cursor_color
}