本文整理汇总了C#中ITextView.MapUpToView方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.MapUpToView方法的具体用法?C# ITextView.MapUpToView怎么用?C# ITextView.MapUpToView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.MapUpToView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanFormatLine
public bool CanFormatLine(ITextView textView, ITextBuffer containedLanguageBuffer, int lineNumber) {
var line = containedLanguageBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber);
var viewPoint = textView.MapUpToView(line.Start);
if (viewPoint.HasValue) {
var lineText = textView.TextBuffer.CurrentSnapshot.GetLineFromPosition(viewPoint.Value).GetText();
return lineText.IndexOfOrdinal("```") < 0 && !lineText.TrimStart().StartsWithIgnoreCase("```{r");
}
return false;
}
示例2: FindCurrentItemDefinition
public static SnapshotPoint? FindCurrentItemDefinition(ITextView textView, ITextBuffer textBuffer, out string itemName) {
Span span;
itemName = textView.GetIdentifierUnderCaret(out span);
if (!string.IsNullOrEmpty(itemName)) {
var position = REditorDocument.MapCaretPositionFromView(textView);
if (position.HasValue) {
var document = REditorDocument.FromTextBuffer(textBuffer);
var itemDefinition = document.EditorTree.AstRoot.FindItemDefinition(position.Value, itemName);
if (itemDefinition != null) {
return textView.MapUpToView(new SnapshotPoint(document.EditorTree.TextSnapshot, itemDefinition.Start));
}
}
}
return null;
}
示例3: IndentCaretInNewScope
private static void IndentCaretInNewScope(ITextView textView, IScope scope, SnapshotPoint caretBufferPoint, RFormatOptions options) {
if (scope == null || scope.OpenCurlyBrace == null) {
return;
}
ITextSnapshot rSnapshot = caretBufferPoint.Snapshot;
ITextBuffer rTextBuffer = rSnapshot.TextBuffer;
int rCaretPosition = caretBufferPoint.Position;
var caretLine = rSnapshot.GetLineFromPosition(rCaretPosition);
int innerIndentSize = SmartIndenter.InnerIndentSizeFromNode(rTextBuffer, scope, options);
int openBraceLineNumber = rSnapshot.GetLineNumberFromPosition(scope.OpenCurlyBrace.Start);
var braceLine = rSnapshot.GetLineFromLineNumber(openBraceLineNumber);
var indentLine = rSnapshot.GetLineFromLineNumber(openBraceLineNumber + 1);
string lineBreakText = braceLine.GetLineBreakText();
rTextBuffer.Insert(indentLine.Start, lineBreakText);
// Fetch the line again since snapshot has changed when line break was inserted
indentLine = rTextBuffer.CurrentSnapshot.GetLineFromLineNumber(openBraceLineNumber + 1);
// Map new caret position back to the view
var positionInView = textView.MapUpToView(indentLine.Start);
if (positionInView.HasValue) {
var viewIndentLine = textView.TextBuffer.CurrentSnapshot.GetLineFromPosition(positionInView.Value);
textView.Caret.MoveTo(new VirtualSnapshotPoint(viewIndentLine.Start, innerIndentSize));
}
}