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


C# IDocument.GetLineSegment方法代码示例

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


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

示例1: GenerateFoldMarkers

        /// <summary>
        /// Generates the foldings for our document.
        /// </summary>
        /// <param name="document">The current document.</param>
        /// <param name="fileName">The filename of the document.</param>
        /// <param name="parseInformation">Extra parse information, not used in this sample.</param>
        /// <returns>A list of FoldMarkers.</returns>
        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> list = new List<FoldMarker>();

            Stack<int> startLines = new Stack<int>();

            // Create foldmarkers for the whole document, enumerate through every line.
            for (int i = 0; i < document.TotalNumberOfLines; i++)
            {
                LineSegment seg = document.GetLineSegment(i);
                int offs, end = document.TextLength;
                char c;
                for (offs = seg.Offset; offs < end && ((c = document.GetCharAt(offs)) == ' ' || c == '\t'); offs++)
                { }
                if (offs == end)
                    break;
                int spaceCount = offs - seg.Offset;

                // now offs points to the first non-whitespace char on the line
                if (document.GetCharAt(offs) == '#')
                {
                    string text = document.GetText(offs, seg.Length - spaceCount);
                    if (text.StartsWith("#region"))
                        startLines.Push(i);
                    if (text.StartsWith("#endregion") && startLines.Count > 0)
                    {
                        // Add a new FoldMarker to the list.
                        int start = startLines.Pop();
                        list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, spaceCount + "#endregion".Length));
                    }
                }
            }

            return list;
        }
开发者ID:276398084,项目名称:KW.OrderManagerSystem,代码行数:42,代码来源:RegionFoldingStrategy.cs

示例2: GenerateFoldMarkers

        /// <summary>
        /// Generates the foldings for our document.
        /// </summary>
        /// <param name="document">The current document.</param>
        /// <param name="fileNameEx">The filename of the document.</param>
        /// <param name="parseInformation">Extra parse information, not used in this sample.</param>
        /// <returns>A list of FoldMarkers.</returns>
        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> list = new List<FoldMarker>();

            int start = 0;

            // Create foldmarkers for the whole document, enumerate through every line.
            for (int i = 0; i < document.TotalNumberOfLines; i++)
            {
                // Get the text of current line.
                string text = document.GetText(document.GetLineSegment(i));

                if (text.StartsWith("#region")) // Look for method starts
                    start = i;
                if (text.StartsWith("#endregion")) // Look for method endings
                    // Add a new FoldMarker to the list.
                    // document = the current document
                    // start = the start line for the FoldMarker
                    // document.GetLineSegment(start).Length = the ending of the current line = the start column of our foldmarker.
                    // i = The current line = end line of the FoldMarker.
                    // 7 = The end column
                    list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 7));
            }

            return list;
        }
开发者ID:ysmood,项目名称:Archer,代码行数:33,代码来源:MyFoldStrategy.cs

示例3: GenerateFoldMarkers

        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> list = new List<FoldMarker>();

            string name = string.Empty;
            int start = 0;
            int startindex = 0;

            for (int i = 0; i < document.TotalNumberOfLines; i++)
            {
                string text = document.GetText(document.GetLineSegment(i));

                Match startmatch = startrxp.Match(text);
                if (startmatch.Success)
                {
                    name = startmatch.Groups[gpname].Value;
                    startindex = startmatch.Groups[gpregion].Index - 1;
                    start = i;
                }
                else if (endrxp.IsMatch(text))
                {
                    list.Add(new FoldMarker(document, start, startindex, i, document.GetLineSegment(i).Length, FoldType.Region, name, true));
                }
            }

            return list;
        }
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:27,代码来源:RegionFoldingStrategy.cs

示例4: SetPosition

		public static void SetPosition(string fileName, IDocument document, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn)
		{
			Remove();
			
			startLine   = makerStartLine;
			startColumn = makerStartColumn;
			endLine     = makerEndLine;
			endColumn   = makerEndColumn;
			
			if (startLine < 1 || startLine > document.TotalNumberOfLines)
				return;
			if (endLine < 1 || endLine > document.TotalNumberOfLines) {
				endLine = startLine;
				endColumn = int.MaxValue;
			}
			if (startColumn < 1)
				startColumn = 1;
			
			LineSegment line = document.GetLineSegment(startLine - 1);
			if (endColumn < 1 || endColumn > line.Length)
				endColumn = line.Length;
			instance = new CurrentLineBookmark(fileName, document, new TextLocation(startColumn - 1, startLine - 1));
			document.BookmarkManager.AddMark(instance);
			document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine - 1, endLine - 1));
			document.CommitUpdate();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:26,代码来源:CurrentLineBookmark.cs

