本文整理汇总了C#中Mono.TextEditor.TextEditorData.ExtendSelectionTo方法的典型用法代码示例。如果您正苦于以下问题:C# Mono.TextEditor.TextEditorData.ExtendSelectionTo方法的具体用法?C# Mono.TextEditor.TextEditorData.ExtendSelectionTo怎么用?C# Mono.TextEditor.TextEditorData.ExtendSelectionTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.TextEditorData
的用法示例。
在下文中一共展示了Mono.TextEditor.TextEditorData.ExtendSelectionTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static TextEditorData Create (string input, bool reverse)
{
TextEditorData data = new Mono.TextEditor.TextEditorData ();
int offset1 = input.IndexOf ('[');
int offset2 = input.IndexOf (']');
var selection = new TextSegment (offset1, offset2 - offset1 - 1);
data.Text = input.Substring (0, offset1) + input.Substring (offset1 + 1, (offset2 - offset1) - 1) + input.Substring (offset2 + 1);
if (reverse) {
data.Caret.Offset = selection.Offset;
data.SelectionAnchor = selection.EndOffset;
data.ExtendSelectionTo (selection.Offset);
} else {
data.Caret.Offset = selection.EndOffset;
data.SelectionAnchor = selection.Offset;
data.ExtendSelectionTo (selection.EndOffset);
}
return data;
}
示例2: TestExtendSelectionTo
public void TestExtendSelectionTo ()
{
TextEditorData data = new Mono.TextEditor.TextEditorData ();
data.Document.Text =
@"123456789
123456789
123456789
123456789
123456789
123456789";
data.SelectionAnchor = 3;
DocumentLine line = data.Document.GetLine (3);
Assert.IsFalse (data.IsSomethingSelected);
data.ExtendSelectionTo (line.Offset + 3);
Assert.IsTrue (data.IsSomethingSelected);
Assert.AreEqual (3, data.SelectionRange.Offset);
Assert.AreEqual (line.Offset + 3, data.SelectionRange.EndOffset);
}