當前位置: 首頁>>代碼示例>>C#>>正文


C# TextDocument.GetLine方法代碼示例

本文整理匯總了C#中Mono.TextEditor.TextDocument.GetLine方法的典型用法代碼示例。如果您正苦於以下問題:C# TextDocument.GetLine方法的具體用法?C# TextDocument.GetLine怎麽用?C# TextDocument.GetLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.TextEditor.TextDocument的用法示例。


在下文中一共展示了TextDocument.GetLine方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindNextWordOffset

		int FindNextWordOffset (TextDocument doc, int offset, bool subword)
		{
			int lineNumber   = doc.OffsetToLineNumber (offset);
			DocumentLine line = doc.GetLine (lineNumber);
			if (line == null)
				return offset;
			
			int result    = offset;
			int endOffset = line.Offset + line.Length;
			if (result == endOffset) {
				line = doc.GetLine (lineNumber + 1);
				if (line != null)
					result = line.Offset;
				return result;
			}
			
			CharacterClass current = GetCharacterClass (doc.GetCharAt (result), subword, false);
			while (result < endOffset) {
				CharacterClass next = GetCharacterClass (doc.GetCharAt (result), subword, false);
				if (next != current) {
					
					// camelCase and PascalCase handling
					bool camelSkip = false;
					if (next == CharacterClass.LowercaseLetter && current == CharacterClass.UppercaseLetter) {
						if (result-2 > line.Offset) {
							CharacterClass previous = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
							if (previous == CharacterClass.UppercaseLetter && result-2 > offset)
								result--;
							else
								camelSkip = true;
						}
					}
					
					if (!camelSkip)
						break;
				}
				
				current = next;		
				result++;
			}
			while (result < endOffset && GetCharacterClass (doc.GetCharAt (result), subword, false) == CharacterClass.Whitespace) {
				result++;
			}
			return result;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:45,代碼來源:SharpDevelopWordFindStrategy.cs

示例2: FindPrevWordOffset

		int FindPrevWordOffset (TextDocument doc, int offset, bool subword)
		{
			int lineNumber = doc.OffsetToLineNumber (offset);
			DocumentLine line = doc.GetLine (lineNumber);
			if (line == null)
				return offset;
			
			int result = offset;
			if (result == line.Offset) {
				line = doc.GetLine (lineNumber - 1);
				if (line != null)
					result = line.Offset + line.Length;
				return result;
			}
			
			CharacterClass current = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
			
			if (current == CharacterClass.Whitespace && result - 1 > line.Offset) {
				result--;
				current = GetCharacterClass (doc.GetCharAt (result - 2), subword, false);
			}
			
			while (result > line.Offset) {
				CharacterClass prev = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
				if (prev != current) {
					
					// camelCase and PascalCase handling
					bool camelSkip = false;
					if (prev == CharacterClass.UppercaseLetter && current == CharacterClass.LowercaseLetter) {
						if (result-2 > line.Offset) {
							CharacterClass back2 = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
							if (back2 == CharacterClass.UppercaseLetter)
								result--;
							else
								camelSkip = true;
						}
					}
					
					if (!camelSkip)
						break;
				}
				
				current = prev;
				result--;
			}
			
			return result;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:48,代碼來源:SharpDevelopWordFindStrategy.cs

示例3: UnderLineError

		void UnderLineError (Document doc, Error info)
		{
			var line = doc.GetLine (info.Region.BeginLine);
			// If the line is already underlined
			if (errors.Any (em => em.LineSegment == line))
				return;
			ErrorMarker error = new ErrorMarker (textEditor.Document, info, line);
			errors.Add (error);
			doc.AddMarker (line, error);
		}
開發者ID:telebovich,項目名稱:monodevelop,代碼行數:10,代碼來源:SourceEditorWidget.cs

示例4: GetInsertionPosition

		static InsertionPoint GetInsertionPosition (TextDocument doc, int line, int column)
		{
			int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
			DocumentLine curLine = doc.GetLine (line);
			if (curLine != null) {
				if (bodyEndOffset < curLine.Offset + curLine.Length) {
					// case1: positition is somewhere inside the start line
					return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.Eol, NewLineInsertion.BlankLine);
				}
			}
			
			// -> if position is at line end check next line
			DocumentLine nextLine = doc.GetLine (line + 1);
			if (nextLine == null) // check for 1 line case.
				return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
			
			for (int i = nextLine.Offset; i < nextLine.Offset + nextLine.Length; i++) {
				char ch = doc.GetCharAt (i);
				if (!char.IsWhiteSpace (ch)) {
					// case2: next line contains non ws chars.
					return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.BlankLine);
				}
			}
			// case3: whitespace line
			return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.None);
		}
