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

void org::gjt::sp::jedit::textarea::TextArea::goToPrevWord ( boolean  select,
boolean  eatWhitespace 
) [inline]

Moves the caret to the start of the previous word.

Since:
jEdit 4.1pre5

Definition at line 2867 of file TextArea.java.

References extendSelection(), org::gjt::sp::jedit::buffer::JEditBuffer::getBooleanProperty(), getLineEndOffset(), getLineStartOffset(), getLineText(), org::gjt::sp::jedit::textarea::DisplayManager::getPrevVisibleLine(), org::gjt::sp::jedit::buffer::JEditBuffer::getStringProperty(), moveCaretPosition(), multi, and selectNone().

      {
            int lineStart = getLineStartOffset(caretLine);
            int newCaret = caret - lineStart;
            String lineText = getLineText(caretLine);

            if(newCaret == 0)
            {
                  if(lineStart == 0)
                  {
                        getToolkit().beep();
                        return;
                  }
                  else
                  {
                        int prevLine = displayManager.getPrevVisibleLine(caretLine);
                        if(prevLine == -1)
                        {
                              getToolkit().beep();
                              return;
                        }

                        newCaret = getLineEndOffset(prevLine) - 1;
                  }
            }
            else
            {
                  String noWordSep = buffer.getStringProperty("noWordSep");
                  boolean camelCasedWords = buffer.getBooleanProperty("camelCasedWords");
                  newCaret = TextUtilities.findWordStart(lineText,
                        newCaret - 1,noWordSep,true,camelCasedWords,eatWhitespace);

                  newCaret += lineStart;
            }

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


Generated by  Doxygen 1.6.0   Back to index