aboutsummaryrefslogtreecommitdiff
path: root/bin/printer.py
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
commitbb9e0f1631dd0773ba24d023b57cafba4b283a74 (patch)
treef94482d735a854e438227973b449a138cbcd1c9f /bin/printer.py
parent3693aced9cc6417b4540dfda08f7733146ce0392 (diff)
ESCAPE key no longer quits simulation.
[#19] I felt it was too easy to quit the simulation accidentally. Now, a user has to type 'q' or 'quit' on the console in order to exit.
Diffstat (limited to 'bin/printer.py')
-rw-r--r--bin/printer.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/printer.py b/bin/printer.py
index 67794ea..9997a0c 100644
--- a/bin/printer.py
+++ b/bin/printer.py
@@ -20,6 +20,8 @@ from world import World
class Printer:
+ ESCAPE_KEY = 27
+
def __init__(self, sim):
""" Printer constructor. It takes care of starting up curses, defining
the data pages and setting the printer on its initial state.
@@ -248,7 +250,7 @@ class Printer:
self.screen.move(self.__curs_y, self.__curs_x)
cmd = self.screen.getch()
- if cmd in [ord("c"), curses.KEY_RESIZE, Handler.ESCAPE_KEY]:
+ if cmd in [ord("c"), curses.KEY_RESIZE, self.ESCAPE_KEY]:
self.on_resize()
break
elif cmd == curses.KEY_LEFT:
@@ -305,7 +307,7 @@ class Printer:
def validator(cmd):
EXIT = 7
- if cmd in [curses.KEY_RESIZE, Handler.ESCAPE_KEY]:
+ if cmd in [curses.KEY_RESIZE, self.ESCAPE_KEY]:
console.clear()
return EXIT
elif cmd == curses.KEY_UP: