def readline(self, echo=None, prompt='<STR_LIT>', use_history=True):
line = []<EOL>insptr = <NUM_LIT:0><EOL>ansi = <NUM_LIT:0><EOL>histptr = len(self.history)<EOL>if self.DOECHO:<EOL><INDENT>self.write(prompt)<EOL>self._current_prompt = prompt<EOL><DEDENT>else:<EOL><INDENT>self._current_prompt = '<STR_LIT>'<EOL><DEDENT>self._current_line = '<STR_LIT>'<EOL>while True:<EOL><INDENT>c = self.getc(block=True)<EOL>c = self.ansi_to_curses(c)<EOL>if c == theNULL:<EOL><INDENT>continue<EOL><DEDENT>elif c == curses.KEY_LEFT:<EOL><INDENT>if insptr > <NUM_LIT:0>:<EOL><INDENT>insptr = insptr - <NUM_LIT:1><EOL>self._readline_echo(self.CODES['<STR_LIT>'], echo)<EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL><DEDENT>continue<EOL><DEDENT>elif c == curses.KEY_RIGHT:<EOL><INDENT>if insptr < len(line):<EOL><INDENT>insptr = insptr + <NUM_LIT:1><EOL>self._readline_echo(self.CODES['<STR_LIT>'], echo)<EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL><DEDENT>continue<EOL><DEDENT>elif c == curses.KEY_UP or c == curses.KEY_DOWN:<EOL><INDENT>if not use_history:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL>continue<EOL><DEDENT>if c == curses.KEY_UP:<EOL><INDENT>if histptr > <NUM_LIT:0>:<EOL><INDENT>histptr = histptr - <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL>continue<EOL><DEDENT><DEDENT>elif c == curses.KEY_DOWN:<EOL><INDENT>if histptr < len(self.history):<EOL><INDENT>histptr = histptr + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL>continue<EOL><DEDENT><DEDENT>line = []<EOL>if histptr < len(self.history):<EOL><INDENT>line.extend(self.history[histptr])<EOL><DEDENT>for char in range(insptr):<EOL><INDENT>self._readline_echo(self.CODES['<STR_LIT>'], echo)<EOL><DEDENT>self._readline_echo(self.CODES['<STR_LIT>'], echo)<EOL>self._readline_echo('<STR_LIT>'.join(line), echo)<EOL>insptr = len(line)<EOL>continue<EOL><DEDENT>elif c == chr(<NUM_LIT:3>):<EOL><INDENT>self._readline_echo('<STR_LIT:\n>' + curses.ascii.unctrl(c) + '<STR_LIT>', echo)<EOL>return '<STR_LIT>'<EOL><DEDENT>elif c == chr(<NUM_LIT:4>):<EOL><INDENT>if len(line) > <NUM_LIT:0>:<EOL><INDENT>self._readline_echo('<STR_LIT:\n>' + curses.ascii.unctrl(c) + '<STR_LIT>', echo)<EOL>return '<STR_LIT>'<EOL><DEDENT>self._readline_echo('<STR_LIT:\n>' + curses.ascii.unctrl(c) + '<STR_LIT>', echo)<EOL>return '<STR_LIT>'<EOL><DEDENT>elif c == chr(<NUM_LIT:10>):<EOL><INDENT>self._readline_echo(c, echo)<EOL>result = '<STR_LIT>'.join(line)<EOL>if use_history:<EOL><INDENT>self.history.append(result)<EOL><DEDENT>if echo is False:<EOL><INDENT>if prompt:<EOL><INDENT>self.write( chr(<NUM_LIT:10>) )<EOL><DEDENT>log.debug('<STR_LIT>', prompt)<EOL><DEDENT>else:<EOL><INDENT>log.debug('<STR_LIT>', prompt, result)<EOL><DEDENT>return result<EOL><DEDENT>elif c == curses.KEY_BACKSPACE or c == chr(<NUM_LIT>) or c == chr(<NUM_LIT:8>):<EOL><INDENT>if insptr > <NUM_LIT:0>:<EOL><INDENT>self._readline_echo(self.CODES['<STR_LIT>'] + self.CODES['<STR_LIT>'], echo)<EOL>insptr = insptr - <NUM_LIT:1><EOL>del line[insptr]<EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL><DEDENT>continue<EOL><DEDENT>elif c == curses.KEY_DC:<EOL><INDENT>if insptr < len(line):<EOL><INDENT>self._readline_echo(self.CODES['<STR_LIT>'], echo)<EOL>del line[insptr]<EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(BELL, echo)<EOL><DEDENT>continue<EOL><DEDENT>else:<EOL><INDENT>if ord(c) < <NUM_LIT:32>:<EOL><INDENT>c = curses.ascii.unctrl(c)<EOL><DEDENT>if len(line) > insptr:<EOL><INDENT>self._readline_insert(c, echo, insptr, line)<EOL><DEDENT>else:<EOL><INDENT>self._readline_echo(c, echo)<EOL><DEDENT><DEDENT>line[insptr:insptr] = c<EOL>insptr = insptr + len(c)<EOL>if self._readline_do_echo(echo):<EOL><INDENT>self._current_line = line<EOL><DEDENT><DEDENT>
Return a line of text, including the terminating LF
           If echo is true always echo, if echo is false never echo
           If echo is None follow the negotiated setting.
           prompt is the current prompt to write (and rewrite if needed)
           use_history controls if this current line uses (and adds to) the command history.