public MText Dup ()
{
- return (new MText (sb.ToString ()));
+ MText mt = new MText (sb.ToString ());
+
+ foreach (MPlist p in intervals)
+ mt.intervals.Add (p.Key, ((MInterval) p.Val).Copy (0, Length));
+ return mt;
}
public MText Ins (int pos, int c)
Console.WriteLine (")");
}
+ public void DumpPropNested ()
+ {
+ Console.Write ("(");
+ foreach (MPlist p in intervals)
+ ((MInterval) p.Val).DumpNested (true);
+ Console.WriteLine (")");
+ }
+
private class MInterval
{
// position: 0 1 2 3 4 5 6 7
MInterval copy, left_copy = null, right_copy = null;
update_from_to ();
+
if (start < From)
{
if (end <= From)
return Left.Copy (start, end);
left_copy = Left.Copy (start, From);
}
- else if (end > To)
+ if (end > To)
{
if (start >= To)
return Right.Copy (start, end);
copy = new MInterval (Key, null, end - start, Stack);
remove_properties (MTextProperty.Flag.Sensitive);
- copy.Left = left_copy;
- copy.Right = right_copy;
-
+ if (left_copy != null)
+ {
+ copy.Left = left_copy;
+ left_copy.Parent = copy;
+ }
+ if (right_copy != null)
+ {
+ copy.Right = right_copy;
+ right_copy.Parent = copy;
+ }
return copy;
}
public void Dump () { Dump (false); }
-
public void Dump (bool force)
{
if (force || M17N.debug)
Right.Dump (force);
}
}
+
+ public void DumpNested (bool force)
+ {
+ if (force || M17N.debug)
+ {
+ update_from_to ();
+
+ Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To);
+ foreach (MPlist p in Stack)
+ Console.Write (" " + p.Val);
+ if (Left != null)
+ {
+ Console.Write (" left=");
+ Left.DumpNested (force);
+ }
+ if (Right != null)
+ {
+ Console.Write (" right=");
+ Right.DumpNested (force);
+ }
+ Console.Write (")");
+ }
+ }
}
private class MTextEnum : IEnumerator