diff options
author | Canop <cano.petrole@gmail.com> | 2020-07-14 09:37:39 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-07-14 09:37:39 +0200 |
commit | 406e54cd90dd047e6171d3d29b1350e2aaf22931 (patch) | |
tree | f31bd2fa08b8e40107fa71d9100cfc88846242f8 /src/command | |
parent | 79af2798986f78afe37e13ccd3486c7b1f511880 (diff) |
previews now scrollable
A little too much code duplication for scroll.
I'll refactor at some point.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/mod.rs | 2 | ||||
-rw-r--r-- | src/command/scroll.rs | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs index 19c5e19..98fe403 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -3,6 +3,7 @@ mod completion; mod event; mod parts; mod sequence; +mod scroll; mod trigger_type; pub use { @@ -11,5 +12,6 @@ pub use { event::PanelInput, parts::CommandParts, sequence::parse_command_sequence, + scroll::ScrollCommand, trigger_type::TriggerType, }; diff --git a/src/command/scroll.rs b/src/command/scroll.rs new file mode 100644 index 0000000..2cfd8e9 --- /dev/null +++ b/src/command/scroll.rs @@ -0,0 +1,16 @@ + +#[derive(Debug, Clone, Copy)] +pub enum ScrollCommand { + Lines(i32), + Pages(i32), +} + +impl ScrollCommand { + pub fn to_lines(self, page_height: i32) -> i32 { + match self { + Self::Lines(n) => n, + Self::Pages(n) => n * page_height, + } + } +} + |