Exemplo n.º 1
0
 public void getChars(int where, int len, Segment txt) throws BadLocationException {
   CharBuffer b = buffer;
   int start = b.getSegment(where, len);
   if (start < 0) throw new BadLocationException("invalid offset", where);
   txt.offset = start;
   txt.array = b.getArray();
   txt.count = len;
 }
Exemplo n.º 2
0
 public SwingContent(int initialSize) {
   CharBuffer b = new CharBuffer(initialSize);
   // Swing assumes that a Content object is initialized to contain
   // a single '\n'.  This of course is not clearly documented ...
   b.gapEnd = initialSize - 1;
   b.getArray()[b.gapEnd] = '\n';
   this.buffer = b;
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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;
  }
Exemplo n.º 5
0
 public javax.swing.text.Position createPosition(int offset) throws BadLocationException {
   CharBuffer b = buffer;
   if (offset < 0 || offset > b.length())
     throw new BadLocationException("bad offset to createPosition", offset);
   return new GapPosition(b, offset);
 }
Exemplo n.º 6
0
 public String getString(int where, int len) throws BadLocationException {
   CharBuffer b = buffer;
   int start = b.getSegment(where, len);
   if (start < 0) throw new BadLocationException("invalid offset", where);
   return new String(b.getArray(), start, len);
 }
Exemplo n.º 7
0
 public int length() {
   return buffer.length();
 }