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


C# ITextView.MapUpToView方法代码示例

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

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

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


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