parameters: (self, x)
docstring: Text box key validator: Callback of key strokes.
  
      Handles a user's keypress in the input text box. Translates certain keys to
      terminator keys for the textbox to allow its edit() method to return.
      Also handles special key-triggered events such as PgUp/PgDown scrolling of
      the screen output.
  
      Args:
        x: (int) Key code.
  
      Returns:
        (int) A translated key code. In most cases, this is identical to the
          input x. However, if x is a Return key, the return value will be
          CLI_TERMINATOR_KEY, so that the text box's edit() method can return.
  
      Raises:
        TypeError: If the input x is not of type int.
        debugger_cli_common.CommandLineExit: If a mouse-triggered command returns
          an exit token when dispatched.
docstring_summary: Text box key validator: Callback of key strokes.
docstring_tokens: Text box key validator : Callback of key strokes .
function: def _on_textbox_keypress(self, x):
      """Text box key validator: Callback of key strokes.
  
      Handles a user's keypress in the input text box. Translates certain keys to
      terminator keys for the textbox to allow its edit() method to return.
      Also handles special key-triggered events such as PgUp/PgDown scrolling of
      the screen output.
  
      Args:
        x: (int) Key code.
  
      Returns:
        (int) A translated key code. In most cases, this is identical to the
          input x. However, if x is a Return key, the return value will be
          CLI_TERMINATOR_KEY, so that the text box's edit() method can return.
  
      Raises:
        TypeError: If the input x is not of type int.
        debugger_cli_common.CommandLineExit: If a mouse-triggered command returns
          an exit token when dispatched.
      """
      if not isinstance(x, int):
        raise TypeError("Key validator expected type int, received type %s" %
                        type(x))
  
      if x in self.CLI_CR_KEYS:
        # Make Enter key the terminator
        self._textbox_curr_terminator = x
        return self.CLI_TERMINATOR_KEY
      elif x == self.CLI_TAB_KEY:
        self._textbox_curr_terminator = self.CLI_TAB_KEY
        return self.CLI_TERMINATOR_KEY
      elif x == curses.KEY_PPAGE:
        self._scroll_output(_SCROLL_UP_A_LINE)
        return x
      elif x == curses.KEY_NPAGE:
        self._scroll_output(_SCROLL_DOWN_A_LINE)
        return x
      elif x == curses.KEY_HOME:
        self._scroll_output(_SCROLL_HOME)
        return x
      elif x == curses.KEY_END:
        self._scroll_output(_SCROLL_END)
        return x
      elif x in [curses.KEY_UP, curses.KEY_DOWN]:
        # Command history navigation.
        if not self._active_command_history:
          hist_prefix = self._screen_gather_textbox_str()
          self._active_command_history = (
              self._command_history_store.lookup_prefix(
                  hist_prefix, self._command_history_limit))
  
        if self._active_command_history:
          if x == curses.KEY_UP:
            if self._command_pointer < len(self._active_command_history):
              self._command_pointer += 1
          elif x == curses.KEY_DOWN:
            if self._command_pointer > 0:
              self._command_pointer -= 1
        else:
          self._command_pointer = 0
  
        self._textbox_curr_terminator = x
  
        # Force return from the textbox edit(), so that the textbox can be
        # redrawn with a history command entered.
        return self.CLI_TERMINATOR_KEY
      elif x == curses.KEY_RESIZE:
        # Respond to terminal resize.
        self._screen_refresh_size()
        self._init_layout()
        self._screen_create_command_window()
        self._redraw_output()
  
        # Force return from the textbox edit(), so that the textbox can be
        # redrawn.
        return self.CLI_TERMINATOR_KEY
      elif x == curses.KEY_MOUSE and self._mouse_enabled:
        try:
          _, mouse_x, mouse_y, _, mouse_event_type = self._screen_getmouse()
        except curses.error:
          mouse_event_type = None
  
        if mouse_event_type == curses.BUTTON1_RELEASED:
          # Logic for mouse-triggered scrolling.
          if mouse_x >= self._max_x - 2:
            scroll_command = self._scroll_bar.get_click_command(mouse_y)
            if scroll_command is not None:
              self._scroll_output(scroll_command)
            return x
          else:
            command = self._fetch_hyperlink_command(mouse_x, mouse_y)
            if command:
              self._screen_create_command_textbox()
              exit_token = self._dispatch_command(command)
              if exit_token is not None:
                raise debugger_cli_common.CommandLineExit(exit_token=exit_token)
      else:
        # Mark the pending command as modified.
        self._textbox_pending_command_changed = True
        # Invalidate active command history.
        self._command_pointer = 0
        self._active_command_history = []
        return self._KEY_MAP.get(x, x)
function_tokens: def _on_textbox_keypress ( self , x ) : if not isinstance ( x , int ) : raise TypeError ( "Key validator expected type int, received type %s" % type ( x ) ) if x in self . CLI_CR_KEYS : # Make Enter key the terminator self . _textbox_curr_terminator = x return self . CLI_TERMINATOR_KEY elif x == self . CLI_TAB_KEY : self . _textbox_curr_terminator = self . CLI_TAB_KEY return self . CLI_TERMINATOR_KEY elif x == curses . KEY_PPAGE : self . _scroll_output ( _SCROLL_UP_A_LINE ) return x elif x == curses . KEY_NPAGE : self . _scroll_output ( _SCROLL_DOWN_A_LINE ) return x elif x == curses . KEY_HOME : self . _scroll_output ( _SCROLL_HOME ) return x elif x == curses . KEY_END : self . _scroll_output ( _SCROLL_END ) return x elif x in [ curses . KEY_UP , curses . KEY_DOWN ] : # Command history navigation. if not self . _active_command_history : hist_prefix = self . _screen_gather_textbox_str ( ) self . _active_command_history = ( self . _command_history_store . lookup_prefix ( hist_prefix , self . _command_history_limit ) ) if self . _active_command_history : if x == curses . KEY_UP : if self . _command_pointer < len ( self . _active_command_history ) : self . _command_pointer += 1 elif x == curses . KEY_DOWN : if self . _command_pointer > 0 : self . _command_pointer -= 1 else : self . _command_pointer = 0 self . _textbox_curr_terminator = x # Force return from the textbox edit(), so that the textbox can be # redrawn with a history command entered. return self . CLI_TERMINATOR_KEY elif x == curses . KEY_RESIZE : # Respond to terminal resize. self . _screen_refresh_size ( ) self . _init_layout ( ) self . _screen_create_command_window ( ) self . _redraw_output ( ) # Force return from the textbox edit(), so that the textbox can be # redrawn. return self . CLI_TERMINATOR_KEY elif x == curses . KEY_MOUSE and self . _mouse_enabled : try : _ , mouse_x , mouse_y , _ , mouse_event_type = self . _screen_getmouse ( ) except curses . error : mouse_event_type = None if mouse_event_type == curses . BUTTON1_RELEASED : # Logic for mouse-triggered scrolling. if mouse_x >= self . _max_x - 2 : scroll_command = self . _scroll_bar . get_click_command ( mouse_y ) if scroll_command is not None : self . _scroll_output ( scroll_command ) return x else : command = self . _fetch_hyperlink_command ( mouse_x , mouse_y ) if command : self . _screen_create_command_textbox ( ) exit_token = self . _dispatch_command ( command ) if exit_token is not None : raise debugger_cli_common . CommandLineExit ( exit_token = exit_token ) else : # Mark the pending command as modified. self . _textbox_pending_command_changed = True # Invalidate active command history. self . _command_pointer = 0 self . _active_command_history = [ ] return self . _KEY_MAP . get ( x , x )