示例5: GenerateFoldMarker

        /// <remarks>
        /// Calculates the fold level of a specific line.
        /// </remarks>
        public int GenerateFoldMarker(IDocument document, int lineNumber)
        {
            LineSegment line = document.GetLineSegment(lineNumber);
            int foldLevel = 0;

            while (document.GetCharAt(line.Offset + foldLevel) == '\t' && foldLevel + 1  < line.TotalLength) {
                ++foldLevel;
            }

            return foldLevel;
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:14,代码来源:IndentFoldingStrategy.cs

示例6: Resolve

		/// <summary>
		/// Attempts to resolve a reference to a resource.
		/// </summary>
		/// <param name="fileName">The name of the file that contains the expression to be resolved.</param>
		/// <param name="document">The document that contains the expression to be resolved.</param>
		/// <param name="caretLine">The 0-based line in the file that contains the expression to be resolved.</param>
		/// <param name="caretColumn">The 0-based column position of the expression to be resolved.</param>
		/// <param name="charTyped">The character that has been typed at the caret position but is not yet in the buffer (this is used when invoked from code completion), or <c>null</c>.</param>
		/// <returns>A <see cref="ResourceResolveResult"/> that describes which resource is referenced by the expression at the specified position in the specified file, or <c>null</c> if that expression does not reference a (known) resource or if the specified position is invalid.</returns>
		public ResourceResolveResult Resolve(string fileName, IDocument document, int caretLine, int caretColumn, char? charTyped)
		{
			if (fileName == null || document == null) {
				LoggingService.Debug("ResourceToolkit: "+this.GetType().ToString()+".Resolve called with null fileName or document argument");
				return null;
			}
			if (caretLine < 0 || caretColumn < 0 || caretLine >= document.TotalNumberOfLines || caretColumn >= document.GetLineSegment(caretLine).TotalLength) {
				LoggingService.Debug("ResourceToolkit: "+this.GetType().ToString()+".Resolve called with invalid position arguments");
				return null;
			}
			return this.Resolve(fileName, document, caretLine, caretColumn, document.PositionToOffset(new TextLocation(caretColumn, caretLine)), charTyped);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:21,代码来源:AbstractResourceResolver.cs

示例7: GetPointForOffset

		static void GetPointForOffset(IDocument document, int offset, out int line, out int column) {
			if (offset > document.TextLength) {
				line = document.TotalNumberOfLines + 1;
				column = 1;
			} else if (offset < 0) {
				line = -1;
				column = -1;
			} else {
				line = document.GetLineNumberForOffset(offset);
				column = offset - document.GetLineSegment(line).Offset;
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:12,代码来源:FoldMarker.cs

示例8: AddFold

 /// <summary>
 /// Adds a fold for the specified tag spanning the specified lines.
 /// </summary>
 /// <remarks>
 /// This method is called by the <see cref="XmlParser"/> whenever a complete tag is found.
 /// </remarks>
 /// <param name="p_docDocument">The document in which to make the fold.</param>
 /// <param name="p_strTagName">The name of the tag being folded.</param>
 /// <param name="p_tlcStart">The location of the start of the tag.</param>
 /// <param name="p_tlcEnd">The location of the closing tag.</param>
 protected void AddFold(IDocument p_docDocument, string p_strTagName, TextLocation p_tlcStart, TextLocation p_tlcEnd)
 {
     if (p_tlcStart.Line == p_tlcEnd.Line)
         return;
     string strStartLine = p_docDocument.GetText(p_docDocument.GetLineSegment(p_tlcStart.Line));
     Int32 intStartFoldPos = strStartLine.IndexOf(">", p_tlcStart.Column);
     if (intStartFoldPos < 0)
         intStartFoldPos = strStartLine.Length;
     else
         intStartFoldPos++;
     m_lstFolds.Add(new FoldMarker(p_docDocument, p_tlcStart.Line, intStartFoldPos, p_tlcEnd.Line, p_tlcEnd.Column - 1));
 }
开发者ID:BioBrainX,项目名称:fomm,代码行数:22,代码来源:XmlFoldingStrategy.cs

示例9: FoldMarker

        public FoldMarker(IDocument document, int startLine, int startColumn, int endLine, int endColumn, FoldType foldType, string foldText, bool isFolded)
        {
            this.document = document;

            startLine = Math.Min(document.TotalNumberOfLines - 1, Math.Max(startLine, 0));
            ISegment startLineSegment = document.GetLineSegment(startLine);

            endLine = Math.Min(document.TotalNumberOfLines - 1, Math.Max(endLine, 0));
            ISegment endLineSegment   = document.GetLineSegment(endLine);

            // Prevent the region from completely disappearing
            if (string.IsNullOrEmpty(foldText)) {
                foldText = "...";
            }

            this.FoldType = foldType;
            this.foldText = foldText;
            this.offset = startLineSegment.Offset + Math.Min(startColumn, startLineSegment.Length);
            this.length = (endLineSegment.Offset + Math.Min(endColumn, endLineSegment.Length)) - this.offset;
            this.isFolded = isFolded;
        }
开发者ID:umabiel,项目名称:WsdlUI,代码行数:21,代码来源:FoldMarker.cs

示例10: Convert

		protected override void Convert(IDocument document, int y1, int y2) 
		{
			for (int i = y2 - 1; i >= y1; --i) {
				LineSegment line = document.GetLineSegment(i);
				int removeNumber = 0;
				for (int x = line.Offset + line.Length - 1; x >= line.Offset && Char.IsWhiteSpace(document.GetCharAt(x)); --x) {
					++removeNumber;
				}
				if (removeNumber > 0) {
					document.Remove(line.Offset + line.Length - removeNumber, removeNumber);
				}
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:13,代码来源:FormatActions.cs

示例11: GenerateFoldMarkers

        /// <summary>
        /// Generates the list of markers indicating where the XML should be folded.
        /// </summary>
        /// <param name="document">The document to fold.</param>
        /// <param name="fileName">The file name of the document to fold.</param>
        /// <param name="parseInformation">User-supplied parse information.</param>
        /// <returns>The list of markers indicating where the code should be folded.</returns>
        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> list = new List<FoldMarker>();

            Stack<int> stack = new Stack<int>();
            //bool InComment;

            for (int i = 0; i < document.TotalNumberOfLines; i++)
            {
                string text = document.GetText(document.GetLineSegment(i)).Trim();
                if (text.StartsWith("}") && stack.Count > 0)
                {
                    int pos = stack.Pop();
                    list.Add(new FoldMarker(document, pos, document.GetLineSegment(pos).Length, i, 1));
                }
                if (text.EndsWith("{"))
                {
                    stack.Push(i);
                }
            }

            return list;
        }
开发者ID:BioBrainX,项目名称:fomm,代码行数:30,代码来源:CodeFoldingStrategy.cs

示例12: SetPosition

		public static void SetPosition(string fileName, IDocument document, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn)
		{
			Remove();
			
			startLine   = makerStartLine;
			startColumn = makerStartColumn;
			endLine     = makerEndLine;
			endColumn   = makerEndColumn;
			
			LineSegment line = document.GetLineSegment(startLine - 1);
			instance = new CurrentLineBookmark(fileName, document, startLine - 1);
			document.BookmarkManager.AddMark(instance);
			document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine - 1, endLine - 1));
			document.CommitUpdate();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:15,代码来源:CurrentLineBookmark.cs

示例13: InsertTabs

		void InsertTabs(IDocument document, ISelection selection, int y1, int y2)
		{
			string indentationString = GetIndentationString(document);
			for (int i = y2; i >= y1; --i) {
				LineSegment line = document.GetLineSegment(i);
				if (i == y2 && i == selection.EndPosition.Y && selection.EndPosition.X  == 0) {
					continue;
				}
				
				// this bit is optional - but useful if you are using block tabbing to sort out
				// a source file with a mixture of tabs and spaces
//				string newLine = document.GetText(line.Offset,line.Length);
//				document.Replace(line.Offset,line.Length,newLine);
				
				document.Insert(line.Offset, indentationString);
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:17,代码来源:MiscActions.cs

示例14: InsertTabs

		void InsertTabs(IDocument document, ISelection selection, int y1, int y2)
		{
			int    redocounter = 0;
			string indentationString = GetIndentationString(document);
			for (int i = y2; i >= y1; --i) {
				LineSegment line = document.GetLineSegment(i);
				if (i == y2 && i == selection.EndPosition.Y && selection.EndPosition.X  == 0) {
					continue;
				}
				
				document.Insert(line.Offset, indentationString);
				++redocounter;
			}
			
			if (redocounter > 0) {
				document.UndoStack.UndoLast(redocounter); // redo the whole operation (not the single deletes)
			}
		}
开发者ID:tangxuehua,项目名称:DataStructure,代码行数:18,代码来源:MiscActions.cs

示例15: Convert

		protected override void Convert(IDocument document, int y1, int y2) 
		{
			int  redocounter = 0; // must count how many Delete operations occur
			for (int i = y2 - 1; i >= y1; --i) {
				LineSegment line = document.GetLineSegment(i);
				int removeNumber = 0;
				for (int x = line.Offset + line.Length - 1; x >= line.Offset && Char.IsWhiteSpace(document.GetCharAt(x)); --x) {
					++removeNumber;
				}
				if (removeNumber > 0) {
					document.Remove(line.Offset + line.Length - removeNumber, removeNumber);
					++redocounter;         // count deletes
				}
			}
			if (redocounter > 0) {
				document.UndoStack.CombineLast(redocounter); // redo the whole operation (not the single deletes)
			}
		}
开发者ID:stophun,项目名称:fdotoolbox,代码行数:18,代码来源:FormatActions.cs


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