summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEijebong <eijebong@bananium.fr>2016-09-17 18:00:51 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-09-20 16:58:42 +0900
commit3199e05e338732c1ffcd788f89ce51de50e26d91 (patch)
tree544ecee0febfdc2a610e5d1ed1f8d56ff266f4e0
parent5a5c1fe9920f0a6c571e8c33f650371879de35dd (diff)
downloadpoezio-3199e05e338732c1ffcd788f89ce51de50e26d91.tar.gz
poezio-3199e05e338732c1ffcd788f89ce51de50e26d91.tar.bz2
poezio-3199e05e338732c1ffcd788f89ce51de50e26d91.tar.xz
poezio-3199e05e338732c1ffcd788f89ce51de50e26d91.zip
Add a PgUp/PgDown keybind to /bookmarks.
Fixes #3231
-rw-r--r--poezio/tabs/bookmarkstab.py6
-rw-r--r--poezio/windows/bookmark_forms.py38
2 files changed, 44 insertions, 0 deletions
diff --git a/poezio/tabs/bookmarkstab.py b/poezio/tabs/bookmarkstab.py
index 5416712b..e11f8aba 100644
--- a/poezio/tabs/bookmarkstab.py
+++ b/poezio/tabs/bookmarkstab.py
@@ -61,6 +61,12 @@ class BookmarksTab(Tab):
self.core.close_tab(self)
return True
+ def on_scroll_down(self):
+ return self.bookmarks_win.go_to_next_page()
+
+ def on_scroll_up(self):
+ return self.bookmarks_win.go_to_previous_page()
+
def on_save(self):
self.bookmarks_win.save()
if find_duplicates(self.new_bookmarks):
diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py
index 9a3c80fd..98a3889e 100644
--- a/poezio/windows/bookmark_forms.py
+++ b/poezio/windows/bookmark_forms.py
@@ -227,6 +227,44 @@ class BookmarksWin(Win):
self.current_horizontal_input = 0
self.lines[self.current_input][self.current_horizontal_input].set_color(get_theme().COLOR_SELECTED_ROW)
+ def go_to_next_page(self):
+ if not self.lines:
+ return
+
+ if self.current_input == len(self.lines) - 1:
+ return
+
+ self.lines[self.current_input][self.current_horizontal_input].set_color(get_theme().COLOR_NORMAL_TEXT)
+ inc = min(self.height, len(self.lines) - self.current_input - 1)
+
+ if self.current_input + inc - self.scroll_pos > self.height - 1:
+ self.current_input += inc
+ self.scroll_pos += inc
+ self.refresh()
+ else:
+ self.current_input += inc
+ self.lines[self.current_input][self.current_horizontal_input].set_color(get_theme().COLOR_SELECTED_ROW)
+ return True
+
+ def go_to_previous_page(self):
+ if not self.lines:
+ return
+
+ if self.current_input == 0:
+ return
+
+ self.lines[self.current_input][self.current_horizontal_input].set_color(get_theme().COLOR_NORMAL_TEXT)
+
+ dec = min(self.height, self.current_input)
+ self.current_input -= dec
+ # Adjust the scroll position if the current_input would be outside
+ # of the visible area
+ if self.current_input < self.scroll_pos:
+ self.scroll_pos = self.current_input
+ self.refresh()
+ self.lines[self.current_input][self.current_horizontal_input].set_color(get_theme().COLOR_SELECTED_ROW)
+ return True
+
def go_to_previous_horizontal_input(self):
if not self.lines:
return