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

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

Moves the caret to the next character.

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

Definition at line 2351 of file TextArea.java.

References org::gjt::sp::jedit::textarea::Selection::end, extendSelection(), org::gjt::sp::jedit::buffer::JEditBuffer::getLength(), getLineEndOffset(), getLineStartOffset(), org::gjt::sp::jedit::textarea::DisplayManager::getNextVisibleLine(), getSelectionAtOffset(), moveCaretPosition(), multi, selectNone(), setCaretPosition(), and org::gjt::sp::jedit::textarea::Selection::start.

      {
            Selection s = getSelectionAtOffset(caret);

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

            int extraStartVirt, extraEndVirt;
            if(s instanceof Selection.Rect)
            {
                  extraStartVirt = ((Selection.Rect)s).extraStartVirt;
                  extraEndVirt = ((Selection.Rect)s).extraEndVirt;
            }
            else
            {
                  extraStartVirt = 0;
                  extraEndVirt = 0;
            }

            int newCaret = caret;

            if(caret == buffer.getLength())
            {
                  if(select && (rectangularSelectionMode || s instanceof Selection.Rect))
                  {
                        if(s != null && caret == s.start)
                              extraStartVirt++;
                        else
                              extraEndVirt++;
                  }
                  else
                  {
                        getToolkit().beep();
                        return;
                  }
            }
            else if(caret == getLineEndOffset(caretLine) - 1)
            {
                  if(select && (rectangularSelectionMode || s instanceof Selection.Rect))
                  {
                        if(s != null && caret == s.start)
                              extraStartVirt++;
                        else
                              extraEndVirt++;
                  }
                  else
                  {
                        int line = displayManager.getNextVisibleLine(caretLine);
                        if(line == -1)
                        {
                              getToolkit().beep();
                              return;
                        }
                        else
                              newCaret = getLineStartOffset(line);
                  }
            }
            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