Exemplo n.º 1
0
  public void deleteNextChar() throws DocumentValidationException {
    if (this.hasSelection()) {
      this.deleteSelection();
    } else {
      int offset = this.getCaretOffset();
      VEXDocument doc = this.getDocument();
      int n = doc.getLength() - 1;
      VEXElement element = doc.getElementAt(offset);

      if (offset == n) {
        // nop
      } else if (this.isBetweenMatchingElements(offset)) {
        this.joinElementsAt(offset);
      } else if (this.isBetweenMatchingElements(offset + 1)) {
        this.joinElementsAt(offset + 1);
      } else if (element.isEmpty()) {
        // deleting the right sentinel of an empty element
        // so just delete the whole element an move on
        this.moveTo(offset - 1, false);
        this.moveTo(offset + 1, true);
        this.deleteSelection();
      } else if (doc.getElementAt(offset + 1).isEmpty()) {
        // deleting the left sentinel of an empty element
        // so just delete the whole element an move on
        this.moveTo(offset + 2, true);
        this.deleteSelection();
      } else {
        if (doc.getCharacterAt(offset) != 0) {
          this.moveTo(offset, false);
          this.moveTo(offset + 1, true);
          this.deleteSelection();
        }
      }
    }
  }
Exemplo n.º 2
0
  public void moveToNextWord(boolean select) {
    VEXDocument doc = this.getDocument();
    int n = doc.getLength() - 1;
    int offset = this.getCaretOffset();
    while (offset < n && !Character.isLetterOrDigit(doc.getCharacterAt(offset))) {
      offset++;
    }

    while (offset < n && Character.isLetterOrDigit(doc.getCharacterAt(offset))) {
      offset++;
    }

    this.moveTo(offset, select);
  }
Exemplo n.º 3
0
  public void selectWord() {
    VEXDocument doc = this.getDocument();
    int startOffset = this.getCaretOffset();
    int endOffset = this.getCaretOffset();
    while (startOffset > 1 && Character.isLetterOrDigit(doc.getCharacterAt(startOffset - 1))) {
      startOffset--;
    }
    int n = doc.getLength() - 1;
    while (endOffset < n && Character.isLetterOrDigit(doc.getCharacterAt(endOffset))) {
      endOffset++;
    }

    if (startOffset < endOffset) {
      this.moveTo(startOffset, false);
      this.moveTo(endOffset, true);
    }
  }