コード例 #1
0
ファイル: gui_curses.py プロジェクト: aseba/TNT
 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
コード例 #2
0
ファイル: gui_curses.py プロジェクト: aseba/TNT
 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)
コード例 #3
0
ファイル: gui_curses.py プロジェクト: aseba/TNT
 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)
コード例 #4
0
ファイル: gui_curses.py プロジェクト: aseba/TNT
 def _commitBuffer(self,window):
     write_buffer = self._getPromptText(window)
     cdo(self._drawWindow)
     cdo(self._moveToOrigin)
コード例 #5
0
ファイル: gui_curses.py プロジェクト: aseba/TNT
 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)