From 85290711e3be3f54d1cedcea989e44fa213cbf9e Mon Sep 17 00:00:00 2001 From: MovingtoMars Date: Sat, 17 Jan 2015 16:02:25 +1300 Subject: [PATCH 1/3] Add several new keybindings Page down and page up select the last and first elements respectively. '+' and '-' can now be used in addition right and left arrow keys to control volume. 'm' sets the volume of the selected element to zero. --- ui.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui.py b/ui.py index d985cd8..87cda59 100644 --- a/ui.py +++ b/ui.py @@ -97,16 +97,18 @@ class VolumeWidget(OneLineWidget): self.parent.addstr(y, slidex+slidewleft, "-"*slidewright) def on_key(self, c, ui): - if c == curses.KEY_LEFT: + if c in (curses.KEY_LEFT, ord('-')): # Increase the volume self.volume.inc_volume(-1) - elif c == curses.KEY_RIGHT: + elif c in (curses.KEY_RIGHT, ord('+')): # Decrease the volume self.volume.inc_volume(1) + elif c == ord('m'): + self.volume.set_volume(0) else: return False return True - + class ScrollableList: """ Object representing a list of OneLineWidgets that can be browsed and @@ -185,9 +187,16 @@ class ScrollableList: self.set_selection(selection) + def select_first_widget(self): + self.set_selection(0) + + def select_last_widget(self): + self.set_selection(len(self.widgets) - 1) + def draw(self, stop, sleft, sbottom, sright): """ - Draw the list in the portion of the screen delimited by the + Draw the list in the portion of the scree + n delimited by the coordinates (stop, sleft, sbottom, sright) """ height = sbottom-stop @@ -211,6 +220,10 @@ class ScrollableList: self.select_next_widget() elif c == curses.KEY_UP: self.select_previous_widget() + elif c == curses.KEY_PPAGE: # page up + self.select_first_widget() + elif c == curses.KEY_NPAGE: # page down + self.select_last_widget() else: selection = self.get_selection() if selection != None: From 8e1f4ad19f48cf0f9effa7aec84c5886de002089 Mon Sep 17 00:00:00 2001 From: MovingtoMars Date: Sat, 17 Jan 2015 16:04:39 +1300 Subject: [PATCH 2/3] undo accidental newline --- ui.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui.py b/ui.py index 87cda59..2dc51cb 100644 --- a/ui.py +++ b/ui.py @@ -195,8 +195,7 @@ class ScrollableList: def draw(self, stop, sleft, sbottom, sright): """ - Draw the list in the portion of the scree - n delimited by the + Draw the list in the portion of the scree n delimited by the coordinates (stop, sleft, sbottom, sright) """ height = sbottom-stop From ba3724f3aa5faedf6ed17137b681691ae9e86e25 Mon Sep 17 00:00:00 2001 From: MovingtoMars Date: Sat, 17 Jan 2015 16:13:23 +1300 Subject: [PATCH 3/3] fix previous fix --- ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.py b/ui.py index 2dc51cb..27dc475 100644 --- a/ui.py +++ b/ui.py @@ -195,7 +195,7 @@ class ScrollableList: def draw(self, stop, sleft, sbottom, sright): """ - Draw the list in the portion of the scree n delimited by the + Draw the list in the portion of the screen delimited by the coordinates (stop, sleft, sbottom, sright) """ height = sbottom-stop