• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDocumentLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDocumentLine的典型用法代码示例。如果您正苦于以下问题:C# IDocumentLine类的具体用法?C# IDocumentLine怎么用?C# IDocumentLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDocumentLine类属于命名空间,在下文中一共展示了IDocumentLine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			LineIndenter indenter = CreateLineIndenter(editor, line);
			if (!indenter.Indent()) {
				base.IndentLine(editor, line);
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:7,代码来源:ScriptingFormattingStrategy.cs


示例2: ModifyLineIndent

		void ModifyLineIndent(ITextEditor editor, IDocumentLine line, bool increaseIndent)
		{
			string indentation = GetLineIndentation(editor, line.LineNumber - 1);
			indentation = GetNewLineIndentation(indentation, editor.Options.IndentationString, increaseIndent);
			string newIndentedText = indentation + line.Text;
			editor.Document.Replace(line.Offset, line.Length, newIndentedText);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:PythonFormattingStrategy.cs


示例3: SmartReplaceLine

		/// <summary>
		/// Replaces the text in a line.
		/// If only whitespace at the beginning and end of the line was changed, this method
		/// only adjusts the whitespace and doesn't replace the other text.
		/// </summary>
		public static void SmartReplaceLine(this IDocument document, IDocumentLine line, string newLineText)
		{
			if (document == null)
				throw new ArgumentNullException("document");
			if (line == null)
				throw new ArgumentNullException("line");
			if (newLineText == null)
				throw new ArgumentNullException("newLineText");
			string newLineTextTrim = newLineText.Trim(whitespaceChars);
			string oldLineText = line.Text;
			if (oldLineText == newLineText)
				return;
			int pos = oldLineText.IndexOf(newLineTextTrim, StringComparison.Ordinal);
			if (newLineTextTrim.Length > 0 && pos >= 0) {
				using (document.OpenUndoGroup()) {
					// find whitespace at beginning
					int startWhitespaceLength = 0;
					while (startWhitespaceLength < newLineText.Length) {
						char c = newLineText[startWhitespaceLength];
						if (c != ' ' && c != '\t')
							break;
						startWhitespaceLength++;
					}
					// find whitespace at end
					int endWhitespaceLength = newLineText.Length - newLineTextTrim.Length - startWhitespaceLength;
					
					// replace whitespace sections
					int lineOffset = line.Offset;
					document.Replace(lineOffset + pos + newLineTextTrim.Length, line.Length - pos - newLineTextTrim.Length, newLineText.Substring(newLineText.Length - endWhitespaceLength));
					document.Replace(lineOffset, pos, newLineText.Substring(0, startWhitespaceLength));
				}
			} else {
				document.Replace(line.Offset, line.Length, newLineText);
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:40,代码来源:DocumentUtilitites.cs


示例4: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			if (line.LineNumber == 1) {
				base.IndentLine(editor, line);
				return;
			}
			
			IDocument document = editor.Document;
			IDocumentLine previousLine = document.GetLine(line.LineNumber - 1);
			string previousLineText = previousLine.Text.Trim();
			
			if (previousLineText.EndsWith(":")) {
				IncreaseLineIndent(editor, line);
			} else if (previousLineText == "pass") {
				DecreaseLineIndent(editor, line);
			} else if ((previousLineText == "return") || (previousLineText.StartsWith("return "))) {
				DecreaseLineIndent(editor, line);
			} else if ((previousLineText == "raise") || (previousLineText.StartsWith("raise "))) {
				DecreaseLineIndent(editor, line);
			} else if (previousLineText == "break") {
				DecreaseLineIndent(editor, line);
			} else {
				base.IndentLine(editor, line);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:25,代码来源:PythonFormattingStrategy.cs


示例5: IsBracketOnly

 bool IsBracketOnly(IDocument document, IDocumentLine documentLine)
 {
     string lineText = document.GetText(documentLine).Trim();
     return lineText == "{" || string.IsNullOrEmpty(lineText)
         || lineText.StartsWith("//", StringComparison.Ordinal)
         || lineText.StartsWith("/*", StringComparison.Ordinal)
         || lineText.StartsWith("*", StringComparison.Ordinal)
         || lineText.StartsWith("'", StringComparison.Ordinal);
 }
开发者ID:123marvin123,项目名称:PawnPlus,代码行数:9,代码来源:BracketSearcher.cs


示例6: RubyLineIndenter

		public RubyLineIndenter(ITextEditor editor, IDocumentLine line)
			: base(editor, line)
		{
			CreateDecreaseLineIndentStatements();
			CreateDecreaseLineIndentStartsWithStatements();
			CreateIncreaseLineIndentStatements();
			CreateIncreaseLineIndentStartsWithStatements();
			CreateIncreaseLineIndentEndsWithStatements();
			CreateIncreaseLineIndentContainsStatements();
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:10,代码来源:RubyLineIndenter.cs


示例7: ScanLine

		/// <summary>
		/// Updates <see cref="CurrentSpanStack"/> for the specified line in the specified document.
		/// 
		/// Before calling this method, <see cref="CurrentSpanStack"/> must be set to the proper
		/// state for the beginning of this line. After highlighting has completed,
		/// <see cref="CurrentSpanStack"/> will be updated to represent the state after the line.
		/// </summary>
		public void ScanLine(IDocument document, IDocumentLine line)
		{
			//this.lineStartOffset = line.Offset; not necessary for scanning
			this.lineText = document.GetText(line);
			try {
				Debug.Assert(highlightedLine == null);
				HighlightLineInternal();
			} finally {
				this.lineText = null;
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:18,代码来源:HighlightingEngine.cs


示例8: IndentSingleLine

		static void IndentSingleLine(CacheIndentEngine engine, IDocument document, IDocumentLine line)
		{
			engine.Update(line.EndOffset);
			if (engine.NeedsReindent) {
				var indentation = TextUtilities.GetWhitespaceAfter(document, line.Offset);
				// replacing the indentation in two steps is necessary to make the caret move accordingly.
				document.Replace(indentation.Offset, indentation.Length, "");
				document.Replace(indentation.Offset, 0, engine.ThisLineIndent);
				engine.ResetEngineToPosition(line.Offset);
			}
		}
开发者ID:krunalc,项目名称:SharpDevelop,代码行数:11,代码来源:CSharpFormattingStrategy.cs


示例9: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			editor.Document.StartUndoableAction();
			try {
				TryIndent(editor, line.LineNumber, line.LineNumber);
			} catch (XmlException ex) {
				LoggingService.Debug(ex.ToString());
			} finally {
				editor.Document.EndUndoableAction();
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:11,代码来源:XmlFormattingStrategy.cs


示例10: IndentLine

		public virtual void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			IDocument document = editor.Document;
			int lineNumber = line.LineNumber;
			if (lineNumber > 1) {
				IDocumentLine previousLine = document.GetLineByNumber(lineNumber - 1);
				string indentation = DocumentUtilities.GetWhitespaceAfter(document, previousLine.Offset);
				// copy indentation to line
				string newIndentation = DocumentUtilities.GetWhitespaceAfter(document, line.Offset);
				document.Replace(line.Offset, newIndentation.Length, indentation);
			}
		}
开发者ID:nataviva,项目名称:SharpDevelop-1,代码行数:12,代码来源:IFormattingStrategy.cs


示例11: IsInsideDocumentationComment

		public static bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset)
		{
			for (int i = curLine.Offset; i < cursorOffset; ++i) {
				char ch = editor.Document.GetCharAt(i);
				if (ch == '"')
					return false;
				if (ch == '\'' && i + 2 < cursorOffset && editor.Document.GetCharAt(i + 1) == '\'' &&
				    editor.Document.GetCharAt(i + 2) == '\'')
					return true;
			}
			return false;
		}
开发者ID:kleinux,项目名称:SharpDevelop,代码行数:12,代码来源:LanguageUtils.cs


示例12: HighlightLine

		/// <summary>
		/// Highlights the specified line in the specified document.
		/// 
		/// Before calling this method, <see cref="CurrentSpanStack"/> must be set to the proper
		/// state for the beginning of this line. After highlighting has completed,
		/// <see cref="CurrentSpanStack"/> will be updated to represent the state after the line.
		/// </summary>
		public HighlightedLine HighlightLine(IDocument document, IDocumentLine line)
		{
			this.lineStartOffset = line.Offset;
			this.lineText = document.GetText(line);
			try {
				this.highlightedLine = new HighlightedLine(document, line);
				HighlightLineInternal();
				return this.highlightedLine;
			} finally {
				this.highlightedLine = null;
				this.lineText = null;
				this.lineStartOffset = 0;
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:21,代码来源:HighlightingEngine.cs


示例13: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			int lineNr = line.LineNumber;
			DocumentAccessor acc = new DocumentAccessor(editor.Document, lineNr, lineNr);
			
			CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
			indentStrategy.IndentationString = editor.Options.IndentationString;
			indentStrategy.Indent(acc, false);
			
			string t = acc.Text;
			if (t.Length == 0) {
				// use AutoIndentation for new lines in comments / verbatim strings.
				base.IndentLine(editor, line);
			}
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:15,代码来源:CSharpFormattingStrategy.cs


示例14: IndentLine

        public override void IndentLine(ITextEditor editor, IDocumentLine line)
        {
            if (line.LineNumber > 1)
            {
                IDocumentLine above = editor.Document.GetLine(line.LineNumber - 1);
                string up = above.Text.Trim();
                if (up.StartsWith("--") == false)
                {
                    // above line is an indent statement
                    if (up.EndsWith("do")
                        || up.EndsWith("then")
                        || (up.StartsWith("function") && up.EndsWith(")"))
                        || (up.Contains("function") && up.EndsWith(")"))) // e.g. aTable.x = function([...])
                    {
                        string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, above.Offset);
                        string newLine = line.Text.TrimStart();
                        newLine = indentation + editor.Options.IndentationString + newLine;
                        editor.Document.SmartReplaceLine(line, newLine);
                    }
                    else // above line is not an indent statement
                    {
                        string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, above.Offset);
                        string newLine = line.Text.TrimStart();
                        newLine = indentation + newLine;
                        editor.Document.SmartReplaceLine(line, newLine);
                    }
                }

                if (line.Text.StartsWith("end"))
                {
                    string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, above.Offset);
                    string newLine = line.Text.TrimStart();
                    string newIndent = "";

                    if (indentation.Length >= editor.Options.IndentationSize)
                        newIndent = indentation.Substring(0, indentation.Length - editor.Options.IndentationSize);

                    newLine = newIndent + newLine;
                    editor.Document.SmartReplaceLine(line, newLine);
                }
            }
            else
            {

            }
            //base.IndentLine(editor, line);
        }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:47,代码来源:SharpLuaFormattingStrategy.cs


示例15: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			IDocument document = editor.Document;
			int lineNumber = line.LineNumber;
			if (lineNumber > 1) {
				IDocumentLine previousLine = document.GetLine(line.LineNumber - 1);
				
				if (previousLine.Text.EndsWith(":", StringComparison.Ordinal)) {
					string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset);
					indentation += editor.Options.IndentationString;
					string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset);
					document.Replace(line.Offset, newIndentation.Length, indentation);
					return;
				}
			}
			base.IndentLine(editor, line);
		}
开发者ID:dondublon,项目名称:SharpDevelop,代码行数:17,代码来源:FormattingStrategy.cs


示例16: Init

		public void Init()
		{
			formattingStrategy = new XmlFormattingStrategy();
			
			options = new MockTextEditorOptions();
			textEditor = new MockTextEditor();
			textEditor.Options = options;
			
			textDocument = new TextDocument();
			document = textDocument;
			textEditor.SetDocument(document);
			
			document.Text = 
				"<root>\r\n" +
				"\t<child>\r\n" +
				"</child>\r\n" +
				"</root>\r\n";
			
			docLine = MockRepository.GenerateStub<IDocumentLine>();
			docLine.Stub(l => l.LineNumber).Return(3);
			formattingStrategy.IndentLine(textEditor, docLine);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:22,代码来源:IndentChildElementEndTagAfterNewLineTypedTestFixture.cs


示例17: DoInsertionOnLine

		void DoInsertionOnLine(string terminator, IDocumentLine currentLine, IDocumentLine lineAbove, string textToReplace, ITextEditor editor, int lineNr)
		{
			string curLineText = currentLine.Text;
			
			if (Regex.IsMatch(textToReplace.Trim(), "^If .*[^_]$", RegexOptions.IgnoreCase)) {
				if (!Regex.IsMatch(textToReplace, "\\bthen\\b", RegexOptions.IgnoreCase)) {
					string specialThen = "Then"; // do special check in cases like If t = True' comment
					if (editor.Document.GetCharAt(lineAbove.Offset + textToReplace.Length) == '\'')
						specialThen += " ";
					if (editor.Document.GetCharAt(lineAbove.Offset + textToReplace.Length - 1) != ' ')
						specialThen = " " + specialThen;
					editor.Document.Insert(lineAbove.Offset + textToReplace.Length, specialThen);
					textToReplace += specialThen;
				}
			}
			
			// check #Region statements
			if (Regex.IsMatch(textToReplace.Trim(), "^#Region", RegexOptions.IgnoreCase) && LookForEndRegion(editor)) {
				string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
				textToReplace += indentation + "\r\n" + indentation + "#End Region";
				editor.Document.Replace(currentLine.Offset, currentLine.Length, textToReplace);
			}
			
			foreach (VBStatement statement_ in statements) {
				VBStatement statement = statement_;	// allow passing statement byref
				if (Regex.IsMatch(textToReplace.Trim(), statement.StartRegex, RegexOptions.IgnoreCase)) {
					string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
					if (IsEndStatementNeeded(editor, ref statement, lineNr)) {
						editor.Document.Replace(currentLine.Offset, currentLine.Length, terminator + indentation + statement.EndStatement);
					}
					if (!IsInsideInterface(editor, lineNr) || statement == interfaceStatement) {
						for (int i = 0; i < statement.IndentPlus; i++) {
							indentation += editor.Options.IndentationString;
						}
					}
					editor.Document.Replace(currentLine.Offset, currentLine.Length, indentation + curLineText.Trim());
					editor.Caret.Line = currentLine.LineNumber;
					editor.Caret.Column = indentation.Length;
					return;
				}
			}
		}
开发者ID:siegfriedpammer,项目名称:SharpDevelop,代码行数:42,代码来源:VBNetFormattingStrategy.cs


示例18: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			var document = editor.Document;
			var engine = CreateIndentEngine(document, editor.ToEditorOptions());
			IndentSingleLine(engine, document, line);
		}
开发者ID:krunalc,项目名称:SharpDevelop,代码行数:6,代码来源:CSharpFormattingStrategy.cs


示例19: GuessSemicolonInsertionOffset

		public static bool GuessSemicolonInsertionOffset (TextEditorData data, IDocumentLine curLine, int caretOffset, out int outOffset)
		{
			int lastNonWsOffset = caretOffset;
			char lastNonWsChar = '\0';
			outOffset = caretOffset;
			int max = curLine.EndOffset;
	//		if (caretOffset - 2 >= curLine.Offset && data.Document.GetCharAt (caretOffset - 2) == ')' && !IsSemicolonalreadyPlaced (data, caretOffset))
	//			return false;

			int end = caretOffset;
			while (end > 1 && char.IsWhiteSpace (data.GetCharAt (end)))
				end--;
			int end2 = end;
			while (end2 > 1 && char.IsLetter(data.GetCharAt (end2 - 1)))
				end2--;
			if (end != end2) {
				string token = data.GetTextBetween (end2, end + 1);
				// guess property context
				if (token == "get" || token == "set")
					return false;
			}

			bool isInString = false , isInChar= false , isVerbatimString= false;
			bool isInLineComment = false , isInBlockComment= false;
			bool firstChar = true;
			for (int pos = caretOffset; pos < max; pos++) {
				if (pos == caretOffset) {
					if (isInString || isInChar || isVerbatimString || isInLineComment || isInBlockComment) {
						outOffset = pos;
						return true;
					}
				}
				char ch = data.Document.GetCharAt (pos);
				switch (ch) {
				case '}':
					if (firstChar && !IsSemicolonalreadyPlaced (data, caretOffset))
						return false;
					break;
				case '/':
					if (isInBlockComment) {
						if (pos > 0 && data.Document.GetCharAt (pos - 1) == '*') 
							isInBlockComment = false;
					} else if (!isInString && !isInChar && pos + 1 < max) {
						char nextChar = data.Document.GetCharAt (pos + 1);
						if (nextChar == '/') {
							outOffset = lastNonWsOffset;
							return true;
						}
						if (!isInLineComment && nextChar == '*') {
							outOffset = lastNonWsOffset;
							return true;
						}
					}
					break;
				case '\\':
					if (isInChar || (isInString && !isVerbatimString))
						pos++;
					break;
				case '@':
					if (!(isInString || isInChar || isInLineComment || isInBlockComment) && pos + 1 < max && data.Document.GetCharAt (pos + 1) == '"') {
						isInString = true;
						isVerbatimString = true;
						pos++;
					}
					break;
				case '"':
					if (!(isInChar || isInLineComment || isInBlockComment)) {
						if (isInString && isVerbatimString && pos + 1 < max && data.Document.GetCharAt (pos + 1) == '"') {
							pos++;
						} else {
							isInString = !isInString;
							isVerbatimString = false;
						}
					}
					break;
				case '\'':
					if (!(isInString || isInLineComment || isInBlockComment)) 
						isInChar = !isInChar;
					break;
				}
				if (!char.IsWhiteSpace (ch)) {
					firstChar = false;
					lastNonWsOffset = pos;
					lastNonWsChar = ch;
				}
			}
			// if the line ends with ';' the line end is not the correct place for a new semicolon.
			if (lastNonWsChar == ';')
				return false;
			outOffset = lastNonWsOffset;
			return true;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:92,代码来源:CSharpTextEditorIndentation.cs


示例20: UrlTextLineMarker

		IUrlTextLineMarker ITextMarkerFactory.CreateUrlTextMarker (MonoDevelop.Ide.Editor.TextEditor editor, IDocumentLine line, string value, MonoDevelop.Ide.Editor.UrlType url, string syntax, int startCol, int endCol)
		{
			return new UrlTextLineMarker (TextEditor.Document, line, value, (Mono.TextEditor.UrlType)url, syntax, startCol, endCol);
		}
开发者ID:stephenoakman,项目名称:monodevelop,代码行数:4,代码来源:SourceEditorView.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDocumentService类代码示例发布时间:2022-05-24
下一篇:
C# IDocumentAccessor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap