Underlying TextBuffer TextView.
, , , ( , ), , TextIter , :
SelectAll:
var start = textview.Buffer.GetIterAtOffset (0);
var end = textview.Buffer.GetIterAtOffset (0);
end.ForwardToEnd ();
textview.Buffer.SelectRange (start, end);
[2,4] :
var start = textview.Buffer.GetIterAtOffset (0);
start.ForwardChars (2);
var end = textview.Buffer.GetIterAtOffset (0);
end.ForwardChars (4);
textview.Buffer.SelectRange (start, end);
TextIter , ForwardChars() BackwardChars().
, TextBuffer - , HasSelection :
var hasSelection = textview.Buffer.HasSelection;
, , Clipboard.
[2,4]:
var clipboard = textview.GetClipboard (Gdk.Selection.Clipboard);
var start = textview.Buffer.GetIterAtOffset (0);
start.ForwardChars (2);
var end = textview.Buffer.GetIterAtOffset (0);
end.ForwardChars (4);
textview.Buffer.SelectRange (start, end);
textview.Buffer.CutClipboard (clipboard, true);
, CutClipboard CopyClipboard:
[2,4]:
var clipboard = textview.GetClipboard (Gdk.Selection.Clipboard);
var start = textview.Buffer.GetIterAtOffset (0);
start.ForwardChars (2);
var end = textview.Buffer.GetIterAtOffset (0);
end.ForwardChars (4);
textview.Buffer.SelectRange (start, end);
textview.Buffer.CopyClipboard (clipboard, true);
, , - /
0:
var pasteLocation=textview.Buffer.GetIterAtOffset (0);
textview.Buffer.SelectRange (pasteLocation, pasteLocation);
textview.Buffer.PasteClipboard (clipboard);
:
123456, 34 , 341256:
void TextViewSample ()
{
textview.Buffer.Text = "123456";
var clipboard = textview.GetClipboard (Gdk.Selection.Clipboard);
var start = textview.Buffer.GetIterAtOffset (0);
start.ForwardChars (2);
var end = textview.Buffer.GetIterAtOffset (0);
end.ForwardChars (4);
textview.Buffer.SelectRange (start, end);
var hasSelection = textview.Buffer.HasSelection;
textview.Buffer.CutClipboard (clipboard, true);
var pasteLocation = textview.Buffer.GetIterAtOffset (0);
textview.Buffer.SelectRange (pasteLocation, pasteLocation);
textview.Buffer.PasteClipboard (clipboard);
}