当前位置: 首页>>代码示例>>C#>>正文


C# ITextView.MapDownToBuffer方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:40,代码来源:RInteractiveWorkflowOperations.cs

示例2: MapCaretToBuffer

 private static SnapshotPoint? MapCaretToBuffer(ITextView textView, ITextBuffer textBuffer) {
     ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
     return textView.MapDownToBuffer(textView.Caret.Position.BufferPosition, textBuffer);
 }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:4,代码来源:AutoFormat.cs

示例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;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:25,代码来源:REditorDocument.cs


注:本文中的ITextView.MapDownToBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。