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


C# TextEditorData.OffsetToLineNumber方法代码示例

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


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

示例1: InnerBlock

        public static CommandRange InnerBlock(TextEditorData editor, char openingChar, char closingChar)
        {
            var range = Block(editor, openingChar, closingChar);
            if (range.Length == 0)
                return CommandRange.Empty;
            int start = range.Start + 1;
            int end = range.End - 2;
            var line = editor.GetLine(editor.OffsetToLineNumber(range.Start));

            // exclude newline if it comes just after opening char
            if (line.EndOffsetIncludingDelimiter - start <= line.DelimiterLength)
                start += line.DelimiterLength;

            // exclude whitespace that comes just before the closing char...
            line = editor.GetLine(editor.OffsetToLineNumber(range.End));
            while (Char.IsWhiteSpace(editor.Text[end]) && end >= line.Offset)
                end--;
            //.. but only if newline comes after it
            if (end >= line.Offset)
                end = range.End - 2;
            else
                end -= line.PreviousLine.DelimiterLength;

            if (start > end + 1)
                return new CommandRange(start, start);

            return new CommandRange(start, end+1);
        }
开发者ID:hifi,项目名称:monodevelop-justenoughvi,代码行数:28,代码来源:TextObject.cs

示例2: GetOutermostClosedFold

		/// <summary>
		/// Gets the outermost closed fold pertaining to the current caret position
		/// </summary>
		static FoldSegment GetOutermostClosedFold (TextEditorData data)
		{
			FoldSegment currentFold = null;
			int endOffset = -1, startOffset = int.MaxValue;
			IEnumerable<FoldSegment> folds = data.Document.GetFoldingContaining (data.Caret.Line);
			int lineNumber = data.LogicalToVisualLocation (data.Caret.Location).Line;
			if (null != folds) {
				foreach (FoldSegment fold in folds) {
					if (fold.IsFolded && data.LogicalToVisualLine (data.OffsetToLineNumber (fold.Offset)) == lineNumber && 
					    fold.Offset <= startOffset && fold.EndOffset >= endOffset) {
						currentFold = fold;
						startOffset = fold.Offset;
						endOffset = fold.EndOffset;
					}
				}
			}
			
			return currentFold;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:22,代码来源:FoldActions.cs

示例3: CorrectFormatting

		int CorrectFormatting (TextEditorData data, int start, int end)
		{
			int delta = 0;
			int lineNumber = data.OffsetToLineNumber (start);
			LineSegment line = data.GetLine (lineNumber);
			if (line.Offset < start)
				lineNumber++;
			line = data.GetLine (lineNumber);
			if (line == null)
				return 0;
			bool wholeDocument = end >= data.Document.Length;
			do {
				string indent = line.GetIndentation (data.Document);
				StringBuilder newIndent = new StringBuilder ();
				int col = 1;
				if (data.Options.TabsToSpaces) {
					foreach (char ch in indent) {
						if (ch == '\t') {
							int tabWidth = TextViewMargin.GetNextTabstop (data, col) - col;
							newIndent.Append (new string (' ', tabWidth));
							col += tabWidth;
						} else {
							newIndent.Append (ch);
						}
					}
				} else {
					for (int i = 0; i < indent.Length; i++) {
						char ch = indent [i];
						if (ch == '\t') {
							int tabWidth = TextViewMargin.GetNextTabstop (data, col) - col;
							newIndent.Append (ch);
							col += tabWidth;
						} else {
							int tabWidth = TextViewMargin.GetNextTabstop (data, col) - col;
							newIndent.Append ('\t');
							col += tabWidth;
							while (tabWidth-- > 0 && i + 1 < indent.Length) {
								if (indent [i + 1] != ' ')
									break;
								i++;
							}
						}
					}
				}
				if (indent.Length == line.EditableLength)
					newIndent.Length = 0;
				if (line.DelimiterLength != 0) {
					delta -= line.DelimiterLength;
					delta += data.EolMarker.Length;
					data.Replace (line.Offset + line.EditableLength, line.DelimiterLength, data.EolMarker);
					if (!wholeDocument) {
						end -= line.DelimiterLength;
						end += data.EolMarker.Length;
					}
				}

				string replaceWith = newIndent.ToString ();
				if (indent != replaceWith) {
					int count = (indent ?? "").Length;
					delta -= count;
					delta += data.Replace (line.Offset, count, replaceWith);
					if (!wholeDocument)
						end = end - count + replaceWith.Length;
				}

				lineNumber++;
				line = data.GetLine (lineNumber);
			} while (line != null && (wholeDocument || line.EndOffset <= end));
			return delta;
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:70,代码来源:CSharpFormatter.cs


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