private void replaceFromTo(Node node,Node last,String text,int length,int firstLineDelta){
  Node successor=successor(node);
  while (successor != last) {
    length-=successor.length;
    Node toDelete=successor;
    successor=successor(successor);
    updateLength(toDelete,-toDelete.length);
  }
  DelimiterInfo info=text == null ? null : nextDelimiterInfo(text,0);
  if (info == null || info.delimiter == null) {
    int added=text == null ? 0 : text.length();
    join(node,last,added - length);
  }
 else {
    int consumed=info.delimiterIndex + info.delimiterLength;
    updateLength(node,consumed - firstLineDelta);
    node.delimiter=info.delimiter;
    length-=firstLineDelta;
    info=nextDelimiterInfo(text,consumed);
    while (info != null) {
      int lineLen=info.delimiterIndex - consumed + info.delimiterLength;
      node=insertAfter(node,lineLen,info.delimiter);
      consumed+=lineLen;
      info=nextDelimiterInfo(text,consumed);
    }
    updateLength(last,text.length() - consumed - length);
  }
}

private void replaceFromTo ( Node node , Node last , String text , int length , int firstLineDelta ) { Node successor = successor ( node ) ; while ( successor != last ) { length -= successor . length ; Node toDelete = successor ; successor = successor ( successor ) ; updateLength ( toDelete , - toDelete . length ) ; } DelimiterInfo info = text == null ? null : nextDelimiterInfo ( text , 0 ) ; if ( info == null || info . delimiter == null ) { int added = text == null ? 0 : text . length ( ) ; join ( node , last , added - length ) ; } else { int consumed = info . delimiterIndex + info . delimiterLength ; updateLength ( node , consumed - firstLineDelta ) ; node . delimiter = info . delimiter ; length -= firstLineDelta ; info = nextDelimiterInfo ( text , consumed ) ; while ( info != null ) { int lineLen = info . delimiterIndex - consumed + info . delimiterLength ; node = insertAfter ( node , lineLen , info . delimiter ) ; consumed += lineLen ; info = nextDelimiterInfo ( text , consumed ) ; } updateLength ( last , text . length ( ) - consumed - length ) ; } }
replace spanning from one node to another .
