From e0a286515f12c6ceed53c74df1c10123cb0b550d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 20 Jun 2019 15:56:09 +0000 Subject: Add block selection This implements a block selection mode which can be triggered by holding Control before starting a selection. If text is copied using this block selection, newlines will be automatically added to the end of the lines. This fixes #526. --- alacritty_terminal/src/input.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'alacritty_terminal/src/input.rs') diff --git a/alacritty_terminal/src/input.rs b/alacritty_terminal/src/input.rs index 17d427cd..b4ea5910 100644 --- a/alacritty_terminal/src/input.rs +++ b/alacritty_terminal/src/input.rs @@ -66,6 +66,7 @@ pub trait ActionContext { fn clear_selection(&mut self); fn update_selection(&mut self, point: Point, side: Side); fn simple_selection(&mut self, point: Point, side: Side); + fn block_selection(&mut self, point: Point, side: Side); fn semantic_selection(&mut self, point: Point); fn line_selection(&mut self, point: Point); fn selection_is_empty(&self) -> bool; @@ -612,7 +613,11 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { // Start new empty selection let side = self.ctx.mouse().cell_side; if let Some(point) = point { - self.ctx.simple_selection(point, side); + if modifiers.ctrl { + self.ctx.block_selection(point, side); + } else { + self.ctx.simple_selection(point, side); + } } let report_modes = @@ -991,6 +996,8 @@ mod tests { fn simple_selection(&mut self, _point: Point, _side: Side) {} + fn block_selection(&mut self, _point: Point, _side: Side) {} + fn copy_selection(&mut self, _: ClipboardType) {} fn clear_selection(&mut self) {} -- cgit