Example #1
0
  public void deletBackwards() {
    if (caretPos == 0) {
      TextBlock tb = caretBlock.previousTextBlock();
      if (tb == null) {
        return;

      } else {
        caretBlock = tb;
        caretPos = caretBlock.textLength();
      }
    }

    if (caretBlock.textLength() == 1) {
      TextBlock tb = caretBlock.previousTextBlock();
      int newPos = tb.textLength();
      caretBlock.remove();
      if (tb == null) {
        caretBlock = textBoard.firstTextBlock();
        caretPos = 0;
      } else {
        caretBlock = tb;
        caretPos = newPos;
      }

    } else {
      caretBlock.deleteCharBefore(caretPos);
      caretPos -= 1;
    }

    textBoard.repaint();
  }
Example #2
0
  public void insertCharacter(char c) {
    String s = "" + c;
    if (Character.isLetter(c)) {
      insertLetter(c);
      textBoard.repaint();

    } else if (TextBoard.PUNCTUATION.indexOf(s) >= 0) {
      insertPunctuation(c);
      textBoard.repaint();

    } else {
      // E.info("ignoring funny character " + s);
    }
  }
Example #3
0
  public void caretRight() {
    if (caretBlock == null) {
      return;
    }
    if (caretPos < caretBlock.textLength()) {
      caretPos += 1;
    } else {
      TextBlock tb = caretBlock.nextTextBlock();
      if (tb == null) {

      } else {
        caretBlock = tb;
        caretPos = 1;
      }
    }
    textBoard.repaint();
  }
Example #4
0
  public void caretLeft() {
    if (caretBlock == null) {
      return;
    }
    if (caretPos > 0) {
      caretPos -= 1;
    } else {
      TextBlock tb = caretBlock.previousTextBlock();
      if (tb == null) {

      } else {
        caretBlock = tb;
        caretPos = caretBlock.textLength() - 1;
      }
    }

    textBoard.repaint();
  }