Logo Search packages:      
Sourcecode: ipython version File versions  Download package

def IPython::frontend::wx::console_widget::ConsoleWidget::_keep_cursor_in_buffer (   self,
  pos = None 
) [private]

Checks if the cursor is where it is allowed to be. If not,
    put it back.

    Returns
    -------
    cursor_moved: Boolean
whether or not the cursor was moved by this routine.

    Notes
    ------
WARNING: This does proper checks only for horizontal
movements.

Definition at line 553 of file console_widget.py.

00553                                               :
        """ Checks if the cursor is where it is allowed to be. If not,
            put it back.

            Returns
            -------
            cursor_moved: Boolean
                whether or not the cursor was moved by this routine.

            Notes
            ------
                WARNING: This does proper checks only for horizontal
                movements.
        """
        if pos is None:
            current_pos = self.GetCurrentPos()
        else:
            current_pos = pos
        if  current_pos < self.current_prompt_pos:
            self.GotoPos(self.current_prompt_pos)
            return True
        line_num = self.LineFromPosition(current_pos)
        if not current_pos > self.GetLength():
            line_pos = self.GetColumn(current_pos)
        else:
            line_pos = self.GetColumn(self.GetLength())
        line = self.GetLine(line_num)
        # Jump the continuation prompt
        continuation_prompt = self.continuation_prompt()
        if ( line.startswith(continuation_prompt)
                     and line_pos < len(continuation_prompt)):
            if line_pos < 2:
                # We are at the beginning of the line, trying to move
                # forward: jump forward.
                self.GotoPos(current_pos + 1 +
                                    len(continuation_prompt) - line_pos)
            else:
                # Jump back up
                self.GotoPos(self.GetLineEndPosition(line_num-1))
            return True
        elif ( current_pos > self.GetLineEndPosition(line_num) 
                        and not current_pos == self.GetLength()): 
            # Jump to next line
            self.GotoPos(current_pos + 1 +
                                    len(continuation_prompt))
            return True

        # We re-allow enter event processing
        self.enter_catched = False 
        return False


if __name__ == '__main__':


Generated by  Doxygen 1.6.0   Back to index