(self, prompt_width)
return start_row, furthest_left, furthest_right
Manage the interactive mode.
Manage the interactive mode.
Manage the interactive mode .
def _interact(self, prompt_width):
        """Manage the interactive mode."""
        # force cursor visibility in all case
        self._cursor.set_override(True)
        self._io_streams.flush()
        try:
            # this is where we started
            start_row = self._text_screen.current_row
            furthest_left = 1 + prompt_width
            # this is where we arrow-keyed on the start line
            furthest_right = self._text_screen.current_col
            while True:
                # get one e-ASCII or dbcs code
                d = self._keyboard.get_fullchar_block()
                if not d:
                    # input stream closed
                    raise error.Exit()
                if d in (
                        ea.UP, ea.CTRL_6, ea.DOWN, ea.CTRL_MINUS,  ea.RIGHT, ea.CTRL_BACKSLASH,
                        ea.LEFT, ea.CTRL_RIGHTBRACKET, ea.HOME, ea.CTRL_k, ea.END, ea.CTRL_n
                    ):
                    # arrow keys drop us out of insert mode
                    self._set_overwrite_mode(True)
                if d == ea.CTRL_c:
                    # CTRL-C -- only caught here, not in wait_char like <CTRL+BREAK>
                    raise error.Break()
                elif d == b'\r':
                    # ENTER, CTRL+M
                    break
                elif d == b'\a':
                    # BEL, CTRL+G
                    self._sound.beep()
                elif d == b'\b':
                    # BACKSPACE, CTRL+H
                    self._text_screen.backspace(start_row, furthest_left)
                elif d == b'\t':
                    # TAB, CTRL+I
                    self._text_screen.tab(self._overwrite_mode)
                elif d == b'\n':
                    # CTRL+ENTER, CTRL+J
                    self._text_screen.line_feed()
                elif d == ea.ESCAPE:
                    # ESC, CTRL+[
                    self._text_screen.clear_line(
                        self._text_screen.current_row, furthest_left
                    )
                elif d in (ea.CTRL_END, ea.CTRL_e):
                    self._text_screen.clear_from(
                        self._text_screen.current_row, self._text_screen.current_col
                    )
                elif d in (ea.UP, ea.CTRL_6):
                    self._text_screen.up()
                elif d in (ea.DOWN, ea.CTRL_MINUS):
                    self._text_screen.down()
                elif d in (ea.RIGHT, ea.CTRL_BACKSLASH):
                    self._text_screen.incr_pos()
                elif d in (ea.LEFT, ea.CTRL_RIGHTBRACKET):
                    self._text_screen.decr_pos()
                elif d in (ea.CTRL_RIGHT, ea.CTRL_f):
                    self._text_screen.skip_word_right()
                elif d in (ea.CTRL_LEFT, ea.CTRL_b):
                    self._text_screen.skip_word_left()
                elif d in (ea.INSERT, ea.CTRL_r):
                    self._set_overwrite_mode(not self._overwrite_mode)
                elif d in (ea.DELETE, ea.CTRL_BACKSPACE):
                    self._text_screen.delete_fullchar()
                elif d in (ea.HOME, ea.CTRL_k):
                    self._text_screen.set_pos(1, 1)
                elif d in (ea.END, ea.CTRL_n):
                    self._text_screen.move_to_end()
                elif d in (ea.CTRL_HOME, ea.CTRL_l):
                    self._text_screen.clear_view()
                elif d == ea.CTRL_PRINT:
                    # ctrl+printscreen toggles printer copy
                    self._io_streams.toggle_echo(self._lpt1_file)
                else:
                    try:
                        # these are done on a less deep level than the fn key macros
                        letters = list(iterchar(ALT_KEY_REPLACE[d])) + [b' ']
                    except KeyError:
                        letters = [d]
                    for d in letters:
                        # ignore eascii by this point, but not dbcs
                        if d[:1] not in (b'\0', b'\r'):
                            if not self._overwrite_mode:
                                self._text_screen.insert_fullchars(d)
                            else:
                                # put all dbcs in before messing with cursor position
                                self._text_screen.write_chars(d, do_scroll_down=True)
                if self._text_screen.current_row == start_row:
                    furthest_left = min(self._text_screen.current_col, furthest_left)
                    furthest_right = max(self._text_screen.current_col, furthest_right)
                    if (
                            self._text_screen.current_col == self._text_screen.mode.width
                            and self._text_screen.overflow
                        ):
                        furthest_right += 1

        finally:
            self._set_overwrite_mode(True)
            # reset cursor visibility
            self._cursor.set_override(False)
        return start_row, furthest_left, furthest_right
