Esempio n. 1
0
 private void addNewPuncBlockAfter(TextBlock bpr, char c) {
   PunctuationBlock wb = new PunctuationBlock();
   wb.setText("" + c);
   Block bnx = bpr.next();
   bpr.setNext(wb);
   wb.setNext(bnx);
   caretBlock = wb;
   caretPos = 1;
 }
Esempio n. 2
0
  private void insertLetterBeforeNonWord(TextBlock tb, char c) {
    TextBlock bpr = tb.previousTextBlock();
    if (bpr instanceof WordBlock) {
      insertLetterInWord(bpr, c, bpr.textLength());

    } else {
      addNewWordBlockAfter(bpr, c);
    }
  }
Esempio n. 3
0
  private void insertPuncBeforeNonPunc(TextBlock tb, char c) {
    TextBlock bpr = tb.previousTextBlock();
    if (bpr instanceof PunctuationBlock) {
      insertPuncInPunc(bpr, c, bpr.textLength());

    } else {
      addNewPuncBlockAfter(bpr, c);
    }
  }
Esempio n. 4
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();
  }
Esempio n. 5
0
 private void insertPuncInNonPunc(TextBlock tb, char c, int cp) {
   PunctuationBlock wb = new PunctuationBlock();
   wb.setText("" + c);
   tb.insert(wb, cp);
   caretBlock = wb;
   caretPos = 1;
 }
Esempio n. 6
0
 private void insertLetterInNonWord(TextBlock tb, char c, int cp) {
   WordBlock wb = new WordBlock();
   wb.setText("" + c);
   tb.insert(wb, cp);
   caretBlock = wb;
   caretPos = 1;
 }
Esempio n. 7
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();
  }
Esempio n. 8
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();
  }
Esempio n. 9
0
  private void insertPuncAfterNonPunc(TextBlock tb, char c) {
    TextBlock bnx = tb.nextTextBlock();
    if (bnx instanceof PunctuationBlock) {
      insertPuncInPunc(bnx, c, 0);

    } else {
      addNewPuncBlockAfter(tb, c);
    }
  }
Esempio n. 10
0
  private void insertLetterAfterNonWord(TextBlock tb, char c) {
    TextBlock bnx = tb.nextTextBlock();
    if (bnx instanceof WordBlock) {
      insertLetterInWord(bnx, c, 0);

    } else {
      addNewWordBlockAfter(tb, c);
    }
  }
Esempio n. 11
0
  private void insertPunctuation(char c) {
    if (caretBlock instanceof PunctuationBlock) {
      insertPuncInPunc(caretBlock, c, caretPos);

    } else {
      if (caretPos == 0) {
        insertPuncBeforeNonPunc(caretBlock, c);

      } else if (caretPos == caretBlock.textLength()) {
        insertPuncAfterNonPunc(caretBlock, c);
      } else {
        insertPuncInNonPunc(caretBlock, c, caretPos);
      }
    }
  }
Esempio n. 12
0
  private void insertLetter(char c) {
    if (caretBlock instanceof WordBlock) {
      insertLetterInWord(caretBlock, c, caretPos);

    } else {
      if (caretPos == 0) {
        insertLetterBeforeNonWord(caretBlock, c);

      } else if (caretPos == caretBlock.textLength()) {
        insertLetterAfterNonWord(caretBlock, c);

      } else {
        insertLetterInNonWord(caretBlock, c, caretPos);
      }
    }
  }
Esempio n. 13
0
  private void newline() {
    if (caretPos == 0) {
      TextBlock tbp = caretBlock.previousTextBlock();
      if (tbp != null) {
        tbp.newlineAfter();
      }

    } else if (caretPos == caretBlock.textLength()) {
      caretBlock.newlineAfter();
      caretBlock = caretBlock.nextTextBlock();
      caretPos = 1;

    } else {
      caretBlock.insertNewline(caretPos);
      caretBlock = caretBlock.nextTextBlock();
      caretPos = 1;
    }
  }
Esempio n. 14
0
 private void insertPuncInPunc(TextBlock tb, char c, int cp) {
   tb.insertCharacter(c, cp);
   caretBlock = tb;
   caretPos = cp + 1;
 }
Esempio n. 15
0
 private void insertLetterInWord(TextBlock tb, char c, int cp) {
   tb.insertCharacter(c, cp);
   caretBlock = tb;
   caretPos = cp + 1;
 }