wustho / epr

CLI Epub Reader
MIT License
1.2k stars 49 forks source link

Scroll half a page up/down #28

Closed jneidel closed 3 years ago

jneidel commented 4 years ago

Use the keys d and u (from ^d/^u in vim) to go down/up half a page.

wustho commented 4 years ago

Hello there, just implement half screen scroll: https://github.com/wustho/epr/commit/bff2316efe578185db59b402e7fa5745fde89b4f.

Sorry took so long for such a simple stuff. Because I wanted to make visual indicator (some kinda like kanliot suggest in https://github.com/wustho/epr/issues/26) when we scroll more than a single line (by using 5j (scroll down 5 lines), 6k (scroll up 6 lines) or half screen scroll up|down, but not page up|down). So we can get visual line looking like this when we scroll down more than one line:

...
line displayed in screen before scroll
line displayed in screen before scroll
--------------------------------------  <-- visual line
line not yet displayed before scroll
line not yet displayed before scroll
...

And when we scroll up more than one line, we will get:

...
line not yet displayed before scroll
line not yet displayed before scroll
--------------------------------------  <-- visual line
line displayed in screen before scroll
line displayed in screen before scroll
...
jneidel commented 4 years ago

Thanks a lot!

What keys does this translate to?

# key bindings
HALF_DOWN = {4}
HALF_UP = {21}

And it should probably be added to help screen and --help flag usage info :smile:

wustho commented 4 years ago

Forgot to edit help text... Just fixed it...

4 translates to ^d and 21 to ^u like you suggest. Reference: ASCII chars.