aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-03-11 13:01:06 +0100
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:56:50 -0700
commit0dcb9ca6a871fd6d28787142a134c9190001ac43 (patch)
tree8f1f4845942c7af562173b9e670ca61664ee49ee /src/input.rs
parent2c7bb9a4d3ce3ead6de4ca6485ca67c44c0bd1c1 (diff)
downloadalacritty-0dcb9ca6a871fd6d28787142a134c9190001ac43.tar.gz
alacritty-0dcb9ca6a871fd6d28787142a134c9190001ac43.zip
Replace scrolling methods with enum
The different scrolling methods added a bunch of boilerplate where the call was just forwarded to the next struct, this has been removed by making the scroll amount into a struct. Now everything is called through one method and the parameter decides how far the viewport should be scrolled.
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/input.rs b/src/input.rs
index adce3448..8cf11811 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -28,6 +28,7 @@ use copypasta::{Clipboard, Load, Buffer};
use glutin::{ElementState, VirtualKeyCode, MouseButton, TouchPhase, MouseScrollDelta, ModifiersState};
use config;
+use grid::Scroll;
use event::{ClickState, Mouse};
use index::{Line, Column, Side, Point};
use term::SizeInfo;
@@ -65,11 +66,7 @@ pub trait ActionContext {
fn last_modifiers(&mut self) -> &mut ModifiersState;
fn change_font_size(&mut self, delta: i8);
fn reset_font_size(&mut self);
- fn scroll(&mut self, count: isize);
- fn reset_scroll(&mut self);
- fn scroll_to_top(&mut self);
- fn scroll_page_up(&mut self);
- fn scroll_page_down(&mut self);
+ fn scroll(&mut self, scroll: Scroll);
}
/// Describes a state and action to take in that state
@@ -254,16 +251,16 @@ impl Action {
ctx.reset_font_size();
},
Action::ScrollPageUp => {
- ctx.scroll_page_up();
+ ctx.scroll(Scroll::PageUp);
},
Action::ScrollPageDown => {
- ctx.scroll_page_down();
+ ctx.scroll(Scroll::PageDown);
},
Action::ScrollToTop => {
- ctx.scroll_to_top();
+ ctx.scroll(Scroll::Top);
},
Action::ScrollToBottom => {
- ctx.reset_scroll();
+ ctx.scroll(Scroll::Bottom);
},
}
}
@@ -527,7 +524,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
self.ctx.write_to_pty(content);
} else {
for _ in 0..scroll_multiplier {
- self.ctx.scroll(-((code as isize) * 2 - 129));
+ self.ctx.scroll(Scroll::Lines(-((code as isize) * 2 - 129)));
}
}
}
@@ -597,7 +594,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
/// Process a received character
pub fn received_char(&mut self, c: char) {
if !*self.ctx.suppress_chars() {
- self.ctx.reset_scroll();
+ self.ctx.scroll(Scroll::Bottom);
self.ctx.clear_selection();
let utf8_len = c.len_utf8();