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

void org::gjt::sp::jedit::textarea::TextArea::goToPrevCharacter ( boolean  select  )  [inline]

Moves the caret to the previous character.

Parameters:
select true if you want to extend selection
Since:
jEdit 2.7pre2.

Definition at line 2651 of file TextArea.java.

References extendSelection(), getLineEndOffset(), getLineStartOffset(), org::gjt::sp::jedit::textarea::DisplayManager::getPrevVisibleLine(), getSelectionAtOffset(), moveCaretPosition(), multi, selectNone(), setCaretPosition(), and org::gjt::sp::jedit::textarea::Selection::start.

      {
            Selection s = getSelectionAtOffset(caret);

            if(caret == 0)
            {
                  getToolkit().beep();
                  return;
            }

            if(!select && s instanceof Selection.Range)
            {
                  if(multi)
                  {
                        if(caret != s.start)
                        {
                              moveCaretPosition(s.start);
                              return;
                        }
                  }
                  else
                  {
                        setCaretPosition(s.start);
                        return;
                  }
            }

            int extraStartVirt = 0;
            int extraEndVirt = 0;
            int newCaret = caret;

            if(select && caret == getLineEndOffset(caretLine) - 1)
            {
                  if(s instanceof Selection.Rect)
                  {
                        extraStartVirt = ((Selection.Rect)s).extraStartVirt;
                        extraEndVirt = ((Selection.Rect)s).extraEndVirt;
                        if(caret == s.start)
                        {
                              if(extraStartVirt == 0)
                                    newCaret = caret - 1;
                              else
                                    extraStartVirt--;
                        }
                        else
                        {
                              if(extraEndVirt == 0)
                                    newCaret = caret - 1;
                              else
                                    extraEndVirt--;
                        }
                  }
                  else
                        newCaret = caret - 1;
            }
            else if(caret == getLineStartOffset(caretLine))
            {
                  int line = displayManager.getPrevVisibleLine(caretLine);
                  if(line == -1)
                  {
                        getToolkit().beep();
                        return;
                  }
                  newCaret = getLineEndOffset(line) - 1;
            }
            else
                  newCaret = caret - 1;

            if(select)
                  extendSelection(caret,newCaret,extraStartVirt,extraEndVirt);
            else if(!multi)
                  selectNone();
            moveCaretPosition(newCaret);
      } //}}}


Generated by  Doxygen 1.6.0   Back to index