diff options
author | Joe Wilm <joe@jwilm.com> | 2018-02-16 17:54:32 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:32:29 -0700 |
commit | c49a7e88f64d1421474d492cc6f51bfd30e1e4d1 (patch) | |
tree | 970237ddc0a0f1702c417b2f072cd70a0e9c228a /src/grid | |
parent | 7fe67743ebffd047532f6271bf28474f9d947f64 (diff) | |
download | alacritty-c49a7e88f64d1421474d492cc6f51bfd30e1e4d1.tar.gz alacritty-c49a7e88f64d1421474d492cc6f51bfd30e1e4d1.zip |
Make number of scrollback lines configurable
Diffstat (limited to 'src/grid')
-rw-r--r-- | src/grid/mod.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index c6543270..1cb0876e 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -28,9 +28,6 @@ mod tests; mod storage; use self::storage::Storage; -/// Lines to keep in scrollback buffer -const SCROLLBACK_LINES: usize = 10_000; - /// Convert a type to a linear index range. pub trait ToRange { fn to_range(&self) -> RangeInclusive<index::Linear>; @@ -101,19 +98,8 @@ pub struct GridIterator<'a, T: 'a> { } impl<T: Copy + Clone> Grid<T> { - pub fn scroll_display(&mut self, count: isize) { - self.display_offset = min( - max((self.display_offset as isize) + count, 0isize) as usize, - self.scroll_limit - ); - } - - pub fn reset_scroll(&mut self) { - self.display_offset = 0; - } - - pub fn new(lines: index::Line, cols: index::Column, template: T) -> Grid<T> { - let mut raw = Storage::with_capacity(*lines + SCROLLBACK_LINES, lines); + pub fn new(lines: index::Line, cols: index::Column, scrollback: usize, template: T) -> Grid<T> { + let mut raw = Storage::with_capacity(*lines + scrollback, lines); let template_row = Row::new(cols, &template); // Allocate all lines in the buffer, including scrollback history @@ -137,6 +123,17 @@ impl<T: Copy + Clone> Grid<T> { } } + pub fn scroll_display(&mut self, count: isize) { + self.display_offset = min( + max((self.display_offset as isize) + count, 0isize) as usize, + self.scroll_limit + ); + } + + pub fn reset_scroll_display(&mut self) { + self.display_offset = 0; + } + pub fn resize(&mut self, lines: index::Line, cols: index::Column) { // Check that there's actually work to do and return early if not if lines == self.lines && cols == self.cols { |