diff kitten: Add keybindings to scroll by a page

This commit is contained in:
Kovid Goyal
2018-05-24 15:17:03 +05:30
parent 219d3161d9
commit a33ebce3c9
5 changed files with 13 additions and 3 deletions

View File

@@ -73,7 +73,7 @@ def parse_scroll_by(func, rest):
@func_with_args('scroll_to')
def parse_scroll_to(func, rest):
rest = rest.lower()
if rest not in {'start', 'end', 'next-change', 'prev-change'}:
if rest not in {'start', 'end', 'next-change', 'prev-change', 'next-page', 'prev-page'}:
rest = 'start'
return func, rest

View File

@@ -47,6 +47,9 @@ map down scroll_by 1
map up scroll_by -1
map home scroll_to start
map end scroll_to end
map page_down scroll_to next-page
map page_up scroll_to prev-page
map space scroll_to next-page
map n scroll_to next-change
map p scroll_to prev-change
map a change_context all

View File

@@ -76,7 +76,10 @@ class DiffHandler(Handler):
where = args[0]
if 'change' in where:
return self.scroll_to_next_change(backwards='prev' in where)
amt = len(self.diff_lines) * (1 if 'end' in where else -1)
if 'page' in where:
amt = self.num_lines * (1 if 'next' in where else -1)
else:
amt = len(self.diff_lines) * (1 if 'end' in where else -1)
return self.scroll_lines(amt)
if func == 'change_context':
new_ctx = self.current_context_count