summaryrefslogtreecommitdiff
path: root/src/term
diff options
context:
space:
mode:
authorCelti Burroughs <celti@celti.name>2018-01-26 14:28:43 -0700
committerJoe Wilm <jwilm@users.noreply.github.com>2018-03-12 23:21:19 -0700
commitfb43c73a38e7941f4208e17f3428c21006f29299 (patch)
tree43921a2e8ec25602b33f2d08cffba516c7981016 /src/term
parent5dad4919a227a265880de3abaa9940b4220a2d95 (diff)
downloadalacritty-fb43c73a38e7941f4208e17f3428c21006f29299.tar.gz
alacritty-fb43c73a38e7941f4208e17f3428c21006f29299.zip
Extend SGR and VT200 (normal) mouse support
With this commit, Alacritty now reports presses and releases of all three mouse buttons properly, dragging events with all three buttons, and mouse movement events where no button is pressed. It does not report more than three buttons due to inherent limitations of the VT200 and SGR protocol modes. It does not report modifier keys on mouse buttons due to practical considerations. Fixes #714, #506.
Diffstat (limited to 'src/term')
-rw-r--r--src/term/mod.rs39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 88e4b63c..5ba192ff 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -418,20 +418,21 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
pub mod mode {
bitflags! {
pub struct TermMode: u16 {
- const SHOW_CURSOR = 0b0_0000_0000_0001;
- const APP_CURSOR = 0b0_0000_0000_0010;
- const APP_KEYPAD = 0b0_0000_0000_0100;
- const MOUSE_REPORT_CLICK = 0b0_0000_0000_1000;
- const BRACKETED_PASTE = 0b0_0000_0001_0000;
- const SGR_MOUSE = 0b0_0000_0010_0000;
- const MOUSE_MOTION = 0b0_0000_0100_0000;
- const LINE_WRAP = 0b0_0000_1000_0000;
- const LINE_FEED_NEW_LINE = 0b0_0001_0000_0000;
- const ORIGIN = 0b0_0010_0000_0000;
- const INSERT = 0b0_0100_0000_0000;
- const FOCUS_IN_OUT = 0b0_1000_0000_0000;
- const ALT_SCREEN = 0b1_0000_0000_0000;
- const ANY = 0b1_1111_1111_1111;
+ const SHOW_CURSOR = 0b00_0000_0000_0001;
+ const APP_CURSOR = 0b00_0000_0000_0010;
+ const APP_KEYPAD = 0b00_0000_0000_0100;
+ const MOUSE_REPORT_CLICK = 0b00_0000_0000_1000;
+ const BRACKETED_PASTE = 0b00_0000_0001_0000;
+ const SGR_MOUSE = 0b00_0000_0010_0000;
+ const MOUSE_MOTION = 0b00_0000_0100_0000;
+ const LINE_WRAP = 0b00_0000_1000_0000;
+ const LINE_FEED_NEW_LINE = 0b00_0001_0000_0000;
+ const ORIGIN = 0b00_0010_0000_0000;
+ const INSERT = 0b00_0100_0000_0000;
+ const FOCUS_IN_OUT = 0b00_1000_0000_0000;
+ const ALT_SCREEN = 0b01_0000_0000_0000;
+ const MOUSE_DRAG = 0b10_0000_0000_0000;
+ const ANY = 0b11_1111_1111_1111;
const NONE = 0;
}
}
@@ -1832,7 +1833,10 @@ impl ansi::Handler for Term {
self.mode.insert(mode::TermMode::MOUSE_REPORT_CLICK);
self.set_mouse_cursor(MouseCursor::Arrow);
},
- ansi::Mode::ReportCellMouseMotion |
+ ansi::Mode::ReportCellMouseMotion => {
+ self.mode.insert(mode::TermMode::MOUSE_DRAG);
+ self.set_mouse_cursor(MouseCursor::Arrow);
+ },
ansi::Mode::ReportAllMouseMotion => {
self.mode.insert(mode::TermMode::MOUSE_MOTION);
self.set_mouse_cursor(MouseCursor::Arrow);
@@ -1869,7 +1873,10 @@ impl ansi::Handler for Term {
self.mode.remove(mode::TermMode::MOUSE_REPORT_CLICK);
self.set_mouse_cursor(MouseCursor::Text);
},
- ansi::Mode::ReportCellMouseMotion |
+ ansi::Mode::ReportCellMouseMotion => {
+ self.mode.remove(mode::TermMode::MOUSE_DRAG);
+ self.set_mouse_cursor(MouseCursor::Text);
+ },
ansi::Mode::ReportAllMouseMotion => {
self.mode.remove(mode::TermMode::MOUSE_MOTION);
self.set_mouse_cursor(MouseCursor::Text);