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


C# Document.GetLineIndent方法代码示例

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


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

示例1: CheckStartPoint

		static void CheckStartPoint (Document doc, InsertionPoint point, bool isEndPoint)
		{
			LineSegment line = doc.GetLine (point.Location.Line);
			if (line == null)
				return;
			if (doc.GetLineIndent (line).Length + 1 == point.Location.Column) {
				int lineNr = point.Location.Line;
				while (lineNr > 1 && doc.GetLineIndent (lineNr - 1).Length == doc.GetLine (lineNr - 1).EditableLength) {
					lineNr--;
				}
				line = doc.GetLine (lineNr);
				point.Location = new DocumentLocation (lineNr, doc.GetLineIndent (line).Length + 1);
			}
			
			if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
				point.LineBefore = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
			if (point.Location.Column < line.EditableLength + 1)
				point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:19,代码来源:HelperMethods.cs

示例2: CheckEndPoint

		static void CheckEndPoint (Document doc, InsertionPoint point, bool isStartPoint)
		{
			LineSegment line = doc.GetLine (point.Location.Line);
			if (line == null)
				return;
			
			if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
				point.LineBefore = NewLineInsertion.BlankLine;
			if (point.Location.Column < line.EditableLength + 1)
				point.LineAfter = NewLineInsertion.Eol;
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:11,代码来源:HelperMethods.cs

示例3: GetIndent

		static string GetIndent (string text)
		{
			Mono.TextEditor.Document doc = new Mono.TextEditor.Document ();
			doc.Text = text;
			string result = null;
			for (int i = 1; i < doc.LineCount; i++) {
				string lineIndent = doc.GetLineIndent (i);
				if (doc.GetLine (i).EditableLength == lineIndent.Length)
					continue;
				if (result == null || lineIndent.Length < result.Length)
					result = lineIndent;
			}
			return result ?? "";
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:14,代码来源:ExtractMethodRefactoring.cs

示例4: GetInsertionPosition

		static InsertionPoint GetInsertionPosition (Document doc, int line, int column)
		{
			int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
			
			LineSegment curLine = doc.GetLine (line);
			if (curLine != null) {
				if (bodyEndOffset < curLine.Offset + curLine.EditableLength)
					return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
			}
			
			LineSegment nextLine = doc.GetLine (line + 1);
			
			int endOffset = nextLine != null ? nextLine.Offset : doc.Length;
			for (int i = bodyEndOffset; i < endOffset; i++) {
				char ch = doc.GetCharAt (i);
				if (!char.IsWhiteSpace (ch))
					return new InsertionPoint (doc.OffsetToLocation (i), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
			}
			
			if (nextLine == null)
				return new InsertionPoint (doc.OffsetToLocation (bodyEndOffset - 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
			int oldLine = line;
			while (line < doc.LineCount && doc.GetLineIndent (line + 1).Length == doc.GetLine (line + 1).EditableLength)
				line++;
			NewLineInsertion insertBefore = NewLineInsertion.None;
			NewLineInsertion insertAfter = NewLineInsertion.None;
			int delta = line - oldLine;
			int lineNumber = line + 1;
			
			if (delta == 0) {
				insertBefore = NewLineInsertion.Eol;
				insertAfter = NewLineInsertion.BlankLine;
			} else if (delta == 1) {
				insertAfter = NewLineInsertion.BlankLine;
			} else if (delta == 2) {
				lineNumber--;
				insertAfter = NewLineInsertion.BlankLine;
			} else if (delta >= 3) {
				lineNumber -= 2;
				insertAfter = NewLineInsertion.None;
			}
			
			return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length + 1), insertBefore, insertAfter);
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:44,代码来源:HelperMethods.cs

示例5: GetInsertionPosition

		static InsertionPoint GetInsertionPosition (Document doc, int line, int column)
		{
			LineSegment nextLine = doc.GetLine (line + 1);
			int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
			int endOffset = nextLine != null ? nextLine.Offset : doc.Length;
			for (int i = bodyEndOffset; i < endOffset; i++) {
				char ch = doc.GetCharAt (i);
				if (!char.IsWhiteSpace (ch))
					return new InsertionPoint (doc.OffsetToLocation (i), true, true);
			}
			
			if (nextLine == null)
				return new InsertionPoint (doc.OffsetToLocation (bodyEndOffset - 1), true, true);
			int oldLine = line;
			bool curLineEmpty = false;
			if (doc.GetLineIndent (nextLine).Length == nextLine.EditableLength) {
				curLineEmpty = true;
				while (line + 2 < doc.LineCount && doc.GetLineIndent (line + 2).Length == doc.GetLine (line + 2).EditableLength)
					line++;
			}
			bool insertBefore = !curLineEmpty && line - oldLine <= 1;
			bool insertAfter  = line - oldLine == 0;
//			if (curLineEmpty)
//				line++;
			int lineNumber = line + 1;
			return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length), insertBefore, insertAfter);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:27,代码来源:HelperMethods.cs

示例6: CheckStartPoint

		static void CheckStartPoint (Document doc, InsertionPoint point)
		{
			LineSegment line = doc.GetLine (point.Location.Line);
			if (line == null)
				return;
			if (doc.GetLineIndent (line).Length < point.Location.Column)
				point.ShouldInsertNewLineBefore = true;
			if (point.Location.Column < line.EditableLength)
				point.ShouldInsertNewLineAfter = true;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:HelperMethods.cs


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