1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

Range::contains is now stable; use it.

This commit is contained in:
Wez Furlong 2019-05-26 11:40:33 -07:00
parent e5fe668bbc
commit 607e180122
6 changed files with 4 additions and 17 deletions

View File

@ -908,7 +908,7 @@ impl Renderer {
fg_color: RgbaTuple,
bg_color: RgbaTuple,
) -> (RgbaTuple, RgbaTuple) {
let selected = term::in_range(cell_idx, selection);
let selected = selection.contains(&cell_idx);
let is_cursor = line_idx as i64 == cursor.y && cursor.x == cell_idx;
let (fg_color, bg_color) = match (selected, is_cursor) {

View File

@ -53,11 +53,6 @@ pub type VisibleRowIndex = i64;
/// to want to scroll back or select more than ~2billion lines of scrollback.
pub type ScrollbackOrVisibleRowIndex = i32;
/// range.contains(), but that is unstable
pub fn in_range<T: Ord + Copy>(value: T, range: &Range<T>) -> bool {
value >= range.start && value < range.end
}
/// Returns true if r1 intersects r2
pub fn intersects_range<T: Ord + Copy>(r1: Range<T>, r2: Range<T>) -> bool {
use std::cmp::{max, min};

View File

@ -1577,7 +1577,7 @@ impl TerminalState {
self.clear_selection_if_intersects(x..limit, y as ScrollbackOrVisibleRowIndex);
}
Edit::DeleteLine(n) => {
if in_range(self.cursor.y, &self.scroll_region) {
if self.scroll_region.contains(&self.cursor.y) {
let scroll_region = self.cursor.y..self.scroll_region.end;
self.screen_mut().scroll_up(&scroll_region, n as usize);
@ -1629,7 +1629,7 @@ impl TerminalState {
self.clear_selection_if_intersects(x..limit, y as ScrollbackOrVisibleRowIndex);
}
Edit::InsertLine(n) => {
if in_range(self.cursor.y, &self.scroll_region) {
if self.scroll_region.contains(&self.cursor.y) {
let scroll_region = self.cursor.y..self.scroll_region.end;
self.screen_mut().scroll_down(&scroll_region, n as usize);

View File

@ -43,7 +43,6 @@ pub mod image;
pub mod input;
pub mod istty;
pub mod keymap;
mod range;
mod readbuf;
pub mod render;
pub mod surface;

View File

@ -1,6 +0,0 @@
use std::ops::Range;
/// range.contains(), but that is unstable
pub fn in_range<T: Ord + Copy>(value: T, range: &Range<T>) -> bool {
value >= range.start && value < range.end
}

View File

@ -1,7 +1,6 @@
use crate::cell::{Cell, CellAttributes};
use crate::cellcluster::CellCluster;
use crate::hyperlink::Rule;
use crate::range::in_range;
use crate::surface::Change;
use bitflags::bitflags;
use serde_derive::*;
@ -153,7 +152,7 @@ impl Line {
// Don't replace existing links
continue;
}
if in_range(byte_idx, &m.range) {
if m.range.contains(&byte_idx) {
let attrs = self.cells[cell_idx]
.attrs()
.clone()