From bb9e0f1631dd0773ba24d023b57cafba4b283a74 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: 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. --- bin/printer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin/printer.py') 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: -- cgit v1.2.1