

def sendkeyevent(self, keyEvent):
    'Interpret the character that the pygame.event.Event object passed as keyEvent represents, and perform the associated action. These actions could be adding another character to the buffer, or manipulating the cursor position (such as when the arrow keys are pressed).'
    if self.done:
        return
    char = interpretkeyevent(keyEvent)
    if ((char in ('\r', '\n')) and (keyEvent.type == KEYUP)):
        self.done = True
        self.parent.input_history.insert(0, self.buffer)
        self.pygsurf.inputcursormode = None
        (x, y) = self.pygsurf.getnthcellfrom(self.startx, self.starty, self.cursor)
        self.pygsurf.write('\n')
        self.pygsurf._repaintcell(x, y)
    elif ((char not in ('\r', '\n')) and (keyEvent.type == KEYDOWN)):
        if ((char is None) and (keyEvent.key in self.KEYMAPPING)):
            self.KEYMAPPING[keyEvent.key]()
        elif (char is not None):
            if (((self.whitelistchars is not None) and (char not in self.whitelistchars)) or ((self.blacklistchars is not None) and (char in self.blacklistchars))):
                return
            if (char == '\t'):
                char = ' '
            if (((not self.insertMode) and (len(self.buffer) < self._maxlength)) or (self.insertMode and (self.cursor == len(self.buffer)))):
                self.buffer.insert(self.cursor, char)
                self.cursor += 1
            elif (len(self.buffer) < self._maxlength):
                self.buffer[self.cursor] = char
                self.cursor += 1
    self.pygsurf.inputcursor = self.pygsurf.getnthcellfrom(self.startx, self.starty, self.cursor)
    self.pygsurf.inputcursor = ((self.pygsurf.inputcursor[0] + len(self.prompt)), self.pygsurf.inputcursor[1])

dataset/ETHPy150Open asweigart/pygcurse/pygcurse/__init__.py PygcurseInput.sendkeyevent/original