Clamp scrolling to file contents
This commit is contained in:
parent
c2ef9f47e8
commit
29f0e7a28b
|
|
@ -76,12 +76,13 @@ def main(stdscr, filename):
|
|||
|
||||
elif focus == "right":
|
||||
if key == curses.KEY_DOWN or key == ord('j'):
|
||||
scroll_offset += 1
|
||||
if scroll_offset < max(0, len(file_lines) - height):
|
||||
scroll_offset += 1
|
||||
elif key == curses.KEY_UP or key == ord('k'):
|
||||
if scroll_offset > 0:
|
||||
scroll_offset -= 1
|
||||
elif key == curses.KEY_NPAGE: # Page Down
|
||||
scroll_offset += height
|
||||
scroll_offset = min(scroll_offset + height, max(0, len(file_lines) - height))
|
||||
elif key == curses.KEY_PPAGE: # Page Up
|
||||
scroll_offset = max(0, scroll_offset - height)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue