aboutsummaryrefslogtreecommitdiff
path: root/src/ansi.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-05-28 09:38:10 -0700
committerJoe Wilm <jwilm@users.noreply.github.com>2017-06-11 13:21:13 -0700
commit529ac47fc81f12e953568826b87ef75568eaa83b (patch)
tree450024deb1f8d4340142d46a11ae9749cf786b77 /src/ansi.rs
parent9825adf695a472be5d3316354f707c7d9d2d2730 (diff)
downloadalacritty-529ac47fc81f12e953568826b87ef75568eaa83b.tar.gz
alacritty-529ac47fc81f12e953568826b87ef75568eaa83b.zip
Add support for Beam, Underline cursors
Notable about this implementation is it takes a different approach for managing cursor cells that previously. The terminal Grid is now borrowed *immutably*. Instead of mutating Cells in the Grid, a list is managed within the RenderableCellsIter. The cell at the cursor location is skipped over, and instead cells are popped off a list of cursor cells. It would be good in the future to share some more code between the different cursor style implementations for populating the cursor cells list. Supercedes #349.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r--src/ansi.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ansi.rs b/src/ansi.rs
index cca8fe28..5114f7df 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -102,6 +102,9 @@ pub trait Handler {
/// OSC to set window title
fn set_title(&mut self, &str) {}
+ /// Set the cursor style
+ fn set_cursor_style(&mut self, _: CursorStyle) {}
+
/// A character to be displayed
fn input(&mut self, _c: char) {}
@@ -261,6 +264,19 @@ pub trait Handler {
fn dectest(&mut self) {}
}
+/// Describes shape of cursor
+#[derive(Debug, Eq, PartialEq, Copy, Clone)]
+pub enum CursorStyle {
+ /// Cursor is a block like `▒`
+ Block,
+
+ /// Cursor is an underscore like `_`
+ Underline,
+
+ /// Cursor is a vertical bar `⎸`
+ Beam,
+}
+
/// Terminal modes
#[derive(Debug, Eq, PartialEq)]
pub enum Mode {
@@ -895,6 +911,16 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
},
's' => handler.save_cursor_position(),
'u' => handler.restore_cursor_position(),
+ 'q' => {
+ let style = match arg_or_default!(idx: 0, default: 0) {
+ 0 ... 2 => CursorStyle::Block,
+ 3 | 4 => CursorStyle::Underline,
+ 5 | 6 => CursorStyle::Beam,
+ _ => unhandled!()
+ };
+
+ handler.set_cursor_style(style);
+ }
_ => unhandled!(),
}
}