From ce116aeade07eb57760e42dbbeeca83ded8214ce Mon Sep 17 00:00:00 2001 From: troido Date: Wed, 23 May 2018 20:36:47 +0200 Subject: game doesn't crash anymore when cursor can't be set --- asciifarm/client/display/screen.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'asciifarm/client/display/screen.py') diff --git a/asciifarm/client/display/screen.py b/asciifarm/client/display/screen.py index 21d7200..605eca5 100644 --- a/asciifarm/client/display/screen.py +++ b/asciifarm/client/display/screen.py @@ -9,7 +9,19 @@ class Screen: def __init__(self, display, stdscr, colours): self.display = display - curses.curs_set(0) + try: + curses.curs_set(0) + self.cursorSet = False + except curses.error: + # Not all terminals support this functionality. + # When the error is ignored the screen will look a little uglier, + # A cursor will move around, but that's not terrible + # So in order to keep the game as accesible as possible to everyone, it should be safe to ignore the error. + self.cursorSet = True + # It is probably possible to make sure the cursor is only in a corner of the screen + # but I can't figure out how. + # it seems to ignore all my move commands unless I press a key + # I give up self.stdscr = stdscr self.colours = colours self.setWins() @@ -67,7 +79,6 @@ class Screen: self.display.forceUpdate() def update(self): - curses.doupdate() def getWidth(self): @@ -76,3 +87,4 @@ class Screen: def getHeight(self): return self.height + -- cgit