From: handa Date: Mon, 20 Apr 2009 07:48:10 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=8dfc2ab1c681a4ba3929d91984967536fa3cbd60;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MText.cs b/MText.cs index 54b3f20..b7f273e 100644 --- a/MText.cs +++ b/MText.cs @@ -330,7 +330,11 @@ namespace M17N.Core 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) @@ -472,6 +476,14 @@ namespace M17N.Core 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 @@ -746,13 +758,14 @@ namespace M17N.Core 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); @@ -761,9 +774,16 @@ namespace M17N.Core 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; } @@ -1314,7 +1334,6 @@ namespace M17N.Core public void Dump () { Dump (false); } - public void Dump (bool force) { if (force || M17N.debug) @@ -1330,6 +1349,29 @@ namespace M17N.Core 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