aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorXiaoyu Yin <yin530@gmail.com>2017-01-14 17:53:48 -0800
committerJoe Wilm <jwilm@users.noreply.github.com>2017-02-07 21:04:18 -0800
commit92e1cec0880313d962d80bf16eca60cebb509eab (patch)
tree165d470ca13ab89dcf8b399b7491f3766b446ab2 /src/event.rs
parent59295e44312b3936132965636e5fac92118e5c27 (diff)
downloadalacritty-92e1cec0880313d962d80bf16eca60cebb509eab.tar.gz
alacritty-92e1cec0880313d962d80bf16eca60cebb509eab.zip
Semantic Selection
Fix tests and add line select Refactor BidirectionalIter to remove if blocks Allow for cells tagged with WRAPLINE to continue expanding the selection Reorganize config into structs Add test coverage that callbacks are called Cleanup mouse config - Uses Duration type for ClickHandler::threshold - Removes `action` property from ClickHandler--this can be added in a backwards compatible way later on - Renames ClickState::DblClick to DoubleClick fixup! Cleanup mouse config
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/event.rs b/src/event.rs
index 295cb6b1..f643c115 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -3,13 +3,14 @@ use std::borrow::Cow;
use std::fs::File;
use std::io::Write;
use std::sync::mpsc;
+use std::time::{Instant};
use serde_json as json;
use parking_lot::MutexGuard;
use glutin::{self, ElementState};
use copypasta::{Clipboard, Load, Store};
-use config::Config;
+use config::{self, Config};
use cli::Options;
use display::OnResize;
use index::{Line, Column, Side, Point};
@@ -71,17 +72,38 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
self.selection.update(point, side);
}
+ fn semantic_selection(&mut self, point: Point) {
+ self.terminal.semantic_selection(&mut self.selection, point)
+ }
+
+ fn line_selection(&mut self, point: Point) {
+ self.terminal.line_selection(&mut self.selection, point)
+ }
+
+ fn mouse_coords(&self) -> Option<Point> {
+ self.terminal.pixels_to_coords(self.mouse.x as usize, self.mouse.y as usize)
+ }
+
#[inline]
fn mouse_mut(&mut self) -> &mut Mouse {
self.mouse
}
}
+pub enum ClickState {
+ None,
+ Click,
+ DoubleClick,
+ TripleClick,
+}
+
/// State of the mouse
pub struct Mouse {
pub x: u32,
pub y: u32,
pub left_button_state: ElementState,
+ pub last_click_timestamp: Instant,
+ pub click_state: ClickState,
pub scroll_px: i32,
pub line: Line,
pub column: Column,
@@ -93,7 +115,9 @@ impl Default for Mouse {
Mouse {
x: 0,
y: 0,
+ last_click_timestamp: Instant::now(),
left_button_state: ElementState::Released,
+ click_state: ClickState::None,
scroll_px: 0,
line: Line(0),
column: Column(0),
@@ -109,6 +133,7 @@ impl Default for Mouse {
pub struct Processor<N> {
key_bindings: Vec<KeyBinding>,
mouse_bindings: Vec<MouseBinding>,
+ mouse_config: config::Mouse,
print_events: bool,
notifier: N,
mouse: Mouse,
@@ -143,6 +168,7 @@ impl<N: Notify> Processor<N> {
Processor {
key_bindings: config.key_bindings().to_vec(),
mouse_bindings: config.mouse_bindings().to_vec(),
+ mouse_config: config.mouse().to_owned(),
print_events: options.print_events,
notifier: notifier,
resize_tx: resize_tx,
@@ -263,8 +289,9 @@ impl<N: Notify> Processor<N> {
processor = input::Processor {
ctx: context,
+ mouse_config: &self.mouse_config,
key_bindings: &self.key_bindings[..],
- mouse_bindings: &self.mouse_bindings[..]
+ mouse_bindings: &self.mouse_bindings[..],
};
process!(event);
@@ -284,5 +311,6 @@ impl<N: Notify> Processor<N> {
pub fn update_config(&mut self, config: &Config) {
self.key_bindings = config.key_bindings().to_vec();
self.mouse_bindings = config.mouse_bindings().to_vec();
+ self.mouse_config = config.mouse().to_owned();
}
}