| 2581 | }; |
| 2582 | // Utility used by replace and split above |
| 2583 | function copyStyles(from, to, source, dest) { |
| 2584 | for (var i = 0, pos = 0, state = 0; pos < to; i+=2) { |
| 2585 | var part = source[i], end = pos + part.length; |
| 2586 | if (state == 0) { |
| 2587 | if (end > from) dest.push(part.slice(from - pos, Math.min(part.length, to - pos)), source[i+1]); |
| 2588 | if (end >= from) state = 1; |
| 2589 | } |
| 2590 | else if (state == 1) { |
| 2591 | if (end > to) dest.push(part.slice(0, to - pos), source[i+1]); |
| 2592 | else dest.push(part, source[i+1]); |
| 2593 | } |
| 2594 | pos = end; |
| 2595 | } |
| 2596 | } |
| 2597 | |
| 2598 | // Data structure that holds the sequence of lines. |
| 2599 | function LeafChunk(lines) { |