diff --git a/fasttyper/application.py b/fasttyper/application.py index 98fade3..b4461df 100644 --- a/fasttyper/application.py +++ b/fasttyper/application.py @@ -24,14 +24,13 @@ class Application: action, key = self.listener.listen(screen) if self.running(): self.buffer.handle_action(action, key) + return True except StoppingSignal as e: if e.silent: self.silent_exit = True if self.running(): self.buffer.stats.signal_stop() - except: - if self.running(): - self.buffer.stats.signal_stop() + return False def summarize(self): if self.finished: @@ -40,7 +39,7 @@ class Application: return False def exit(self): - if not self.finished and not self.silent_exit: + if not self.silent_exit: sys.exit(1) diff --git a/fasttyper/config.py b/fasttyper/config.py index 7cb4f53..d021ae4 100644 --- a/fasttyper/config.py +++ b/fasttyper/config.py @@ -12,7 +12,7 @@ class Config: "lines_on_screen": 3, "logo": "~FastTyper~", "logo_color": 8, - "resume_text": "press any key to continue, C to exit", + "resume_text": "press to continue, C to exit", "resume_text_color": 9, "end_template": ( "wpm: {wpm:.1f}/{peak_wpm:.1f} raw: {raw_wpm:.1f}/{peak_raw_wpm:.1f}", diff --git a/fasttyper/interface.py b/fasttyper/interface.py index 4cb864c..22cde93 100644 --- a/fasttyper/interface.py +++ b/fasttyper/interface.py @@ -1,4 +1,5 @@ import curses +from .application import StoppingSignal class Interface: @@ -54,4 +55,6 @@ class Interface: screen.clear() curses.curs_set(0) self.draw_end(screen) - self.application.action(screen) + + while self.application.action(screen): + pass diff --git a/fasttyper/listener.py b/fasttyper/listener.py index 321fd79..98dcaa7 100644 --- a/fasttyper/listener.py +++ b/fasttyper/listener.py @@ -1,5 +1,6 @@ import enum import string +import curses from .application import StoppingSignal @@ -64,5 +65,5 @@ class Listener: try: key = screen.get_wch() return self.handle_key(key) - except KeyboardInterrupt: + except (KeyboardInterrupt, curses.error): raise StoppingSignal() diff --git a/setup.cfg b/setup.cfg index 898de85..8fb17b0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.1.1 +current_version = 2.1.2 [wheel] universal = 1 diff --git a/setup.py b/setup.py index b0c8812..0206890 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ with open("requirements.txt", "r", encoding="utf-8") as fh: setup( name="fasttyper", - version="2.1.1", + version="2.1.2", author="Piotr Domanski", author_email="pi.domanski@gmail.com", description="Minimalistic typing exercise",