Пример #1
0
  public UndoableEdit insertString(int where, String str, boolean beforeMarkers)
      throws BadLocationException {
    CharBuffer b = buffer;
    if (where < 0 || where > b.length()) throw new BadLocationException("bad insert", where);
    b.insert(where, str, beforeMarkers);

    GapUndoableEdit undo = new GapUndoableEdit(where);
    undo.content = this;
    undo.data = str;
    undo.nitems = str.length();
    undo.isInsertion = true;
    return undo;
  }
Пример #2
0
  public UndoableEdit remove(int where, int nitems) throws BadLocationException {
    CharBuffer b = buffer;
    if (nitems < 0 || where < 0 || where + nitems > b.length())
      throw new BadLocationException("invalid remove", where);

    b.delete(where, nitems);

    GapUndoableEdit undo = new GapUndoableEdit(where);
    undo.content = this;
    undo.data = new String(b.getArray(), b.gapEnd - nitems, nitems);
    undo.nitems = nitems;
    undo.isInsertion = false;
    return undo;
  }