def _interact ( self , prompt_width ) : # force cursor visibility in all case self . _cursor . set_override ( True ) self . _io_streams . flush ( ) try : # this is where we started start_row = self . _text_screen . current_row furthest_left = 1 + prompt_width # this is where we arrow-keyed on the start line furthest_right = self . _text_screen . current_col while True : # get one e-ASCII or dbcs code d = self . _keyboard . get_fullchar_block ( ) if not d : # input stream closed raise error . Exit ( ) if d in ( ea . UP , ea . CTRL_6 , ea . DOWN , ea . CTRL_MINUS , ea . RIGHT , ea . CTRL_BACKSLASH , ea . LEFT , ea . CTRL_RIGHTBRACKET , ea . HOME , ea . CTRL_k , ea . END , ea . CTRL_n ) : # arrow keys drop us out of insert mode self . _set_overwrite_mode ( True ) if d == ea . CTRL_c : # CTRL-C -- only caught here, not in wait_char like <CTRL+BREAK> raise error . Break ( ) elif d == b'\r' : # ENTER, CTRL+M break elif d == b'\a' : # BEL, CTRL+G self . _sound . beep ( ) elif d == b'\b' : # BACKSPACE, CTRL+H self . _text_screen . backspace ( start_row , furthest_left ) elif d == b'\t' : # TAB, CTRL+I self . _text_screen . tab ( self . _overwrite_mode ) elif d == b'\n' : # CTRL+ENTER, CTRL+J self . _text_screen . line_feed ( ) elif d == ea . ESCAPE : # ESC, CTRL+[ self . _text_screen . clear_line ( self . _text_screen . current_row , furthest_left ) elif d in ( ea . CTRL_END , ea . CTRL_e ) : self . _text_screen . clear_from ( self . _text_screen . current_row , self . _text_screen . current_col ) elif d in ( ea . UP , ea . CTRL_6 ) : self . _text_screen . up ( ) elif d in ( ea . DOWN , ea . CTRL_MINUS ) : self . _text_screen . down ( ) elif d in ( ea . RIGHT , ea . CTRL_BACKSLASH ) : self . _text_screen . incr_pos ( ) elif d in ( ea . LEFT , ea . CTRL_RIGHTBRACKET ) : self . _text_screen . decr_pos ( ) elif d in ( ea . CTRL_RIGHT , ea . CTRL_f ) : self . _text_screen . skip_word_right ( ) elif d in ( ea . CTRL_LEFT , ea . CTRL_b ) : self . _text_screen . skip_word_left ( ) elif d in ( ea . INSERT , ea . CTRL_r ) : self . _set_overwrite_mode ( not self . _overwrite_mode ) elif d in ( ea . DELETE , ea . CTRL_BACKSPACE ) : self . _text_screen . delete_fullchar ( ) elif d in ( ea . HOME , ea . CTRL_k ) : self . _text_screen . set_pos ( 1 , 1 ) elif d in ( ea . END , ea . CTRL_n ) : self . _text_screen . move_to_end ( ) elif d in ( ea . CTRL_HOME , ea . CTRL_l ) : self . _text_screen . clear_view ( ) elif d == ea . CTRL_PRINT : # ctrl+printscreen toggles printer copy self . _io_streams . toggle_echo ( self . _lpt1_file ) else : try : # these are done on a less deep level than the fn key macros letters = list ( iterchar ( ALT_KEY_REPLACE [ d ] ) ) + [ b' ' ] except KeyError : letters = [ d ] for d in letters : # ignore eascii by this point, but not dbcs if d [ : 1 ] not in ( b'\0' , b'\r' ) : if not self . _overwrite_mode : self . _text_screen . insert_fullchars ( d ) else : # put all dbcs in before messing with cursor position self . _text_screen . write_chars ( d , do_scroll_down = True ) if self . _text_screen . current_row == start_row : furthest_left = min ( self . _text_screen . current_col , furthest_left ) furthest_right = max ( self . _text_screen . current_col , furthest_right ) if ( self . _text_screen . current_col == self . _text_screen . mode . width and self . _text_screen . overflow ) : furthest_right += 1 finally : self . _set_overwrite_mode ( True ) # reset cursor visibility self . _cursor . set_override ( False ) return start_row , furthest_left , furthest_right