本文整理汇总了C#中ITextView.MapDownToBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.MapDownToBuffer方法的具体用法?C# ITextView.MapDownToBuffer怎么用?C# ITextView.MapDownToBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.MapDownToBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCurrentExpression
public void ExecuteCurrentExpression(ITextView textView, Action<ITextView, ITextBuffer, int> formatDocument) {
if (InteractiveWindow == null || InteractiveWindow.IsRunning) {
return;
}
_coreShell.AssertIsOnMainThread();
var curBuffer = InteractiveWindow.CurrentLanguageBuffer;
var documentPoint = textView.MapDownToBuffer(textView.Caret.Position.BufferPosition, curBuffer);
var text = curBuffer.CurrentSnapshot.GetText();
if (!documentPoint.HasValue ||
documentPoint.Value == documentPoint.Value.Snapshot.Length ||
documentPoint.Value.Snapshot.Length == 0 ||
!IsMultiLineCandidate(text)) {
// Let the repl try and execute the code if the user presses enter at the
// end of the buffer.
if (InteractiveWindow.Evaluator.CanExecuteCode(text)) {
// If we know we can execute the code move the caret to the end of the
// current input, otherwise the interactive window won't execute it. We
// have slightly more permissive handling here.
var point = textView.BufferGraph.MapUpToBuffer(
new SnapshotPoint(
curBuffer.CurrentSnapshot,
curBuffer.CurrentSnapshot.Length
),
PointTrackingMode.Positive,
PositionAffinity.Successor,
textView.TextBuffer
);
textView.Caret.MoveTo(point.Value);
}
InteractiveWindow.Operations.Return();
} else {
// Otherwise insert a line break in the middle of an input
InteractiveWindow.Operations.BreakLine();
formatDocument(InteractiveWindow.TextView, curBuffer, Math.Max(documentPoint.Value - 1, 0));
}
}
示例2: MapCaretToBuffer
private static SnapshotPoint? MapCaretToBuffer(ITextView textView, ITextBuffer textBuffer) {
ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
return textView.MapDownToBuffer(textView.Caret.Position.BufferPosition, textBuffer);
}
示例3: MapPointFromView
/// <summary>
/// Maps given point from view buffer to R editor buffer
/// </summary>
public static SnapshotPoint? MapPointFromView(ITextView textView, SnapshotPoint point) {
ITextBuffer rBuffer;
SnapshotPoint? documentPoint = null;
IREditorDocument document = REditorDocument.FindInProjectedBuffers(textView.TextBuffer);
if (document != null) {
rBuffer = document.TextBuffer;
} else {
// Last resort, typically in unit tests when document is not available
rBuffer = REditorDocument.FindRBuffer(textView.TextBuffer);
}
if (rBuffer != null) {
if (textView.BufferGraph != null) {
documentPoint = textView.MapDownToBuffer(point, rBuffer);
} else {
documentPoint = point;
}
}
return documentPoint;
}