summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Stanley <fungi@yuggoth.org>2015-07-22 20:16:21 +0000
committerJames E. Blair <corvus@gnu.org>2015-07-25 09:12:16 -0700
commitff07c4700e19cd3197fd8bac1ab8346b18aaaf15 (patch)
tree85c3eb4c285765f6e6570a16f72521ef206b532e
parent12060b060c23e76ca075114c9d4981c288387ad8 (diff)
Use the q key to quit gracefully
Relying on ctrl-C user interrupt to exit leaves the terminal in a dirty state, and potentially unusable. Add the ability to exit gracefully by pressing the q key.
-rw-r--r--README.rst2
-rw-r--r--presentty/console.py2
-rw-r--r--presentty/presentty.py2
3 files changed, 6 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index 1855710..1e4a37f 100644
--- a/README.rst
+++ b/README.rst
@@ -56,6 +56,8 @@ In either the presenter's console or the main presentty window, the
56left and right arrow keys or page-up and page-down navigate between 56left and right arrow keys or page-up and page-down navigate between
57slides. 57slides.
58 58
59To exit presentty gracefully, use the 'q' key.
60
59Source 61Source
60------ 62------
61 63
diff --git a/presentty/console.py b/presentty/console.py
index d29b864..d10dc3e 100644
--- a/presentty/console.py
+++ b/presentty/console.py
@@ -172,6 +172,8 @@ class Screen(urwid.WidgetWrap):
172 self.console.prev() 172 self.console.prev()
173 elif key == 't': 173 elif key == 't':
174 self.console.timerDialog() 174 self.console.timerDialog()
175 elif key == 'q':
176 raise urwid.ExitMainLoop()
175 else: 177 else:
176 return super(Screen, self).keypress(size, key) 178 return super(Screen, self).keypress(size, key)
177 return None 179 return None
diff --git a/presentty/presentty.py b/presentty/presentty.py
index 35e19c1..b7589bf 100644
--- a/presentty/presentty.py
+++ b/presentty/presentty.py
@@ -78,6 +78,8 @@ class Presenter(object):
78 self.nextSlide() 78 self.nextSlide()
79 elif key in ('left', 'page up'): 79 elif key in ('left', 'page up'):
80 self.prevSlide() 80 self.prevSlide()
81 elif key == 'q':
82 raise urwid.ExitMainLoop()
81 83
82 def transitionTo(self, index, forward=True): 84 def transitionTo(self, index, forward=True):
83 self.pos = index 85 self.pos = index