[Mono-list] Fixes for TextBuffer in gtk GTK#
Daniel Morgan
danmorg@sc.rr.com
Fri, 15 Nov 2002 14:56:51 -0500
Here is some sample implementations for InsertWithTagsByName() and
CreateTag() for TextBuffer in
gtk in gtk#. Is it okay?
// InsertWithTagsByName() should exist in TextBuffer
void InsertWithTagsByName (TextBuffer buffer,
TextIter iter, string text, int len,
string[] TagNames) {
buffer.Insert(iter, text, len);
TextIter endIter;
buffer.GetIterAtOffset(out endIter, len);
buffer.RemoveAllTags(iter, endIter);
for (int t = 0; t < TagNames.Length; t++) {
buffer.ApplyTagByName(tag_name, iter, endIter);
}
}
// CreateTag() should exist in TextBuffer
void BufferCreateTag (TextBuffer buffer,
string TagName, object[] TagProperties) {
TextTagTable textTagTable = buffer.TagTable;
TextTag textTag = new TextTabg(TagName);
for(int p = 0; p < TagProperties.Length; p++) {
// use Base class SetProperty()
// but will need to convert
// System.Object to GLib.Value somehow
// not sure if casting will work
GLib.Value v = (GLib.Value) TagProperties[p,1];
textTag.SetProperty (TagProperties[p,0], v);
textTagTable.Add (textTag);
}
}