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


C# TextDocument.GetLineByOffset方法代码示例

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


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

示例1: ScanWord

		static int ScanWord (TextDocument doc, int offset, bool forwardDirection)
		{
			if (offset < 0 || offset >= doc.TextLength)
				return offset;
			var line = doc.GetLineByOffset (offset);
			char first = doc.GetCharAt (offset);
			if (char.IsPunctuation (first))
				return forwardDirection ? System.Math.Min (line.Offset + line.Length, offset + 1) : System.Math.Max (line.Offset, offset - 1);
			while (offset >= line.Offset && offset < line.Offset + line.Length) {
				char ch = doc.GetCharAt (offset);
				if (char.IsWhiteSpace (first) && !char.IsWhiteSpace (ch)
				    || WordFindStrategy.IsNoIdentifierPart (first) && !WordFindStrategy.IsNoIdentifierPart (ch)
				    || (char.IsLetterOrDigit (first) || first == '_') && !(char.IsLetterOrDigit (ch) || ch == '_'))
					break;
				offset = forwardDirection ? offset + 1 : offset - 1;
			}
			return System.Math.Min (line.Offset + line.Length,
			                        System.Math.Max (line.Offset, offset + (forwardDirection ? 0 : 1)));
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:19,代码来源:TextViewMargin.cs

示例2: StartsInLineComment

		bool StartsInLineComment (TextDocument document, int offset)
		{
			List<string> lineComments = GetList (document, "LineComment");
			DocumentLine line = document.GetLineByOffset (offset);
			for (int i = line.Offset ; i < offset; i++) {
				if (StartsWithListMember (document, lineComments, i) >= 0)
					return true;
			}
			return false;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:10,代码来源:IBracketMatcher.cs

示例3: GetLastSourceCodePosition

		int GetLastSourceCodePosition (TextDocument document, int lineOffset)
		{
			DocumentLine line = document.GetLineByOffset (lineOffset);
			if (line == null)
				return lineOffset;
			bool isInBlockComment = false;
			bool isInLineComment  = false;
			int  curStringQuote   = -1;
			
			List<string> lineComments       = GetList (document, "LineComment");
			List<string> blockCommentStarts = GetList (document, "BlockCommentStart");
			List<string> blockCommentEnds   = GetList (document, "BlockCommentEnd");
			List<string> stringQuotes       = GetList (document, "StringQuote");
			
			for (int i = 0 ; i < line.Length; i++) {
				int offset = line.Offset + i;
				// check line comments
				if (!isInBlockComment && curStringQuote < 0) {
					isInLineComment = StartsWithListMember (document, lineComments, offset) >= 0;
					if (isInLineComment) 
						return System.Math.Min (offset, lineOffset);
				}
				// check block comments
				if (!isInLineComment && curStringQuote < 0) {
					if (!isInBlockComment) { 
						isInBlockComment = StartsWithListMember (document, blockCommentStarts, offset) >= 0;
					} else {
						isInBlockComment = StartsWithListMember (document, blockCommentEnds, offset) < 0;
					}
				}
				
				if (!isInBlockComment && !isInLineComment) {
					int j = StartsWithListMember (document, stringQuotes, offset);
					if (j >= 0) {
						if (curStringQuote >= 0) {
							if (curStringQuote == j)
								curStringQuote = -1;
						} else {
							curStringQuote = j;
						}
					}
				}
			}
			return lineOffset;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:45,代码来源:IBracketMatcher.cs

示例4: Conflicts

		// todo: move to version control backend
		static IEnumerable<Conflict> Conflicts (TextDocument doc)
		{
			int mergeStart = 0;
			while ((mergeStart = doc.IndexOf ("<<<<<<<", mergeStart, doc.TextLength - mergeStart, StringComparison.Ordinal)) >= 0) {
				DocumentLine start = doc.GetLineByOffset (mergeStart);
				if (start.Offset != mergeStart)
					continue;
				int dividerOffset = doc.IndexOf ("=======", mergeStart, doc.TextLength - mergeStart, StringComparison.Ordinal);
				DocumentLine divider = doc.GetLineByOffset (dividerOffset);

				int endOffset = doc.IndexOf (">>>>>>>", dividerOffset, doc.TextLength - dividerOffset, StringComparison.Ordinal);
				DocumentLine end = doc.GetLineByOffset (endOffset);
				mergeStart = dividerOffset + 1;

				yield return new Conflict (new TextSegment (start.EndOffsetIncludingDelimiter, divider.Offset - start.EndOffsetIncludingDelimiter),
					new TextSegment (divider.EndOffsetIncludingDelimiter, end.Offset - divider.EndOffsetIncludingDelimiter),
					start,
					divider,
					end);
			}
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:22,代码来源:MergeWidget.cs


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