Ejemplo n.º 1
0
 def _interact(self):
     old_handler = register_onresize(self._onresize)
     try:
         for ch in term.wait_for_keypresses(0.5):
             if not ch:
                 # Signal handler could have invalidated interactive mode
                 # of the widget -- in which case we need to stop rendering
                 if not self._interactive:
                     break
                 else:
                     continue
             uch = ch.name if ch.is_sequence else ch.upper()
             if self._jump_string is None:
                 if uch == "Q" or uch == "KEY_ESCAPE": break
                 if uch in DataFrameWidget._MOVES:
                     DataFrameWidget._MOVES[uch](self)
             else:
                 if uch in {"Q", "KEY_ESCAPE", "KEY_ENTER"}:
                     self._jump_string = None
                     self._draw()
                 elif uch == "KEY_DELETE" or uch == "KEY_BACKSPACE":
                     self._jump_to(self._jump_string[:-1])
                 elif uch in "0123456789:":
                     self._jump_to(self._jump_string + uch)
     except KeyboardInterrupt:
         pass
     register_onresize(old_handler)
     # Clear the interactive prompt
     if self._show_navbar:
         term.clear_line(end="\n")
Ejemplo n.º 2
0
 def render(self):
     self.draw()
     if not self._interactive:
         return
     old_handler = register_onresize(self._onresize)
     try:
         for ch in datatable.utils.terminal.wait_for_keypresses(0.5):
             if not ch:
                 # Signal handler could have invalidated interactive mode
                 # of the widget -- in which case we need to stop rendering
                 if not self._interactive:
                     break
                 else:
                     continue
             uch = ch.name if ch.is_sequence else ch.upper()
             if self._jump_string is None:
                 if uch == "Q" or uch == "KEY_ESCAPE": break
                 if uch in DataFrameWidget._MOVES:
                     DataFrameWidget._MOVES[uch](self)
             else:
                 if uch in {"Q", "KEY_ESCAPE", "KEY_ENTER"}:
                     self._jump_string = None
                     self.draw()
                 elif uch == "KEY_DELETE" or uch == "KEY_BACKSPACE":
                     self._jump_to(self._jump_string[:-1])
                 elif uch in "0123456789:":
                     self._jump_to(self._jump_string + uch)
     except KeyboardInterrupt:
         pass
     register_onresize(old_handler)
     print(term.move_x(0) + term.clear_eol)