aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2018-03-06 20:57:40 -0800
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:34:28 -0700
commit8018dee1812ab88793c0f18e13335fa77c068000 (patch)
tree3d9a4a5435a1bdfe260ea78299f49d8934535b6b /src/event.rs
parent8ef062efd94975885776e61b6df936088b018da0 (diff)
downloadalacritty-8018dee1812ab88793c0f18e13335fa77c068000.tar.gz
alacritty-8018dee1812ab88793c0f18e13335fa77c068000.zip
Support selections with scrolling buffer
Selections now *mostly* work. They move as the buffer scrolls, copying works as it should, and it looks like the different selection modes behave properly as well. The new Selection implementation uses buffer coordinates instead of screen coordinates. This leads to doing a transform from mouse input to update the selection, and back to screen coordinates when displaying the selection. Scrolling the selection is fast because the grid is already operating in buffer coordinates. There are several bugs to address: * A _partially_ visible selection will lead to a crash since the drawing routine converts selection coordinates to screen coordinates. The solution will be to clip the coordinates at draw time. * A selection scrolling off the buffer in either direction leads to indexing out-of-bounds. The solution again is to clip, but this needs to be done within Selection::rotate by passing a max limit. It may also need a return type to indicate that the selection is no longer visible and should be discarded. * A selection scrolling out of a logical scrolling region is not clipped. A temporary and robust workaround is to simply discard the selection in the case of scrolling in a region. wip selections fix issue with line selection selection mostly working need to support selection not being on the screen at draw time Fix selection_to_string Uncomment tests
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/event.rs b/src/event.rs
index d6348ba0..8d2d80e4 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -81,34 +81,33 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
}
fn update_selection(&mut self, point: Point, side: Side) {
+ self.terminal.dirty = true;
+ let point = self.terminal.visible_to_buffer(point);
// Update selection if one exists
- let mut had_selection = false; // borrowck
if let Some(ref mut selection) = *self.terminal.selection_mut() {
selection.update(point, side);
- had_selection = true;
- }
-
- if had_selection { // borrowck
- self.terminal.dirty = true;
return;
}
// Otherwise, start a regular selection
- self.simple_selection(point, side);
+ *self.terminal.selection_mut() = Some(Selection::simple(point, side));
}
fn simple_selection(&mut self, point: Point, side: Side) {
+ let point = self.terminal.visible_to_buffer(point);
*self.terminal.selection_mut() = Some(Selection::simple(point, side));
self.terminal.dirty = true;
}
fn semantic_selection(&mut self, point: Point) {
+ let point = self.terminal.visible_to_buffer(point);
*self.terminal.selection_mut() = Some(Selection::semantic(point, &*self.terminal));
self.terminal.dirty = true;
}
fn line_selection(&mut self, point: Point) {
+ let point = self.terminal.visible_to_buffer(point);
*self.terminal.selection_mut() = Some(Selection::lines(point));
self.terminal.dirty = true;
}