aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-12-29 20:39:30 -0500
committerJoe Wilm <joe@jwilm.com>2016-12-29 20:53:41 -0500
commitb704dafb2420df6f7fca64980a2f52c1a00bcef5 (patch)
treef4659fa9ba38a8626d478e23d97b331c6dd5f8dc /src/input.rs
parentf1336ee1c74c8e3d324ff7b32b562a64046df5ce (diff)
downloadalacritty-b704dafb2420df6f7fca64980a2f52c1a00bcef5.tar.gz
alacritty-b704dafb2420df6f7fca64980a2f52c1a00bcef5.zip
Fix some bugs with selections
Moving the window on macOS would cause a panic in certain circumstances.
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/input.rs b/src/input.rs
index 001f541c..84ed86ec 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -150,11 +150,12 @@ impl Action {
Action::Copy => {
if let Some(selection) = ctx.selection.span() {
let buf = ctx.terminal.string_from_selection(&selection);
-
- Clipboard::new()
- .expect("get clipboard")
- .store_primary(buf)
- .expect("copy into clipboard");
+ if !buf.is_empty() {
+ Clipboard::new()
+ .expect("get clipboard")
+ .store_primary(buf)
+ .expect("copy into clipboard");
+ }
}
},
Action::Paste |
@@ -193,9 +194,9 @@ impl<'a, N: Notify + 'a> Processor<'a, N> {
self.ctx.mouse.x = x;
self.ctx.mouse.y = y;
- if let Some((line, column)) = self.ctx.size_info.pixels_to_coords(x as usize, y as usize) {
- self.ctx.mouse.line = line;
- self.ctx.mouse.column = column;
+ if let Some(point) = self.ctx.size_info.pixels_to_coords(x as usize, y as usize) {
+ self.ctx.mouse.line = point.line;
+ self.ctx.mouse.column = point.col;
let cell_x = x as usize % self.ctx.size_info.cell_width as usize;
let half_cell_width = (self.ctx.size_info.cell_width / 2.0) as usize;
@@ -210,8 +211,8 @@ impl<'a, N: Notify + 'a> Processor<'a, N> {
!self.ctx.terminal.mode().contains(mode::MOUSE_REPORT_CLICK)
{
self.ctx.selection.update(Point {
- line: line,
- col: column
+ line: point.line,
+ col: point.col
}, self.ctx.mouse.cell_side);
}
}
@@ -248,6 +249,16 @@ impl<'a, N: Notify + 'a> Processor<'a, N> {
self.mouse_report(3);
return;
}
+
+ if let Some(selection) = self.ctx.selection.span() {
+ let buf = self.ctx.terminal.string_from_selection(&selection);
+ if !buf.is_empty() {
+ Clipboard::new()
+ .expect("get clipboard")
+ .store_selection(buf)
+ .expect("copy into clipboard");
+ }
+ }
}
pub fn on_mouse_wheel(&mut self, delta: MouseScrollDelta, phase: TouchPhase) {