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:
parent
e5fe668bbc
commit
607e180122
@ -908,7 +908,7 @@ impl Renderer {
|
|||||||
fg_color: RgbaTuple,
|
fg_color: RgbaTuple,
|
||||||
bg_color: RgbaTuple,
|
bg_color: RgbaTuple,
|
||||||
) -> (RgbaTuple, 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 is_cursor = line_idx as i64 == cursor.y && cursor.x == cell_idx;
|
||||||
|
|
||||||
let (fg_color, bg_color) = match (selected, is_cursor) {
|
let (fg_color, bg_color) = match (selected, is_cursor) {
|
||||||
|
@ -53,11 +53,6 @@ pub type VisibleRowIndex = i64;
|
|||||||
/// to want to scroll back or select more than ~2billion lines of scrollback.
|
/// to want to scroll back or select more than ~2billion lines of scrollback.
|
||||||
pub type ScrollbackOrVisibleRowIndex = i32;
|
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
|
/// Returns true if r1 intersects r2
|
||||||
pub fn intersects_range<T: Ord + Copy>(r1: Range<T>, r2: Range<T>) -> bool {
|
pub fn intersects_range<T: Ord + Copy>(r1: Range<T>, r2: Range<T>) -> bool {
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
@ -1577,7 +1577,7 @@ impl TerminalState {
|
|||||||
self.clear_selection_if_intersects(x..limit, y as ScrollbackOrVisibleRowIndex);
|
self.clear_selection_if_intersects(x..limit, y as ScrollbackOrVisibleRowIndex);
|
||||||
}
|
}
|
||||||
Edit::DeleteLine(n) => {
|
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;
|
let scroll_region = self.cursor.y..self.scroll_region.end;
|
||||||
self.screen_mut().scroll_up(&scroll_region, n as usize);
|
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);
|
self.clear_selection_if_intersects(x..limit, y as ScrollbackOrVisibleRowIndex);
|
||||||
}
|
}
|
||||||
Edit::InsertLine(n) => {
|
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;
|
let scroll_region = self.cursor.y..self.scroll_region.end;
|
||||||
self.screen_mut().scroll_down(&scroll_region, n as usize);
|
self.screen_mut().scroll_down(&scroll_region, n as usize);
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ pub mod image;
|
|||||||
pub mod input;
|
pub mod input;
|
||||||
pub mod istty;
|
pub mod istty;
|
||||||
pub mod keymap;
|
pub mod keymap;
|
||||||
mod range;
|
|
||||||
mod readbuf;
|
mod readbuf;
|
||||||
pub mod render;
|
pub mod render;
|
||||||
pub mod surface;
|
pub mod surface;
|
||||||
|
@ -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
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
use crate::cell::{Cell, CellAttributes};
|
use crate::cell::{Cell, CellAttributes};
|
||||||
use crate::cellcluster::CellCluster;
|
use crate::cellcluster::CellCluster;
|
||||||
use crate::hyperlink::Rule;
|
use crate::hyperlink::Rule;
|
||||||
use crate::range::in_range;
|
|
||||||
use crate::surface::Change;
|
use crate::surface::Change;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use serde_derive::*;
|
use serde_derive::*;
|
||||||
@ -153,7 +152,7 @@ impl Line {
|
|||||||
// Don't replace existing links
|
// Don't replace existing links
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if in_range(byte_idx, &m.range) {
|
if m.range.contains(&byte_idx) {
|
||||||
let attrs = self.cells[cell_idx]
|
let attrs = self.cells[cell_idx]
|
||||||
.attrs()
|
.attrs()
|
||||||
.clone()
|
.clone()
|
||||||
|
Loading…
Reference in New Issue
Block a user