def processKeystroke(self, window, kstroke): if kstroke in [curses.KEY_ENTER, 10]: cdo(self._commitBuffer) else: self._textInput(window,kstroke) cdo(self._updatePrompt) return True
def __init__(self): self.prompt="[%03d]" #Window relative attributes self.max_x=0 self.max_y=0 self.text_buffer = "" super(TNTGui, self).__init__() #We need a curses window object window = curses.initscr() cdo(self._fillWindowData) cdo(self.hidListener)
def hidListener(self,window): running = True try: while running: curses.echo() curses.cbreak() window.keypad(1) #FIXME: This patches a bug in wrapper last_stroke = window.getch() running = cdo(self.processKeystroke, last_stroke) except KeyboardInterrupt: pass except Exception, e: raise self._destroy(1)
def _commitBuffer(self,window): write_buffer = self._getPromptText(window) cdo(self._drawWindow) cdo(self._moveToOrigin)
def _fillWindowData(self, window): self.max_y, self.max_x = window.getmaxyx() self.max_y -= 1 self.max_x -= 1 cdo(self._drawWindow) self._moveToOrigin(window)