mirror of
https://github.com/alacritty/alacritty.git
synced 2025-09-04 22:43:53 -04:00
Remove redundant selection::Region type
The type selection::Region was defined identially to std::ops::Range. Using something other than range just served to confuse.
This commit is contained in:
parent
9fdf77f91a
commit
44f58b81f2
1 changed files with 13 additions and 17 deletions
|
@ -19,6 +19,7 @@
|
||||||
//! when text is added/removed/scrolled on the screen. The selection should
|
//! when text is added/removed/scrolled on the screen. The selection should
|
||||||
//! also be cleared if the user clicks off of the selection.
|
//! also be cleared if the user clicks off of the selection.
|
||||||
use std::cmp::{min, max};
|
use std::cmp::{min, max};
|
||||||
|
use std::ops::Range;
|
||||||
|
|
||||||
use index::{Point, Column, RangeInclusive, Side, Linear, Line};
|
use index::{Point, Column, RangeInclusive, Side, Linear, Line};
|
||||||
use grid::ToRange;
|
use grid::ToRange;
|
||||||
|
@ -41,20 +42,20 @@ use grid::ToRange;
|
||||||
pub enum Selection {
|
pub enum Selection {
|
||||||
Simple {
|
Simple {
|
||||||
/// The region representing start and end of cursor movement
|
/// The region representing start and end of cursor movement
|
||||||
region: Region<Anchor>,
|
region: Range<Anchor>,
|
||||||
},
|
},
|
||||||
Semantic {
|
Semantic {
|
||||||
/// The region representing start and end of cursor movement
|
/// The region representing start and end of cursor movement
|
||||||
region: Region<Point>,
|
region: Range<Point>,
|
||||||
|
|
||||||
/// When beginning a semantic selection, the grid is searched around the
|
/// When beginning a semantic selection, the grid is searched around the
|
||||||
/// initial point to find semantic escapes, and this initial expansion
|
/// initial point to find semantic escapes, and this initial expansion
|
||||||
/// marks those points.
|
/// marks those points.
|
||||||
initial_expansion: Region<Point>
|
initial_expansion: Range<Point>
|
||||||
},
|
},
|
||||||
Lines {
|
Lines {
|
||||||
/// The region representing start and end of cursor movement
|
/// The region representing start and end of cursor movement
|
||||||
region: Region<Point>,
|
region: Range<Point>,
|
||||||
|
|
||||||
/// The line under the initial point. This is always selected regardless
|
/// The line under the initial point. This is always selected regardless
|
||||||
/// of which way the cursor is moved.
|
/// of which way the cursor is moved.
|
||||||
|
@ -62,11 +63,6 @@ pub enum Selection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Region<T> {
|
|
||||||
start: T,
|
|
||||||
end: T
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A Point and side within that point.
|
/// A Point and side within that point.
|
||||||
pub struct Anchor {
|
pub struct Anchor {
|
||||||
point: Point,
|
point: Point,
|
||||||
|
@ -99,7 +95,7 @@ pub trait Dimensions {
|
||||||
impl Selection {
|
impl Selection {
|
||||||
pub fn simple(location: Point, side: Side) -> Selection {
|
pub fn simple(location: Point, side: Side) -> Selection {
|
||||||
Selection::Simple {
|
Selection::Simple {
|
||||||
region: Region {
|
region: Range {
|
||||||
start: Anchor::new(location, side),
|
start: Anchor::new(location, side),
|
||||||
end: Anchor::new(location, side)
|
end: Anchor::new(location, side)
|
||||||
}
|
}
|
||||||
|
@ -109,11 +105,11 @@ impl Selection {
|
||||||
pub fn semantic<G: SemanticSearch>(point: Point, grid: &G) -> Selection {
|
pub fn semantic<G: SemanticSearch>(point: Point, grid: &G) -> Selection {
|
||||||
let (start, end) = (grid.semantic_search_left(point), grid.semantic_search_right(point));
|
let (start, end) = (grid.semantic_search_left(point), grid.semantic_search_right(point));
|
||||||
Selection::Semantic {
|
Selection::Semantic {
|
||||||
region: Region {
|
region: Range {
|
||||||
start: point,
|
start: point,
|
||||||
end: point,
|
end: point,
|
||||||
},
|
},
|
||||||
initial_expansion: Region {
|
initial_expansion: Range {
|
||||||
start: start,
|
start: start,
|
||||||
end: end
|
end: end
|
||||||
}
|
}
|
||||||
|
@ -122,7 +118,7 @@ impl Selection {
|
||||||
|
|
||||||
pub fn lines(point: Point) -> Selection {
|
pub fn lines(point: Point) -> Selection {
|
||||||
Selection::Lines {
|
Selection::Lines {
|
||||||
region: Region {
|
region: Range {
|
||||||
start: point,
|
start: point,
|
||||||
end: point
|
end: point
|
||||||
},
|
},
|
||||||
|
@ -159,8 +155,8 @@ impl Selection {
|
||||||
}
|
}
|
||||||
fn span_semantic<G>(
|
fn span_semantic<G>(
|
||||||
grid: &G,
|
grid: &G,
|
||||||
region: &Region<Point>,
|
region: &Range<Point>,
|
||||||
initial_expansion: &Region<Point>
|
initial_expansion: &Range<Point>
|
||||||
) -> Option<Span>
|
) -> Option<Span>
|
||||||
where G: SemanticSearch + Dimensions
|
where G: SemanticSearch + Dimensions
|
||||||
{
|
{
|
||||||
|
@ -192,7 +188,7 @@ impl Selection {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn span_lines<G>(grid: &G, region: &Region<Point>, initial_line: &Line) -> Option<Span>
|
fn span_lines<G>(grid: &G, region: &Range<Point>, initial_line: &Line) -> Option<Span>
|
||||||
where G: Dimensions
|
where G: Dimensions
|
||||||
{
|
{
|
||||||
// First, create start and end points based on initial line and the grid
|
// First, create start and end points based on initial line and the grid
|
||||||
|
@ -225,7 +221,7 @@ impl Selection {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn span_simple<G: Dimensions>(grid: &G, region: &Region<Anchor>) -> Option<Span> {
|
fn span_simple<G: Dimensions>(grid: &G, region: &Range<Anchor>) -> Option<Span> {
|
||||||
let start = region.start.point;
|
let start = region.start.point;
|
||||||
let start_side = region.start.side;
|
let start_side = region.start.side;
|
||||||
let end = region.end.point;
|
let end = region.end.point;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue