本文整理汇总了C#中TextEditorData类的典型用法代码示例。如果您正苦于以下问题:C# TextEditorData类的具体用法?C# TextEditorData怎么用?C# TextEditorData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextEditorData类属于命名空间,在下文中一共展示了TextEditorData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static TextEditorData Create (string content)
{
int caretIndex = content.IndexOf ("$");
if (caretIndex >= 0)
content = content.Substring (0, caretIndex) + content.Substring (caretIndex + 1);
int selection1 = content.IndexOf ("<-");
int selection2 = content.IndexOf ("->");
int selectionStart = 0;
int selectionEnd = 0;
if (0 <= selection1 && selection1 < selection2) {
content = content.Substring (0, selection2) + content.Substring (selection2 + 2);
content = content.Substring (0, selection1) + content.Substring (selection1 + 2);
selectionStart = selection1;
selectionEnd = selection2 - 2;
caretIndex = selectionEnd;
}
var data = new TextEditorData ();
data.Text = content;
if (caretIndex >= 0)
data.Caret.Offset = caretIndex;
if (selection1 >= 0) {
if (caretIndex == selectionStart) {
data.SetSelection (selectionEnd, selectionStart);
} else {
data.SetSelection (selectionStart, selectionEnd);
}
}
return data;
}
示例2: CreateData
TextEditorData CreateData ()
{
var data = new TextEditorData ();
data.IndentationTracker = IndentTracker;
data.Options.IndentStyle = IndentStyle.Smart;
return data;
}
示例3: CreateData
TextEditorData CreateData (string content)
{
var data = new TextEditorData (new TextDocument (content));
data.IndentationTracker = IndentTracker;
data.Options.IndentStyle = IndentStyle.Smart;
return data;
}
示例4: CreateData
public static TextEditorData CreateData (string content)
{
var data = new TextEditorData (new TextDocument (content));
data.IndentationTracker = SmartIndentModeTests.IndentTracker;
data.Options.IndentStyle = IndentStyle.Virtual;
return data;
}
示例5: GetMarkup
public static string GetMarkup (string input, string syntaxMode)
{
var data = new TextEditorData (new TextDocument (input));
data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode (data.Document, syntaxMode);
data.ColorStyle = SyntaxModeService.GetColorStyle ("TangoLight");
return data.GetMarkup (0, data.Length, false);
}
示例6: CreateData
TextEditorData CreateData ()
{
var data = new TextEditorData ();
data.IndentationTracker = SmartIndentModeTests.IndentTracker;
data.Options.IndentStyle = IndentStyle.Virtual;
return data;
}
示例7: Join
public static void Join (TextEditorData data)
{
int startLine, endLine, startOffset, length;
if (data.IsSomethingSelected) {
startLine = data.Document.OffsetToLineNumber (data.SelectionRange.Offset);
endLine = data.Document.OffsetToLineNumber (data.SelectionRange.EndOffset - 1);
} else {
startLine = endLine = data.Caret.Line;
}
//single-line joins
if (endLine == startLine)
endLine++;
if (endLine > data.Document.LineCount)
return;
DocumentLine seg = data.Document.GetLine (startLine);
startOffset = seg.Offset;
StringBuilder sb = new StringBuilder (data.Document.GetTextAt (seg).TrimEnd ());
//lastSpaceOffset = startOffset + sb.Length;
for (int i = startLine + 1; i <= endLine; i++) {
seg = data.Document.GetLine (i);
//lastSpaceOffset = startOffset + sb.Length;
sb.Append (" ");
sb.Append (data.Document.GetTextAt (seg).Trim ());
}
length = (seg.Offset - startOffset) + seg.Length;
// TODO: handle conversion issues ?
data.Replace (startOffset, length, sb.ToString ());
}
示例8: TestBug14716
public void TestBug14716 ()
{
var data = new TextEditorData ();
data.Document.Text = "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n";
data.SearchEngine = new RegexSearchEngine ();
data.SearchEngine.SearchRequest.SearchPattern = "u.i.g";
data.SearchReplaceAll ("bar");
Assert.AreEqual ("bar System;\nbar System.Linq;\nbar System.Collections.Generic;\n", data.Document.Text );
}
示例9: CreateInsertionPoint
string CreateInsertionPoint (string input, string text, NewLineInsertion before, NewLineInsertion after)
{
int idx = input.IndexOf ('$');
Assert.Greater (idx, -1);
TextEditorData data = new TextEditorData (new TextDocument (input.Substring (0, idx) + input.Substring (idx + 1)));
InsertionPoint point = new InsertionPoint (data.Document.OffsetToLocation (idx), before, after);
point.Insert (data, text);
return data.Document.Text;
}
示例10: OnRemovedFromEditor
protected override void OnRemovedFromEditor (TextEditorData data)
{
SetCaretMode (CaretMode.Insert, data);
if (viTextEditor != null) {
statusArea.RemoveFromParentAndDestroy ();
statusArea = null;
viTextEditor = null;
}
}
示例11: Check
public static void Check (TextEditorData data, string output, bool reverse)
{
int offset1 = output.IndexOf ('[');
int offset2 = output.IndexOf (']');
string expected = output.Substring (0, offset1) + output.Substring (offset1 + 1, (offset2 - offset1) - 1) + output.Substring (offset2 + 1);
offset2--;
Assert.AreEqual (expected, data.Text);
Assert.AreEqual (data.OffsetToLocation (reverse ? offset2 : offset1), data.MainSelection.Anchor);
Assert.AreEqual (data.OffsetToLocation (reverse ? offset1 : offset2), data.MainSelection.Lead);
}
示例12: TestSimpleYToLineNumber
public void TestSimpleYToLineNumber ()
{
var editor = new TextEditorData ();
editor.Text = "1\n2\n3\n4\n5\n6\n7";
HeightTree heightTree = new HeightTree (editor);
heightTree.Rebuild ();
for (int i = 1; i <= editor.LineCount; i++) {
Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight));
}
}
示例13: LoadMark
public void LoadMark (TextEditorData data) {
int x = base.LineSegment.LineNumber;
data.Caret.Line = x;
int len = base.LineSegment.LengthIncludingDelimiter;
if (ColumnNumber >= len) {
// Check if the line has been truncated after the setting the mark
data.Caret.Column = len - 1;
} else {
data.Caret.Column = ColumnNumber;
}
}
示例14: OnAddedToEditor
protected override void OnAddedToEditor (TextEditorData data)
{
ViEditor.SetMode (ViEditorMode.Normal);
SetCaretMode (CaretMode.Block, data);
ViActions.RetreatFromLineEnd (data);
viTextEditor = data.Parent;
if (viTextEditor != null) {
statusArea = new ViStatusArea (viTextEditor);
}
}
示例15: NewLineAbove
public static void NewLineAbove (TextEditorData data)
{
if (data.Caret.Line == DocumentLocation.MinLine ) {
data.Caret.Offset = 0;
MiscActions.InsertNewLine (data);
data.Caret.Offset = 0;
return;
}
DocumentLine currentLine = data.Document.GetLine (data.Caret.Line - 1);
data.Caret.Offset = currentLine.Offset + currentLine.Length;
MiscActions.InsertNewLine (data);
}