開發者ID:dodev,項目名稱:monodevelop,代碼行數:26,代碼來源:CodeGenerationService.cs

示例5: CheckStartPoint

		static void CheckStartPoint (TextDocument doc, InsertionPoint point, bool isEndPoint)
		{
			DocumentLine 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).Length) {
					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 = NewLineInsertion.Eol;
			if (point.Location.Column < line.Length + 1)
				point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
		}
開發者ID:dodev,項目名稱:monodevelop,代碼行數:19,代碼來源:CodeGenerationService.cs

示例6: CheckEndPoint

		static void CheckEndPoint (TextDocument doc, InsertionPoint point, bool isStartPoint)
		{
			DocumentLine 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.Length + 1)
				point.LineAfter = NewLineInsertion.Eol;
		}
開發者ID:dodev,項目名稱:monodevelop,代碼行數:11,代碼來源:CodeGenerationService.cs

示例7: StripHeader

		static string StripHeader (string content)
		{
			var doc = new Mono.TextEditor.TextDocument (content);
			while (true) {
				string lineText = doc.GetLineText (1);
				if (lineText == null)
					break;
				if (lineText.StartsWith ("//")) {
					doc.Remove (doc.GetLine (1).SegmentIncludingDelimiter);
					continue;
				}
				break;
			}
			return doc.Text;
		}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:15,代碼來源:MoveTypeToFile.cs

示例8: StripDoubleBlankLines

		static string StripDoubleBlankLines (string content)
		{
			var doc = new Mono.TextEditor.TextDocument (content);
			for (int i = 1; i + 1 <= doc.LineCount; i++) {
				if (IsBlankLine (doc, i) && IsBlankLine (doc, i + 1)) {
					doc.Remove (doc.GetLine (i).SegmentIncludingDelimiter);
					i--;
					continue;
				}
			}
			return doc.Text;
		}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:12,代碼來源:MoveTypeToFile.cs

示例9: IsBlankLine

		static bool IsBlankLine (TextDocument doc, int i)
		{
			var line = doc.GetLine (i);
			return line.Length == line.GetIndentation (doc).Length;
		}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:5,代碼來源:MoveTypeToFile.cs

示例10: FormatMessage

		internal static string FormatMessage (string msg)
		{
			StringBuilder sb = new StringBuilder ();
			bool wasWs = false;
			foreach (char ch in msg) {
				if (ch == ' ' || ch == '\t') {
					if (!wasWs)
						sb.Append (' ');
					wasWs = true;
					continue;
				}
				wasWs = false;
				sb.Append (ch);
			}
			
			var doc = new TextDocument ();
			doc.Text = sb.ToString ();
			for (int i = 1; i <= doc.LineCount; i++) {
				string text = doc.GetLineText (i).Trim ();
				int idx = text.IndexOf (':');
				if (text.StartsWith ("*") && idx >= 0 && idx < text.Length - 1) {
					int offset = doc.GetLine (i).EndOffsetIncludingDelimiter;
					msg = text.Substring (idx + 1) + doc.GetTextAt (offset, doc.TextLength - offset);
					break;
				}
			}
			return msg.TrimStart (' ', '\t');
		}
開發者ID:halleyxu,項目名稱:monodevelop,代碼行數:28,代碼來源:BlameWidget.cs

示例11: UrlTextLineMarker

		public UrlTextLineMarker (TextDocument doc, IDocumentLine line, string url, Mono.TextEditor.UrlType urlType, string style, int startColumn, int endColumn) : base (doc, doc.GetLine (line.LineNumber), url, urlType, style, startColumn, endColumn)
		{
			if (doc == null)
				throw new ArgumentNullException ("doc");
			this.line = line;
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:6,代碼來源:UrlTextLineMarker.cs


注:本文中的Mono.TextEditor.TextDocument.GetLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。