summaryrefslogtreecommitdiff
path: root/src/ansi.rs
diff options
context:
space:
mode:
authorDustin <dustin1114@gmail.com>2017-12-24 15:15:42 -0500
committerJoe Wilm <jwilm@users.noreply.github.com>2017-12-24 12:15:42 -0800
commitcaddac918e21a2b881a929eb371acf9f4d82cd0c (patch)
tree934f3ef81485d2b0a6dac6afd24011a6e10e5bf3 /src/ansi.rs
parented91eb365e8e24b0ef64351235ab3f8022a8e7b3 (diff)
downloadalacritty-caddac918e21a2b881a929eb371acf9f4d82cd0c.tar.gz
alacritty-caddac918e21a2b881a929eb371acf9f4d82cd0c.zip
Change mouse cursor on terminal mode change (#865)
Some terminals have functionality around changing the type of mouse cursor dynamically (arrow and text) based on which mode(s) the VTE is in. For example, gnome-terminal changes the cursor from text (default) to an arrow when opening programs that track mouse events (e.g. vim, emacs, tmux, htop, etc.). The programs all allow using the mouse interactively under some circumstances (like executing `set mouse=a` in vim). The programs that use an interactive mouse set the terminal mode to different values. Though they're not entirely the same terminal mode across programs, an emulator like vte (the library gnome-terminal implements), changes the mouse cursor if the mouse mode is one of the following: - 1000: Mouse Click Tracking - 1001: Mouse Highlight Tracking - 1002: Mouse Cell Motion Tracking - 1003: Mouse All Motion Tracking - 1004: Mouse Focus Tracking See https://github.com/GNOME/vte/blob/6acfa59dfcceef65c1f7e3570db37ab245f049c4/src/vteseq.cc#L708 for more information. This commit adds functionality that changes the winit/glutin `MouseCursor` when a mouse-listening mode of 1000-1004 is set. It behaves similarly to when the window title changes.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r--src/ansi.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ansi.rs b/src/ansi.rs
index ec139294..3d66b497 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -21,7 +21,7 @@ use vte;
use index::{Column, Line, Contains};
-use ::Rgb;
+use ::{MouseCursor, Rgb};
// Parse color arguments
//
@@ -178,6 +178,9 @@ pub trait Handler {
/// OSC to set window title
fn set_title(&mut self, &str) {}
+ /// Set the window's mouse cursor
+ fn set_mouse_cursor(&mut self, MouseCursor) {}
+
/// Set the cursor style
fn set_cursor_style(&mut self, _: Option<CursorStyle>) {}
@@ -402,7 +405,9 @@ pub enum Mode {
/// ?1000
ReportMouseClicks = 1000,
/// ?1002
- ReportMouseMotion = 1002,
+ ReportCellMouseMotion = 1002,
+ /// ?1003
+ ReportAllMouseMotion = 1003,
/// ?1004
ReportFocusInOut = 1004,
/// ?1006
@@ -427,12 +432,16 @@ impl Mode {
12 => Mode::BlinkingCursor,
25 => Mode::ShowCursor,
1000 => Mode::ReportMouseClicks,
- 1002 => Mode::ReportMouseMotion,
+ 1002 => Mode::ReportCellMouseMotion,
+ 1003 => Mode::ReportAllMouseMotion,
1004 => Mode::ReportFocusInOut,
1006 => Mode::SgrMouse,
1049 => Mode::SwapScreenAndSetRestoreCursor,
2004 => Mode::BracketedPaste,
- _ => return None
+ _ => {
+ trace!("[unhandled] mode={:?}", num);
+ return None
+ }
})
} else {
Some(match num {