aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorTuomas Siipola <siiptuo@kapsi.fi>2017-02-22 21:52:37 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2017-02-22 14:49:29 -0800
commit7bb49fabfa0d2686e4e74c1c11362d6b6aade1ca (patch)
tree6d8512f2bc7d75be76d656a8d019e9e5ed90204e /src/event.rs
parent418df72a077cd85b14cbede78e281bb224515a40 (diff)
downloadalacritty-7bb49fabfa0d2686e4e74c1c11362d6b6aade1ca.tar.gz
alacritty-7bb49fabfa0d2686e4e74c1c11362d6b6aade1ca.zip
Add hide cursor when typing option
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
index 9a7d2e8e..d6b0796a 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -142,6 +142,8 @@ pub struct Processor<N> {
ref_test: bool,
size_info: SizeInfo,
pub selection: Selection,
+ hide_cursor_when_typing: bool,
+ hide_cursor: bool,
}
/// Notify that the terminal was resized
@@ -178,6 +180,8 @@ impl<N: Notify> Processor<N> {
mouse: Default::default(),
selection: Default::default(),
size_info: size_info,
+ hide_cursor_when_typing: config.hide_cursor_when_typing(),
+ hide_cursor: false,
}
}
@@ -189,6 +193,7 @@ impl<N: Notify> Processor<N> {
event: glutin::Event,
ref_test: bool,
resize_tx: &mpsc::Sender<(u32, u32)>,
+ hide_cursor: &mut bool,
) {
match event {
glutin::Event::Closed => {
@@ -219,9 +224,11 @@ impl<N: Notify> Processor<N> {
processor.ctx.terminal.dirty = true;
},
glutin::Event::KeyboardInput(state, _code, key, mods, string) => {
+ *hide_cursor = true;
processor.process_key(state, key, mods, string);
},
glutin::Event::MouseInput(state, button) => {
+ *hide_cursor = false;
processor.mouse_input(state, button);
processor.ctx.terminal.dirty = true;
},
@@ -229,6 +236,7 @@ impl<N: Notify> Processor<N> {
let x = limit(x, 0, processor.ctx.size_info.width as i32);
let y = limit(y, 0, processor.ctx.size_info.height as i32);
+ *hide_cursor = false;
processor.mouse_moved(x as u32, y as u32);
if !processor.ctx.selection.is_empty() {
@@ -236,6 +244,7 @@ impl<N: Notify> Processor<N> {
}
},
glutin::Event::MouseWheel(scroll_delta, touch_phase) => {
+ *hide_cursor = false;
processor.on_mouse_wheel(scroll_delta, touch_phase);
},
glutin::Event::Focused(true) |
@@ -275,6 +284,7 @@ impl<N: Notify> Processor<N> {
$event,
self.ref_test,
&self.resize_tx,
+ &mut self.hide_cursor,
)
}
}
@@ -309,6 +319,10 @@ impl<N: Notify> Processor<N> {
for event in window.poll_events() {
process!(event);
}
+
+ if self.hide_cursor_when_typing {
+ window.set_cursor_visible(!self.hide_cursor);
+ }
}
self.wait_for_event = !terminal.dirty;