本文整理汇总了C#中Mono.TextEditor.TextDocument.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.Insert方法的具体用法?C# TextDocument.Insert怎么用?C# TextDocument.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.TextDocument
的用法示例。
在下文中一共展示了TextDocument.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyData
void CopyData (TextEditorData data, Selection selection)
{
copiedDocument = null;
monoDocument = null;
if (selection != null && data != null && data.Document != null) {
copiedDocument = new TextDocument ();
monoDocument = new TextDocument ();
this.docStyle = data.ColorStyle;
this.options = data.Options;
this.mode = SyntaxModeService.GetSyntaxMode (monoDocument, data.MimeType);
switch (selection.SelectionMode) {
case SelectionMode.Normal:
isBlockMode = false;
var segment = selection.GetSelectionRange (data);
var text = data.GetTextAt (segment);
copiedDocument.Text = text;
monoDocument.Text = text;
var line = data.Document.GetLineByOffset (segment.Offset);
var spanStack = line.StartSpan.Clone ();
SyntaxModeService.ScanSpans (data.Document, this.mode as SyntaxMode, this.mode as SyntaxMode, spanStack, line.Offset, segment.Offset);
this.copiedDocument.GetLine (DocumentLocation.MinLine).StartSpan = spanStack;
break;
case SelectionMode.Block:
isBlockMode = true;
DocumentLocation visStart = data.LogicalToVisualLocation (selection.Anchor);
DocumentLocation visEnd = data.LogicalToVisualLocation (selection.Lead);
int startCol = System.Math.Min (visStart.Column, visEnd.Column);
int endCol = System.Math.Max (visStart.Column, visEnd.Column);
for (int lineNr = selection.MinLine; lineNr <= selection.MaxLine; lineNr++) {
DocumentLine curLine = data.Document.GetLine (lineNr);
int col1 = curLine.GetLogicalColumn (data, startCol) - 1;
int col2 = System.Math.Min (curLine.GetLogicalColumn (data, endCol) - 1, curLine.Length);
if (col1 < col2) {
copiedDocument.Insert (copiedDocument.TextLength, data.Document.GetTextAt (curLine.Offset + col1, col2 - col1));
monoDocument.Insert (monoDocument.TextLength, data.Document.GetTextAt (curLine.Offset + col1, col2 - col1));
}
if (lineNr < selection.MaxLine) {
// Clipboard line end needs to be system dependend and not the document one.
copiedDocument.Insert (copiedDocument.TextLength, Environment.NewLine);
// \r in mono document stands for block selection line end.
monoDocument.Insert (monoDocument.TextLength, "\r");
}
}
line = data.Document.GetLine (selection.MinLine);
spanStack = line.StartSpan.Clone ();
SyntaxModeService.ScanSpans (data.Document, this.mode as SyntaxMode, this.mode as SyntaxMode, spanStack, line.Offset, line.Offset + startCol);
this.copiedDocument.GetLine (DocumentLocation.MinLine).StartSpan = spanStack;
break;
}
} else {
copiedDocument = null;
}
}