From 800b65622cd8881f30d4d02e87c1ba4e4c9d27d2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 15:25:04 -0800 Subject: Remove need for step_by feature --- src/term/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 690c2f10..4c2afc35 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -20,7 +20,7 @@ use std::io; use ansi::{self, Color, NamedColor, Attr, Handler}; use grid::{Grid, ClearRegion, ToRange}; -use index::{self, Point, Column, Line, Linear}; +use index::{self, Point, Column, Line, Linear, IndexRange}; use selection::{Span, Selection}; pub mod cell; @@ -286,7 +286,7 @@ impl Term { let grid = Grid::new(num_lines, num_cols, &template); - let mut tabs = (Column(0)..grid.num_cols()) + let mut tabs = IndexRange::from(Column(0)..grid.num_cols()) .map(|i| (*i as usize) % TAB_SPACES == 0) .collect::>(); @@ -424,7 +424,7 @@ impl Term { // Starting line res.append(&self.grid, start.line, start.col..); - let middle_range = (start.line + 1)..(end.line); + let middle_range = IndexRange::from((start.line + 1)..(end.line)); for line in middle_range { res.append(&self.grid, line, ..); } @@ -507,7 +507,7 @@ impl Term { self.cursor.col = limit(self.cursor.col, Column(0), num_cols); // Recreate tabs list - self.tabs = (Column(0)..self.grid.num_cols()) + self.tabs = IndexRange::from(Column(0)..self.grid.num_cols()) .map(|i| (*i as usize) % TAB_SPACES == 0) .collect::>(); -- cgit From c579d079939b5d4ee3127579de732f037e612c28 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 15:48:23 -0800 Subject: Remove need for range_contains feature --- src/term/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 4c2afc35..975ba376 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -20,7 +20,7 @@ use std::io; use ansi::{self, Color, NamedColor, Attr, Handler}; use grid::{Grid, ClearRegion, ToRange}; -use index::{self, Point, Column, Line, Linear, IndexRange}; +use index::{self, Point, Column, Line, Linear, IndexRange, Contains}; use selection::{Span, Selection}; pub mod cell; @@ -129,7 +129,7 @@ impl<'a> Iterator for RenderableCellsIter<'a> { self.column += 1; let selected = self.selection.as_ref() - .map(|range| range.contains(index)) + .map(|range| range.contains_(index)) .unwrap_or(false); // Skip empty cells @@ -812,7 +812,7 @@ impl ansi::Handler for Term { #[inline] fn insert_blank_lines(&mut self, lines: Line) { debug_println!("insert_blank_lines: {}", lines); - if self.scroll_region.contains(self.cursor.line) { + if self.scroll_region.contains_(self.cursor.line) { let origin = self.cursor.line; self.scroll_down_relative(origin, lines); } @@ -821,7 +821,7 @@ impl ansi::Handler for Term { #[inline] fn delete_lines(&mut self, lines: Line) { debug_println!("delete_lines: {}", lines); - if self.scroll_region.contains(self.cursor.line) { + if self.scroll_region.contains_(self.cursor.line) { let origin = self.cursor.line; self.scroll_up_relative(origin, lines); } -- cgit From fbeded8ac543613b89af2ed7fd856e978493cde4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 16:26:31 -0800 Subject: Remove need for inclusive ranges --- src/term/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 975ba376..09ed5d41 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -13,14 +13,14 @@ // limitations under the License. // //! Exports the `Term` type which is a high-level API for the Grid -use std::ops::{Deref, Range, RangeInclusive}; +use std::ops::{Deref, Range}; use std::ptr; use std::cmp; use std::io; use ansi::{self, Color, NamedColor, Attr, Handler}; use grid::{Grid, ClearRegion, ToRange}; -use index::{self, Point, Column, Line, Linear, IndexRange, Contains}; +use index::{self, Point, Column, Line, Linear, IndexRange, Contains, RangeInclusive}; use selection::{Span, Selection}; pub mod cell; -- cgit From 49187d53f2f8b7cfca9105c3fb00d7c29e2a457b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 16:32:29 -0800 Subject: Add `nightly` feature, use for `unlikely` intrinsic --- src/term/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 09ed5d41..eab73e74 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -630,7 +630,7 @@ impl ansi::Handler for Term { } unsafe { - if ::std::intrinsics::unlikely(self.cursor.line == self.grid.num_lines()) { + if ::util::unlikely(self.cursor.line == self.grid.num_lines()) { panic!("cursor fell off grid"); } } -- cgit From 4e1f4c8cd7180606156b71ad0222f60e4559f2b3 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 20:44:51 -0800 Subject: Clippy fixes! --- src/term/mod.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index eab73e74..45dd8a45 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -306,7 +306,7 @@ impl Term { mode: Default::default(), scroll_region: scroll_region, size_info: size, - template_cell: template.clone(), + template_cell: template, empty_cell: template, } } @@ -498,7 +498,7 @@ impl Term { println!("num_cols, num_lines = {}, {}", num_cols, num_lines); // Resize grids to new size - let template = self.template_cell.clone(); + let template = self.template_cell; self.grid.resize(num_lines, num_cols, &template); self.alt_grid.resize(num_lines, num_cols, &template); @@ -514,7 +514,7 @@ impl Term { self.tabs[0] = false; // Make sure bottom of terminal is clear - let template = self.empty_cell.clone(); + let template = self.empty_cell; self.grid.clear_region((self.cursor.line).., |c| c.reset(&template)); self.alt_grid.clear_region((self.cursor.line).., |c| c.reset(&template)); @@ -538,7 +538,7 @@ impl Term { ::std::mem::swap(&mut self.cursor, &mut self.alt_cursor); if self.alt { - let template = self.empty_cell.clone(); + let template = self.empty_cell; self.grid.clear(|c| c.reset(&template)); } } @@ -551,7 +551,7 @@ impl Term { debug_println!("scroll_down: {}", lines); // Copy of cell template; can't have it borrowed when calling clear/scroll - let template = self.empty_cell.clone(); + let template = self.empty_cell; // Clear `lines` lines at bottom of area { @@ -576,7 +576,7 @@ impl Term { debug_println!("scroll_up: {}", lines); // Copy of cell template; can't have it borrowed when calling clear/scroll - let template = self.empty_cell.clone(); + let template = self.empty_cell; // Clear `lines` lines starting from origin to origin + lines { @@ -636,7 +636,7 @@ impl ansi::Handler for Term { } let cell = &mut self.grid[&self.cursor]; - *cell = self.template_cell.clone(); + *cell = self.template_cell; cell.c = c; self.cursor.col += 1; } @@ -682,7 +682,7 @@ impl ansi::Handler for Term { // Cells were just moved out towards the end of the line; fill in // between source and dest with blanks. - let template = self.empty_cell.clone(); + let template = self.empty_cell; for c in &mut line[source..destination] { c.reset(&template); } @@ -834,7 +834,7 @@ impl ansi::Handler for Term { let end = start + count; let row = &mut self.grid[self.cursor.line]; - let template = self.empty_cell.clone(); + let template = self.empty_cell; for c in &mut row[start..end] { c.reset(&template); } @@ -861,7 +861,7 @@ impl ansi::Handler for Term { // Clear last `count` cells in line. If deleting 1 char, need to delete // 1 cell. - let template = self.empty_cell.clone(); + let template = self.empty_cell; let end = self.size_info.cols() - count; for c in &mut line[end..] { c.reset(&template); @@ -891,7 +891,7 @@ impl ansi::Handler for Term { #[inline] fn clear_line(&mut self, mode: ansi::LineClearMode) { debug_println!("clear_line: {:?}", mode); - let template = self.empty_cell.clone(); + let template = self.empty_cell; match mode { ansi::LineClearMode::Right => { let row = &mut self.grid[self.cursor.line]; @@ -917,7 +917,7 @@ impl ansi::Handler for Term { #[inline] fn clear_screen(&mut self, mode: ansi::ClearMode) { debug_println!("clear_screen: {:?}", mode); - let template = self.empty_cell.clone(); + let template = self.empty_cell; match mode { ansi::ClearMode::Below => { for row in &mut self.grid[self.cursor.line..] { -- cgit