aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event.rs21
-rw-r--r--src/selection.rs7
-rw-r--r--src/term/mod.rs2
3 files changed, 14 insertions, 16 deletions
diff --git a/src/event.rs b/src/event.rs
index abbad0ef..2987fce0 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -36,6 +36,7 @@ pub struct ActionContext<'a, N: 'a> {
pub selection: &'a mut Option<Selection>,
pub size_info: &'a SizeInfo,
pub mouse: &'a mut Mouse,
+ pub selection_modified: bool,
}
impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
@@ -69,9 +70,11 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn clear_selection(&mut self) {
*self.selection = None;
+ self.selection_modified = true;
}
fn update_selection(&mut self, point: Point, side: Side) {
+ self.selection_modified = true;
// Update selection if one exists
if let &mut Some(ref mut selection) = self.selection {
selection.update(point, side);
@@ -84,14 +87,17 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn simple_selection(&mut self, point: Point, side: Side) {
*self.selection = Some(Selection::simple(point, side));
+ self.selection_modified = true;
}
fn semantic_selection(&mut self, point: Point) {
*self.selection = Some(Selection::semantic(point, self.terminal as &Term));
+ self.selection_modified = true;
}
fn line_selection(&mut self, point: Point) {
*self.selection = Some(Selection::lines(point));
+ self.selection_modified = true;
}
fn mouse_coords(&self) -> Option<Point> {
@@ -256,16 +262,6 @@ impl<N: Notify> Processor<N> {
*hide_cursor = false;
processor.mouse_moved(x as u32, y as u32);
-
- if !processor.ctx.selection.is_none() {
- // TODO this should only be passed if the selection changes
- // which happens when the point/side change *and* the mouse
- // is still pressed.
- //
- // Right now, this causes lots of unnecessary redraws while
- // selection is active.
- processor.ctx.terminal.dirty = true;
- }
},
glutin::Event::MouseWheel(scroll_delta, touch_phase) => {
*hide_cursor = false;
@@ -335,6 +331,7 @@ impl<N: Notify> Processor<N> {
selection: &mut self.selection,
mouse: &mut self.mouse,
size_info: &self.size_info,
+ selection_modified: false,
};
processor = input::Processor {
@@ -355,6 +352,10 @@ impl<N: Notify> Processor<N> {
if self.hide_cursor_when_typing {
window.set_cursor_visible(!self.hide_cursor);
}
+
+ if processor.ctx.selection_modified {
+ processor.ctx.terminal.dirty = true;
+ }
}
self.wait_for_event = !terminal.dirty;
diff --git a/src/selection.rs b/src/selection.rs
index 868ded7b..a81a9fe6 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -18,13 +18,10 @@
//! finalized when the button is released. The selection should be cleared
//! when text is added/removed/scrolled on the screen. The selection should
//! also be cleared if the user clicks off of the selection.
-use std::mem;
-use std::cmp::min;
-use std::cmp::max;
+use std::cmp::{min, max};
use index::{Point, Column, RangeInclusive, Side, Linear, Line};
-use grid::{Grid, ToRange};
-use term::Cell;
+use grid::ToRange;
/// Describes a region of a 2-dimensional area
///
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 1a79d309..cd7ffadd 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -24,7 +24,7 @@ use unicode_width::UnicodeWidthChar;
use ansi::{self, Color, NamedColor, Attr, Handler, CharsetIndex, StandardCharset, CursorStyle};
use grid::{BidirectionalIterator, Grid, ClearRegion, ToRange, Indexed};
-use index::{self, Point, Column, Line, Linear, IndexRange, Contains, RangeInclusive, Side};
+use index::{self, Point, Column, Line, Linear, IndexRange, Contains, RangeInclusive};
use selection::{self, Span, Selection};
use config::{Config, VisualBellAnimation};
use Rgb;