/// <summary> /// Copy a portion of source text into a target SourceText instance /// </summary> /// <param name="target"></param> /// <param name="from">Start offste of the portion</param> /// <param name="to">End offset of the portion</param> public override void Copy(SourceText target, int from, int to) { if (!CheckRange(next, from, to) || target == null) { return; } if (!(target is StringSourceText)) { // convert int s = to - from; char[] buf = new char[s]; Array.Copy(content, from, buf, 0, s); target.ReplaceWithStr(buf, s); return; } StringSourceText ct = (StringSourceText)target; int nSave = to - from; if (ct.size < nSave) { ct.Expand(nSave); } Array.Copy(content, from, ct.content, 0, nSave); ct.next = nSave; }
/// <summary> /// Copy a portion of source text into a target SourceText instance /// </summary> /// <param name="target"></param> /// <param name="from">Start offste of the portion</param> /// <param name="to">End offset of the portion</param> public override void Copy(SourceText target, int from, int to) { if (!CheckRange(length, from, to) || (target == null)) { return; } if (!(target is GapSourceText)) { // convert int s = to - from; char[] buf = new char[s + 1]; CopyTo(buf, 0, from, to); buf[to - from] = '\0'; target.ReplaceWithStr(buf, s); return; } GapSourceText ft = (GapSourceText)target; int nSize = to - from; ft.Empty(); if (ft.size < nSize) { ft.Expand(nSize, 0); } CopyTo(ft.body, 0, from, to); ft.length = to - from; ft.Update(to - from); }