add checks in curses ui for small windows

addch() and addstr() throw an exception if text has to be printed
outside of the window. This may occur if the terminal is very small.
Such erroneous prints are no-ops now.

Signed-off-by: Mart Lubbers <mart@martlubbers.net>
This commit is contained in:
Mart Lubbers 2019-02-13 11:59:34 +01:00
parent 137130fbd0
commit b4cb233f4a
1 changed files with 11 additions and 2 deletions

View File

@ -137,7 +137,13 @@ class CursesAccountFrame:
sleepstr = '%3d:%02d'% (secs // 60, secs % 60) if secs else 'active'
accstr = '%s: [%s] %12.12s: '% (self.acc_num, sleepstr, self.account)
self.ui.exec_locked(self.window.addstr, 0, 0, accstr)
def addstr():
try:
self.window.addstr(0, 0, accstr)
except curses.error as e: # Occurs when the terminal is very small
pass
self.ui.exec_locked(addstr);
self.location = len(accstr)
def setwindow(self, curses_win, acc_num):
@ -211,7 +217,10 @@ class CursesThreadFrame:
def display(self):
def locked_display():
self.window.addch(self.y, self.x, '@', self.curses_color)
try:
self.window.addch(self.y, self.x, '@', self.curses_color)
except curses.error: # Occurs when the terminal is very small
pass
self.window.refresh()
# lock the curses IO while fudging stuff
self.ui.exec_locked(locked_display)