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> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net> Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/595
This commit is contained in:
parent
137130fbd0
commit
c9f71b0c64
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user