public class Test
{
- public static void Main()
+ static void symbol_test ()
{
MSymbol sym1, sym2;
+ Console.WriteLine ("### Symbol test ###");
sym1 = new MSymbol ("abc");
Console.WriteLine (sym1.ToString ());
sym2 = new MSymbol ("abc");
Console.WriteLine (pp.ToString ());
Console.WriteLine (p.get (MSymbol.t));
}
+
+ static void mtext_test ()
+ {
+ MText mt;
+
+ Console.WriteLine ("### MText test ###");
+ mt = new MText ("abc");
+ Console.WriteLine (mt);
+ Console.WriteLine (mt + new MText ("def"));
+ Console.WriteLine (mt);
+ }
+
+ static void mtext_property_test ()
+ {
+ Console.WriteLine ("### MTextProperty test ###");
+ }
+
+ public static void Main()
+ {
+ symbol_test ();
+ mtext_test ();
+ mtext_property_test ();
+ }
+
}
private int cache_pos;
private int cache_idx;
private MInterval root_interval;
- private bool unmodifiable;
+ private bool read_only;
private static UTF8Encoding utf8 = new UTF8Encoding ();
public static MText operator+ (MText mt1, MText mt2)
{
- MText mt = new MText (mt1.sb);
+ MText mt = new MText (mt1.sb.ToString);
mt.sb.Append (mt2.sb);
mt.nchars = mt1.nchars + mt2.nchars;
return mt;
}
+ public bool ReadOnly { get { return read_only; } }
+
public override string ToString ()
{
return sb.ToString ();
return this;
}
+ public void PushProp (int from, int to, MTextProperty prop)
+ {
+ if (root_interval == null)
+ root_interval = new MInterval (0, true, sb.Length, true);
+ root_interval.Push (from, to, prop);
+ }
+
private class MInterval
{
// Start and end positions of this interval and its children.
}
}
- public void Push (MTextProperty prop, int start, int end)
+ public void Push (int start, int end, MTextProperty prop)
{
start <<= 2;
if (prop.FrontSticky)
if (start >= end)
throw new Exception ("Invalid Text Property Range");
- push (prop, start, end);
+ push (start, end, prop);
}
private MInterval divide_right (int pos)
return interval;
}
- private void push (MTextProperty prop, int start, int end)
+ private void push (int start, int end, MTextProperty prop)
{
int this_start = Start;
int this_end = End;
if (start < this_start)
{
if (end <= this_start)
- Left.push (prop, start, end);
- else
{
- Left.push (prop, start, this_start);
- if (end < this_end)
- {
- divide_right (end);
- stack.Push (prop);
- }
- else
- {
- stack.Push (prop);
- if (this_end < end)
- Right.Push (prop, this_end, end);
- }
+ Left.push (start, end, prop);
+ return;
}
+ Left.push (start, this_start, prop);
+ start = this_start;
}
- else if (start < this_end)
+ if (this_end < end)
{
- divide_right (start).Push (prop, start, end);
+ if (this_end < start)
+ {
+ Right.push (start, end, prop);
+ return;
+ }
+ Right.push (this_end, end, prop);
+ end = this_end;
}
- else
- Right.Push (prop, start, end);
+ if (this_start < start)
+ divide_left (start);
+ if (end < this_end)
+ divide_right (end);
+ stack.Push (prop);
}
}
}