summaryrefslogtreecommitdiff
path: root/src/grid/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r--src/grid/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index a52c27c5..ac761adc 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -176,6 +176,26 @@ impl<T: Copy + Clone> Grid<T> {
self.display_offset = 0;
}
+ pub fn scroll_to_top(&mut self) {
+ self.display_offset = self.scroll_limit;
+ }
+
+ pub fn scroll_page_up(&mut self) {
+ if self.display_offset + self.lines.0 >= self.scroll_limit {
+ self.display_offset = self.scroll_limit;
+ } else {
+ self.display_offset += self.lines.0;
+ }
+ }
+
+ pub fn scroll_page_down(&mut self) {
+ if self.display_offset <= self.lines.0 {
+ self.display_offset = 0;
+ } else {
+ self.display_offset -= self.lines.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 {