intervals = new MPlist ();
}
+ public MText (byte[] str, int offset, int length)
+ {
+ sb = new StringBuilder (utf8.GetString (str, offset, length));
+ nchars = count_chars (sb);
+ intervals = new MPlist ();
+ }
+
public MText (String str)
{
sb = new StringBuilder (str);
intervals.Push (prop.key, root);
}
else
- root = (MInterval) p.Val;
-
- if (root.isSensitive)
- root.PopSensitive (from, to);
+ {
+ root = (MInterval) p.Val;
+ if (root.isSensitive)
+ {
+ root.PopSensitive (from, to);
+ root.MergeAfterChange (from, to);
+ root = (MInterval) p.Val;
+ if (M17n.debug)
+ DumpPropNested ();
+ }
+ }
root.Push (from, to, prop);
root.MergeAfterChange (from, to);
root.Balance ();
MInterval head = find_head (start);
MInterval tail = find_tail (end);
+ M17n.DebugPrint ("Copying: {0}", copy);
+
if (! head.Stack.IsEmpty
&& (isSensitive && head.From < start
- || isFrontSensitive && ! first))
+ || (isFrontSensitive && ! first)))
{
+ M17n.DebugPrint (" clear head");
head = copy.find_head (0);
head.Stack.Clear ();
}
if (! tail.Stack.IsEmpty
- && (isSensitive && end < head.To
- || isRearSensitive && ! last))
+ && (isSensitive && end < tail.To
+ || (isRearSensitive && ! last)))
{
+ M17n.DebugPrint (" clear tail");
tail = copy.find_tail (copy.Length);
tail.Stack.Clear ();
}
- M17n.DebugPrint ("Copied: {0}\n", copy);
+ M17n.DebugPrint ("\n");
return copy;
}
interval = interval.Copy (mtext, start, end,
front_grafted,
(rear_grafted
- || (next == null && end < interval.mtext.Length)));
+ || (next == null && end == interval.mtext.Length)));
else
interval = new MInterval (Key, mtext, end - start, null);
update_from_to ();
MInterval head = find_head (start);
MInterval tail = find_tail (end);
- while (! head.Stack.IsEmpty && head.From > 0)
- {
- MInterval prev = head.Prev;
-
- if (prev.Stack.IsEmpty || head.Stack.Val != prev.Stack.Val)
- break;
- head = head.Prev;
- }
- while (! tail.Stack.IsEmpty && tail.To < mtext.Length)
- {
- MInterval next = tail.Next;
-
- if (next.Stack.IsEmpty || tail.Stack.Val != next.Stack.Val)
- break;
- tail = tail.Next;
- }
Pop (head.From, tail.To);
}