due to an urwid-library technicality, some mouse events like scroll or click would crash scyllatop. This patch fixes this problem. closes issue #1396. Signed-off-by: Yoav Kleinberger <yoav@scylladb.com> Message-Id: <1467294117-19218-1-git-send-email-yoav@scylladb.com>
27 lines
648 B
Python
27 lines
648 B
Python
import urwid
|
|
import logging
|
|
|
|
|
|
class UserInput(object):
|
|
def __init__(self):
|
|
self._viewMap = None
|
|
self._mainLoop = None
|
|
|
|
def setMap(self, ** viewMap):
|
|
self._viewMap = viewMap
|
|
|
|
def setLoop(self, loop):
|
|
self._mainLoop = loop
|
|
|
|
def __call__(self, keypress):
|
|
logging.debug('keypress={}'.format(keypress))
|
|
if keypress in ('q', 'Q'):
|
|
raise urwid.ExitMainLoop()
|
|
if type(keypress) is not str:
|
|
return
|
|
if keypress.upper() not in self._viewMap:
|
|
return
|
|
|
|
view = self._viewMap[keypress.upper()]
|
|
self._mainLoop.widget = view.widget()
|