tcr / rager

A pager written in Rust, like more or less.
https://crates.io/crates/rager
52 stars 12 forks source link

Vim keybinding support #9

Open E5ten opened 5 years ago

E5ten commented 5 years ago

The pressed_g value is used for pressing "gg" to go to the top of the page, given that I don't know rust I probably didn't use the best practices here, but the value is set from n to y the first time g is pressed, and reset to n after any other letter is pressed, on second press it will trigger going to the top of the page. All the other keybinds are just their non-vim counterpart with the key replaced.

tcr commented 5 years ago

Using the characters 'y' and 'n' as values is so such a nice way to do this! After thinking about this, a simple approach that scales well might be to make pressed_g a usize that just tracks the number of successive g keys in a row. So each non-g command would reset it to 0, while pressing g increments it. And if it equals 2, the scroll to top occurs, and it gets reset to 0 as well. If that makes sense.

E5ten commented 5 years ago

@tcr That definitely sounds like a good way to do it, I'll try to see if I can figure that out.

E5ten commented 5 years ago

Does this look like what you were talking about?

E5ten commented 5 years ago

@tcr Is there anything keeping this open?

soloturn commented 1 year ago

@tcr ?