aboutsummaryrefslogtreecommitdiff
path: root/src/ansi.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2017-12-03 21:38:42 +0000
committerJoe Wilm <jwilm@users.noreply.github.com>2017-12-03 13:38:42 -0800
commit9bdac6b50aa911cd8f94624a1084a1ba35be6ed4 (patch)
tree0809e0e65413978c8f906528bee192559a05fa78 /src/ansi.rs
parentd552d28418ef192724b2b4353863708f31f325d4 (diff)
downloadalacritty-9bdac6b50aa911cd8f94624a1084a1ba35be6ed4.tar.gz
alacritty-9bdac6b50aa911cd8f94624a1084a1ba35be6ed4.zip
Add cursor style option (#928)
The default cursor can now be configured through the cursor_style field of the config. Valid options include Block, Underline, and Beam. The default can be restored by sending \e[0q as in VTE terminals. Live config reloading is supported for this parameter.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r--src/ansi.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/ansi.rs b/src/ansi.rs
index 2b196145..ec139294 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -179,7 +179,7 @@ pub trait Handler {
fn set_title(&mut self, &str) {}
/// Set the cursor style
- fn set_cursor_style(&mut self, _: CursorStyle) {}
+ fn set_cursor_style(&mut self, _: Option<CursorStyle>) {}
/// A character to be displayed
fn input(&mut self, _c: char) {}
@@ -344,7 +344,7 @@ pub trait Handler {
}
/// Describes shape of cursor
-#[derive(Debug, Eq, PartialEq, Copy, Clone)]
+#[derive(Debug, Eq, PartialEq, Copy, Clone, Deserialize)]
pub enum CursorStyle {
/// Cursor is a block like `▒`
Block,
@@ -356,6 +356,12 @@ pub enum CursorStyle {
Beam,
}
+impl Default for CursorStyle {
+ fn default() -> CursorStyle {
+ CursorStyle::Block
+ }
+}
+
/// Terminal modes
#[derive(Debug, Eq, PartialEq)]
pub enum Mode {
@@ -1070,9 +1076,10 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
'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,
+ 0 => None,
+ 1 | 2 => Some(CursorStyle::Block),
+ 3 | 4 => Some(CursorStyle::Underline),
+ 5 | 6 => Some(CursorStyle::Beam),
_ => unhandled!()
};