GtkSharp/gtk/TextBuffer.custom

38 lines
849 B
Text
Raw Normal View History

public string Text {
get {
return GetText (StartIter, EndIter, false);
}
set {
gtk_text_buffer_set_text (Handle, value,
System.Text.Encoding.UTF8.GetByteCount(value));
}
}
public void Clear ()
{
Delete (StartIter, EndIter);
}
// overload to paste clipboard contents at cursor editable by default.
[DllImport("libgtk-win32-2.0-0.dll")]
static extern void gtk_text_buffer_paste_clipboard (IntPtr raw, IntPtr clip, IntPtr iter, bool default_edit);
public void PasteClipboard (Gtk.Clipboard clipboard)
{
gtk_text_buffer_paste_clipboard(Handle, clipboard.Handle, IntPtr.Zero, true);
}
public void InsertWithTags (string text, params TextTag[] tags)
{
TextIter iter;
this.Insert (EndIter, text);
iter = this.GetIterAtOffset (EndIter.Offset - text.Length);
foreach (TextTag t in tags)
{
this.ApplyTag (t, iter, EndIter);
}
}