aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/display/content.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2024-10-15 11:41:08 +0300
committerGitHub <noreply@github.com>2024-10-15 11:41:08 +0300
commita5bb567c0a15bed65ff18c94d04c8c147bf817a9 (patch)
treeda9efc2394af9c52ade67832ab172a5ab3fa8400 /alacritty/src/display/content.rs
parenta2653293a8e6ac5f5fb9f7e075656799d8df3488 (diff)
downloadr-alacritty-a5bb567c0a15bed65ff18c94d04c8c147bf817a9.tar.gz
r-alacritty-a5bb567c0a15bed65ff18c94d04c8c147bf817a9.tar.bz2
r-alacritty-a5bb567c0a15bed65ff18c94d04c8c147bf817a9.zip
Implement multi-char cursor highlight
Use `end` of the cursor to draw a `HollowBlock` from `start` to `end`. When cursor covers only a single character, use `Beam` cursor instead of `HollowBlock`. Fixes #8238. Fixes #7849.
Diffstat (limited to 'alacritty/src/display/content.rs')
-rw-r--r--alacritty/src/display/content.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs
index 0e06b3ca..2fbbdec4 100644
--- a/alacritty/src/display/content.rs
+++ b/alacritty/src/display/content.rs
@@ -1,4 +1,5 @@
use std::borrow::Cow;
+use std::num::NonZeroU32;
use std::ops::Deref;
use std::{cmp, mem};
@@ -134,8 +135,13 @@ impl<'a> RenderableContent<'a> {
text_color = self.config.colors.primary.background;
}
+ let width = if cell.flags.contains(Flags::WIDE_CHAR) {
+ NonZeroU32::new(2).unwrap()
+ } else {
+ NonZeroU32::new(1).unwrap()
+ };
RenderableCursor {
- is_wide: cell.flags.contains(Flags::WIDE_CHAR),
+ width,
shape: self.cursor_shape,
point: self.cursor_point,
cursor_color,
@@ -396,7 +402,7 @@ pub struct RenderableCursor {
shape: CursorShape,
cursor_color: Rgb,
text_color: Rgb,
- is_wide: bool,
+ width: NonZeroU32,
point: Point<usize>,
}
@@ -405,15 +411,20 @@ impl RenderableCursor {
let shape = CursorShape::Hidden;
let cursor_color = Rgb::default();
let text_color = Rgb::default();
- let is_wide = false;
+ let width = NonZeroU32::new(1).unwrap();
let point = Point::default();
- Self { shape, cursor_color, text_color, is_wide, point }
+ Self { shape, cursor_color, text_color, width, point }
}
}
impl RenderableCursor {
- pub fn new(point: Point<usize>, shape: CursorShape, cursor_color: Rgb, is_wide: bool) -> Self {
- Self { shape, cursor_color, text_color: cursor_color, is_wide, point }
+ pub fn new(
+ point: Point<usize>,
+ shape: CursorShape,
+ cursor_color: Rgb,
+ width: NonZeroU32,
+ ) -> Self {
+ Self { shape, cursor_color, text_color: cursor_color, width, point }
}
pub fn color(&self) -> Rgb {
@@ -424,8 +435,8 @@ impl RenderableCursor {
self.shape
}
- pub fn is_wide(&self) -> bool {
- self.is_wide
+ pub fn width(&self) -> NonZeroU32 {
+ self.width
}
pub fn point(&self) -> Point<usize> {