sb.Insert (pos_idx, mt2.sb.ToString (from_idx, to_idx - from_idx));
nchars += to - from;
- foreach (MPlist plist in mt2.intervals)
- if (intervals.Find (plist.Key) == null)
- intervals.Push (plist.Key, new MInterval (plist.Key, this));
foreach (MPlist plist in intervals)
{
MPlist p = mt2.intervals.Find (plist.Key);
- MInterval interval;
+ MInterval i;
if (p == null)
- interval = new MInterval (plist.Key, this, to - from);
+ i = new MInterval (plist.Key, this, to - from);
else
- interval = ((MInterval) p.Val).Copy (from, to);
- ((MInterval) plist.Val).Insert (pos, interval);
+ i = ((MInterval) p.Val).Copy (this, from, to);
+ ((MInterval) plist.Val).Insert (pos, i);
}
+ foreach (MPlist plist in mt2.intervals)
+ if (intervals.Find (plist.Key) == null)
+ {
+ MInterval i = (((MInterval) plist.Val).Copy (this, from, to));
+ intervals.Push (plist.Key, i);
+ }
}
private void insert (int pos, int c)
MText mt = new MText (sb.ToString ());
foreach (MPlist p in intervals)
- mt.intervals.Add (p.Key, ((MInterval) p.Val).Copy (0, Length));
+ mt.intervals.Add (p.Key, ((MInterval) p.Val).Copy (mt, 0, Length));
return mt;
}
((MInterval) plist.Val).Delete (from, to);
else
intervals = new MPlist ();
+ if (M17N.debug)
+ DumpPropNested ();
return this;
}
public void DumpPropNested ()
{
+ Console.WriteLine ("total length = {0}", Length);
foreach (MPlist p in intervals)
((MInterval) p.Val).DumpNested (true);
}
private MInterval LeftMost
{
get {
+ update_from_to ();
if (Left == null)
return this;
- Left.update_from_to ();
return Left.LeftMost;
}
}
private MInterval RightMost
{
get {
+ update_from_to ();
if (Right == null)
return this;
- Right.update_from_to ();
return Right.RightMost;
}
}
{
MInterval child = this;
for (i = Parent; i != null && i.Left == child;
- child = i, i = i.Parent)
- i.update_from_to ();
+ child = i, i = i.Parent);
}
return i;
}
{
MInterval child = this;
for (i = Parent; i != null && i.Right == child;
- child = i, i = i.Parent)
- i.update_from_to ();
+ child = i, i = i.Parent);
}
return i;
}
return i;
}
- public MInterval Copy (int start, int end)
+ public MInterval Copy (MText mt, int start, int end)
{
MInterval copy, left_copy = null, right_copy = null;
if (start < From)
{
if (end <= From)
- return Left.Copy (start, end);
- left_copy = Left.Copy (start, From);
+ return Left.Copy (mt, start, end);
+ left_copy = Left.Copy (mt, start, From);
}
if (end > To)
{
if (start >= To)
- return Right.Copy (start, end);
- right_copy = Right.Copy (To, end);
+ return Right.Copy (mt, start, end);
+ right_copy = Right.Copy (mt, To, end);
}
copy = new MInterval (Key, null, end - start, Stack);
+ copy.mtext = mt;
remove_properties (MTextProperty.Flag.Sensitive);
if (left_copy != null)
{
{
if (Parent != null)
{
- int len = Length - RightLength;
+ int len = Length - LeftLength;
for (MInterval i = Parent; i != null; i = i.Parent)
i.Length -= len;
}
}
+ if (len == 0)
+ return interval;
Length += len;
To += len;
+ M17N.DebugPrint ("grafted {0} in ", len); DumpOne (false, true);
for (MInterval prev = this, ii = this.Parent; ii != null;
prev = ii, ii = ii.Parent)
{