From 8018dee1812ab88793c0f18e13335fa77c068000 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 6 Mar 2018 20:57:40 -0800 Subject: 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 --- src/index.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index 418faff2..ada5f5b1 100644 --- a/src/index.rs +++ b/src/index.rs @@ -28,13 +28,13 @@ pub enum Side { /// Index in the grid using row, column notation #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize, PartialOrd)] -pub struct Point { - pub line: Line, +pub struct Point { + pub line: L, pub col: Column, } -impl Point { - pub fn new(line: Line, col: Column) -> Point { +impl Point { + pub fn new(line: L, col: Column) -> Point { Point { line, col } } } -- cgit From f50ca1a54c94fe324d22d985c1acae1ff7c16a80 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 21 Jul 2018 17:17:41 +0000 Subject: Scrollback cleanup There were some unneeded codeblocks and TODO/XXX comments in the code that have been removed. All issues marked with TODO/XXX have either been already resolved or tracking issues exist. --- src/index.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index ada5f5b1..ab8e7416 100644 --- a/src/index.rs +++ b/src/index.rs @@ -270,7 +270,7 @@ macro_rules! inclusive { match *self { Empty { .. } => (0, Some(0)), - NonEmpty { ref start, ref end } => { + NonEmpty { start, end } => { let added = $steps_add_one(start, end); match added { Some(hint) => (hint.saturating_add(1), hint.checked_add(1)), @@ -283,9 +283,9 @@ macro_rules! inclusive { } } -fn steps_add_one_u8(start: &u8, end: &u8) -> Option { - if *start < *end { - Some((*end - *start) as usize) +fn steps_add_one_u8(start: u8, end: u8) -> Option { + if start < end { + Some((end - start) as usize) } else { None } @@ -330,11 +330,11 @@ macro_rules! ops { impl $ty { #[inline] #[allow(trivial_numeric_casts)] - fn steps_between(start: &$ty, end: &$ty, by: &$ty) -> Option { - if *by == $construct(0) { return None; } - if *start < *end { + fn steps_between(start: $ty, end: $ty, by: $ty) -> Option { + if by == $construct(0) { return None; } + if start < end { // Note: We assume $t <= usize here - let diff = (*end - *start).0; + let diff = (end - start).0; let by = by.0; if diff % by > 0 { Some(diff / by + 1) @@ -347,8 +347,8 @@ macro_rules! ops { } #[inline] - fn steps_between_by_one(start: &$ty, end: &$ty) -> Option { - Self::steps_between(start, end, &$construct(1)) + fn steps_between_by_one(start: $ty, end: $ty) -> Option { + Self::steps_between(start, end, $construct(1)) } } @@ -366,7 +366,7 @@ macro_rules! ops { } #[inline] fn size_hint(&self) -> (usize, Option) { - match Self::Item::steps_between_by_one(&self.0.start, &self.0.end) { + match Self::Item::steps_between_by_one(self.0.start, self.0.end) { Some(hint) => (hint, Some(hint)), None => (0, None) } -- cgit