Add vim-like page scrolling
* feat: added match fallback for handle_command SelectViewExt * feat: HalfPage and FullPage MoveAmount variants * feat: Display for MoveAmount variants * feat: fallback for MoveAmount variants in TabView * feat: ListView FullPage/HalfPage MoveAmount * feat: default keybinds for page scrolling * feat: HalfPage/FullPage MoveAmount for HelpView * feat: removed new defaul keybinds for pagescroll * style: "upwards" -> "halfpageup" etc. * feat: toml parse "move pageup" / "move halfpageup" * chore: cargo fmt * feat: simplified page scroll command interface * docs: added `move` to readme * feat: replace FullPage and HalfPage with Float variant * fix: remove stray variant * dosc: update move command * chore: fmt * feat: implement MoveAmount::Float for selectview * chore: fmt
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use cursive::views::ViewRef;
|
||||
use cursive::{View, XY};
|
||||
|
||||
use crate::command::{Command, MoveAmount, MoveMode};
|
||||
use crate::commands::CommandResult;
|
||||
@@ -37,6 +38,10 @@ impl<T: 'static> SelectViewExt for cursive::views::SelectView<T> {
|
||||
MoveMode::Up => {
|
||||
match amount {
|
||||
MoveAmount::Extreme => self.set_selection(0),
|
||||
MoveAmount::Float(scale) => {
|
||||
let amount = (*self).required_size(XY::default()).y as f32 * scale;
|
||||
self.select_up(amount as usize)
|
||||
}
|
||||
MoveAmount::Integer(amount) => self.select_up(*amount as usize),
|
||||
};
|
||||
Ok(CommandResult::Consumed(None))
|
||||
@@ -44,6 +49,10 @@ impl<T: 'static> SelectViewExt for cursive::views::SelectView<T> {
|
||||
MoveMode::Down => {
|
||||
match amount {
|
||||
MoveAmount::Extreme => self.set_selection(items),
|
||||
MoveAmount::Float(scale) => {
|
||||
let amount = (*self).required_size(XY::default()).y as f32 * scale;
|
||||
self.select_down(amount as usize)
|
||||
}
|
||||
MoveAmount::Integer(amount) => self.select_down(*amount as usize),
|
||||
};
|
||||
Ok(CommandResult::Consumed(None))
|
||||
|
||||
Reference in New Issue
Block a user