Support for scrolling more than 1 line at a time while paging
Closed this issue · 2 comments
This is a feature request for scrolling more than 1 line at a time while paging, akin to typing 5k
or 100j
while viewing a file in vim.
I have worked on this a bit and have a few implementations that will work, but they all require breaking changes to the InputClassifier
trait. This is because, before this feature, the input classifier didn't need to store any state between different calls of classify_input
, but it must to implement this feature, since it requires handling multiple characters.
The three implementations I've considered (and successfully implemented) are:
- Adding another parameter to the
classify_input
fn, e.g.line_count: &mut Option<String>
so that if a numeric key is pressed, it can be appended toline_count
, then the fn can returnNone
, and it assume that nothing was input. - Changing the parameters of
classify_input
to take, instead of many parameters, a single struct (e.g.InputParameters
) that will contain everything that was previously a parameters ofclassify_input
. This will allow you to add extra members (and thus functionality) toInputParameters
later without it being a breaking change - Modifying the
classify_input
fn to take&mut self
instead of&self
so that theDefaultInputHandler
can store and modify state whenclassify_input
is called. I think this is the best solution, but I also think it may take more work than the others (borrow checker gets in the way with some mutable/immutable reference rules when you try to just change&self
to&mut self
).
I would very much like this feature, and would like your thoughts on if you would like it as well, and what you think the best solution is. If you can think of a different way to implement this that would not require a breaking change, that would also be much appreciated and I'd be more than happy to put some work into it.
Thanks for the issue. I am working on an implementation. There might be some breaking changes so I have to do some research
This is now implemented and will be available in the next major release of minus
. You can prefix j
, k
, Up
or Down
keys with a number to scroll to that by the number of lines.
Prefixing G
with a number will take you exactly to that line.
Thanks for filling the issue. Marking it as resolved