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


C# IDocument.OffsetToPosition方法代码示例

本文整理汇总了C#中IDocument.OffsetToPosition方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.OffsetToPosition方法的具体用法?C# IDocument.OffsetToPosition怎么用?C# IDocument.OffsetToPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocument的用法示例。


在下文中一共展示了IDocument.OffsetToPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHighlight

		public BracketHighlight GetHighlight(IDocument document, int offset)
		{
			int searchOffset;
			if (document.TextEditorProperties.BracketMatchingStyle == BracketMatchingStyle.After) {
				searchOffset = offset;
			} else {
				searchOffset = offset + 1;
			}
			char word = document.GetCharAt(Math.Max(0, Math.Min(document.TextLength - 1, searchOffset)));
			
			TextLocation endP = document.OffsetToPosition(searchOffset);
			if (word == opentag) {
				if (searchOffset < document.TextLength) {
					int bracketOffset = TextUtilities.SearchBracketForward(document, searchOffset + 1, opentag, closingtag);
					if (bracketOffset >= 0) {
						TextLocation p = document.OffsetToPosition(bracketOffset);
						return new BracketHighlight(p, endP);
					}
				}
			} else if (word == closingtag) {
				if (searchOffset > 0) {
					int bracketOffset = TextUtilities.SearchBracketBackward(document, searchOffset - 1, opentag, closingtag);
					if (bracketOffset >= 0) {
						TextLocation p = document.OffsetToPosition(bracketOffset);
						return new BracketHighlight(p, endP);
					}
				}
			}
			return null;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:30,代码来源:BracketHighlighter.cs

示例2: SelectText

		/// <summary>
		/// Selects the specified text range.
		/// </summary>
		static void SelectText(SelectionManager selectionManager, IDocument document, int startOffset, int length)
		{
			selectionManager.ClearSelection();
			TextLocation selectionStart = document.OffsetToPosition(startOffset);
			TextLocation selectionEnd = document.OffsetToPosition(startOffset + length);
			selectionManager.SetSelection(selectionStart, selectionEnd);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:WixDocumentEditor.cs

示例3: GetHighlight

 public Highlight GetHighlight(IDocument document, int offset)
 {
     char word = document.GetCharAt(Math.Max(0, Math.Min(document.TextLength - 1, offset)));
     Point endP = document.OffsetToPosition(offset);
     if (word == opentag) {
         if (offset < document.TextLength) {
             int bracketOffset = TextUtilities.SearchBracketForward(document, offset + 1, opentag, closingtag);
             if (bracketOffset >= 0) {
                 Point p = document.OffsetToPosition(bracketOffset);
                 return new Highlight(p, endP);
             }
         }
     } else if (word == closingtag) {
         if (offset > 0) {
             int bracketOffset = TextUtilities.SearchBracketBackward(document, offset - 1, opentag, closingtag);
             if (bracketOffset >= 0) {
                 Point p = document.OffsetToPosition(bracketOffset);
                 return new Highlight(p, endP);
             }
         }
     }
     return null;
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:23,代码来源:BracketHighlighter.cs

示例4: GetHighlight

        /// <summary>
        /// Gets the highlight.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="offset">The offset.</param>
        /// <returns>The matching bracers.</returns>
        public Highlight GetHighlight(IDocument document, int offset)
        {
            int searchOffset;
              if (document.TextEditorProperties.BracketMatchingStyle == BracketMatchingStyle.After)
            searchOffset = offset;
              else
            searchOffset = offset + 1;

              char word = document.GetCharAt(Math.Max(0, Math.Min(document.TextLength - 1, searchOffset)));

              TextLocation endP = document.OffsetToPosition(searchOffset);
              if (word == _openTag)
              {
            if (searchOffset < document.TextLength)
            {
              int bracketOffset = TextHelper.FindClosingBracket(document, searchOffset + 1, _openTag, _closingTag);
              if (bracketOffset >= 0)
              {
            TextLocation p = document.OffsetToPosition(bracketOffset);
            return new Highlight(p, endP);
              }
            }
              }
              else if (word == _closingTag)
              {
            if (searchOffset > 0)
            {
              int bracketOffset = TextHelper.FindOpeningBracket(document, searchOffset - 1, _openTag, _closingTag);
              if (bracketOffset >= 0)
              {
            TextLocation p = document.OffsetToPosition(bracketOffset);
            return new Highlight(p, endP);
              }
            }
              }
              return null;
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:43,代码来源:BracketHighlighter.cs

示例5: SearchBracket

		public BracketSearchResult SearchBracket(IDocument document, int offset)
		{
			if (offset > 0) {
				char c = document.GetCharAt(offset - 1);
				int index = openingBrackets.IndexOf(c);
				int otherOffset = -1;
				if (index > -1)
					otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]);
				
				index = closingBrackets.IndexOf(c);
				if (index > -1)
					otherOffset = SearchBracketBackward(document, offset - 2, openingBrackets[index], closingBrackets[index]);
				
				if (otherOffset > -1)
					return new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1,
					                               Math.Max(offset - 1, otherOffset), 1);
				
				int length;
				VBStatement statement;
				
				int startIndex = FindBeginStatementAroundOffset(document, offset, out statement, out length);
				int endIndex = 0;
				
				if (statement != null)
					endIndex = FindEndStatement(document, statement);
				else {
					endIndex = FindEndStatementAroundOffset(document, offset, out statement);
					
					if (statement != null)
						startIndex = FindBeginStatement(document, statement, document.OffsetToPosition(endIndex), out length);
				}
				
				if (startIndex > -1 && endIndex > -1)
					return new BracketSearchResult(startIndex, length, endIndex,
					                               statement.EndStatement.Length);
			}
			
			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:39,代码来源:VBNetBracketSearcher.cs

示例6: ExtendLeft

		/// <summary>
		/// If the text at startPos is preceded by any of the prefixes, moves the start backwards to include one prefix
		/// (the rightmost one).
		/// </summary>
		Location ExtendLeft(Location startPos, IDocument document, params String[] prefixes)
		{
			int startOffset = document.PositionToOffset(startPos);
			foreach (string prefix in prefixes) {
				if (startOffset < prefix.Length) continue;
				string realPrefix = document.GetText(startOffset - prefix.Length, prefix.Length);
				if (realPrefix == prefix) {
					return document.OffsetToPosition(startOffset - prefix.Length);
				}
			}
			// no prefixes -> do not extend
			return startPos;
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:17,代码来源:CodeManipulation.cs

示例7: ExtendSelectionToEndOfLineComments

		/// <summary>
		/// If there is a comment block behind selection on the same line ("var i = 5; // comment"), add it to selection.
		/// </summary>
		Selection ExtendSelectionToEndOfLineComments(IDocument document, Location selectionStart, Location selectionEnd, IEnumerable<Comment> commentsBlankLines)
		{
			var lineComment = commentsBlankLines.FirstOrDefault(c => c.StartPosition.Line == selectionEnd.Line && c.StartPosition >= selectionEnd);
			if (lineComment == null) {
				return null;
			}
			bool isWholeLineSelected = IsWhitespaceBetween(document, new Location(1, selectionStart.Line), selectionStart);
			if (!isWholeLineSelected) {
				// whole line must be selected before we add the comment
				return null;
			}
			// fix the end of comment set to next line incorrectly by the parser
			int fixEndPos = document.PositionToOffset(lineComment.EndPosition) - 1;
			return new Selection { Start = selectionStart, End = document.OffsetToPosition(fixEndPos) };
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:18,代码来源:CodeManipulation.cs

示例8: GetEndPosition

		public virtual Point GetEndPosition(IDocument document)
		{
			return document.OffsetToPosition(Offset + Length);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:4,代码来源:SearchResult.cs

示例9: GetStartPosition

		public virtual Point GetStartPosition(IDocument document)
		{
			return document.OffsetToPosition(Offset);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:4,代码来源:SearchResult.cs

示例10: GenerateFoldMarkers

        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> Back = new List<FoldMarker>();
            //get all the text
            string Script = document.GetText(0, document.TextLength);
            //tokenize text
            TokenList Tokens = Script.GetTokens();

            #region Calculate folding for BEGIN <----> END
            List<Token> FoldStarter = Tokens.GetByType(TokenType.BLOCKSTART);
            List<Token> FoldEnder = Tokens.GetByType(TokenType.BLOCKEND);

            for (int i = 0; i < FoldEnder.Count; i++)
            {
                for (int j = FoldStarter.Count - 1; j >= 0; j--)
                {
                    if (Tokens.GetStartOf(FoldStarter[j]) < Tokens.GetStartOf(FoldEnder[i]))
                    {
                        Token Starter, Ender;
                        Ender = FoldEnder[i];
                        Starter = FoldStarter[j];
                        TextLocation Start, End, afterFoldHelper;

                        Start = document.OffsetToPosition(Tokens.GetStartOf(Starter) + "begin".Length);
                        afterFoldHelper = document.OffsetToPosition(Tokens.GetStartOf(Starter));
                        End = document.OffsetToPosition(Tokens.GetStartOf(Ender));

                        string afterStarter = document.GetText(document.GetLineSegment(afterFoldHelper.Line)).Substring(afterFoldHelper.Column).Trim(' ', '\t', '\n', '\r');
                        afterStarter = afterStarter.Length > 5 ? afterStarter.Substring(5) : "";
                        if (String.IsNullOrEmpty(afterStarter) || afterStarter.Trim().Length == 0)
                            afterStarter = "...";

                        Back.Add(new FoldMarker(document, Start.Line, Start.Column, End.Line, End.Column, FoldType.Region, afterStarter, false));

                        FoldStarter.RemoveAt(j);
                        break;
                    }
                }
            }
            #endregion

            #region Calculate folding for block comments
            List<Token> BlockCommentFolds = Tokens.GetByType(TokenType.BLOCKCOMMENT);

            for (int i = 0; i < BlockCommentFolds.Count; i++)
            {
                Token BlockComment = BlockCommentFolds[i];
                TextLocation Start, End;

                Start = document.OffsetToPosition(Tokens.GetStartOf(BlockComment) + 2);
                End = document.OffsetToPosition(Tokens.GetEndOf(BlockComment) - 1);

                Back.Add(new FoldMarker(document, Start.Line, Start.Column, End.Line, End.Column, FoldType.Region, "***", false));
            }
            #endregion

            #region Calculate folding for custom folders --fold <----> --/fold
            FoldStarter = Tokens.GetCustomFolders(true);
            FoldEnder = Tokens.GetCustomFolders(false);

            for (int i = 0; i < FoldEnder.Count; i++)
            {
                for (int j = FoldStarter.Count - 1; j >= 0; j--)
                {
                    if (Tokens.GetStartOf(FoldStarter[j]) < Tokens.GetStartOf(FoldEnder[i]))
                    {
                        Token Starter, Ender;
                        Ender = FoldEnder[i];
                        Starter = FoldStarter[j];
                        TextLocation Start, End, afterFoldHelper;

                        Start = document.OffsetToPosition(Tokens.GetStartOf(Starter) + "--fold".Length);
                        afterFoldHelper = document.OffsetToPosition(Tokens.GetStartOf(Starter));
                        End = document.OffsetToPosition(Tokens.GetStartOf(Ender));

                        string afterStarter = document.GetText(document.GetLineSegment(afterFoldHelper.Line)).Substring(afterFoldHelper.Column).Trim(' ', '\t', '\n', '\r');
                        afterStarter = afterStarter.Length > 6 ? afterStarter.Substring(6) : "";
                        if (String.IsNullOrEmpty(afterStarter) || afterStarter.Trim().Length == 0)
                            afterStarter = "...";

                        Back.Add(new FoldMarker(document, Start.Line, Start.Column, End.Line, End.Column, FoldType.Region, afterStarter, false));

                        FoldStarter.RemoveAt(j);
                        break;
                    }
                }
            }
            #endregion

            return Back;
        }
开发者ID:GUrbiola,项目名称:Ez_SQL,代码行数:91,代码来源:FoldingStrategy.cs

示例11: Resolve

		public static ResolveResult Resolve(int offset, IDocument document, string fileName)
		{
			var position = document.OffsetToPosition(offset);
			return Resolve(position.Line, position.Column, document, fileName);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:5,代码来源:ParserService.cs

示例12: GetEndPosition

		public virtual TextLocation GetEndPosition(IDocument document)
		{
			return document.OffsetToPosition(Math.Min(Offset + Length, document.TextLength));
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:4,代码来源:SearchResultMatch.cs

示例13: GetTextSpan

            private NiTextSpan GetTextSpan(IDocument document, int offset, int length)
            {
                var start = document.OffsetToPosition(offset);
                var end = document.OffsetToPosition(offset + length);

                return new NiTextSpan(start.Line, start.Column, end.Line, end.Column);
            }
开发者ID:netide,项目名称:netide,代码行数:7,代码来源:TextEditorControl.FindTarget.cs

示例14: ToRegion

 public DomRegion ToRegion(IDocument document)
 {
     Location start = document.OffsetToPosition(minChar);
     Location end = document.OffsetToPosition(limChar);
     return DomRegion.FromLocation(start, end);
 }
开发者ID:pabloescribano,项目名称:typescript-addin,代码行数:6,代码来源:NavigateToItem.cs

示例15: GetStartPosition

		public virtual Location GetStartPosition(IDocument document)
		{
			return document.OffsetToPosition(Math.Min(Offset, document.TextLength));
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:SearchResultMatch.cs


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