示例#1
0
 /**
  * Ensures that the <code>lineInfo</code> array can contain the specified index. This enlarges it
  * if necessary. No action is taken if the array is large enough already.
  *
  * <p>It should be unnecessary to call this under normal circumstances; <code>insertLine()</code>
  * should take care of enlarging the line info array automatically.
  *
  * @param index The array index
  */
 protected void ensureCapacity(int index) {
   if (lineInfo == null) lineInfo = new LineInfo[index + 1];
   else if (lineInfo.length <= index) {
     LineInfo[] lineInfoN = new LineInfo[(index + 1) * 2];
     System.arraycopy(lineInfo, 0, lineInfoN, 0, lineInfo.length);
     lineInfo = lineInfoN;
   }
 }
示例#2
0
  /**
   * Informs the token marker that lines have been inserted into the document. This inserts a gap in
   * the <code>lineInfo</code> array.
   *
   * @param index The first line number
   * @param lines The number of lines
   */
  public void insertLines(int index, int lines) {
    if (lines <= 0) return;
    length += lines;
    ensureCapacity(length);
    int len = index + lines;
    System.arraycopy(lineInfo, index, lineInfo, len, lineInfo.length - len);

    for (int i = index + lines - 1; i >= index; i--) {
      lineInfo[i] = new LineInfo();
    }
  }
示例#3
0
 /**
  * Informs the token marker that line have been deleted from the document. This removes the lines
  * in question from the <code>lineInfo</code> array.
  *
  * @param index The first line number
  * @param lines The number of lines
  */
 public void deleteLines(int index, int lines) {
   if (lines <= 0) return;
   int len = index + lines;
   length -= lines;
   System.arraycopy(lineInfo, len, lineInfo, index, lineInfo.length - len);
 }