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


C# Document.GetCharAt方法代码示例

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


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

示例1: FindNextWordOffset

		/// <summary>
		/// Move past next whitespace group.
		/// </summary>
		public override int FindNextWordOffset (Document doc, int offset)
		{
			int myoffset = offset;
			if (0 > myoffset || doc.Length-1 <= myoffset){ return myoffset; }
			
			for (char c = doc.GetCharAt (myoffset);
			     !char.IsWhiteSpace (c) && 0 <= myoffset && doc.Length-1 > myoffset;
			     c = doc.GetCharAt (++myoffset));
			for (char c = doc.GetCharAt (myoffset);
			     char.IsWhiteSpace (c) && 0 <= myoffset && doc.Length-1 > myoffset;
			     c = doc.GetCharAt (++myoffset));
			     
			return (myoffset == offset)? myoffset+1: myoffset;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:17,代码来源:ViWordFindStrategy.cs

示例2: BreakLinesIntoWords

		/// <summary>
		/// Breaks the lines into words in the form of a list of <see cref="ISegment">ISegments</see>. A 'word' is defined as an identifier (a series of letters, digits or underscores)
		/// or a single non-identifier character (including white space characters)
		/// </summary>
		/// <returns>
		/// The list of segments representing the 'words' in the lines
		/// </returns>
		/// <param name='document'>
		/// The document to get the words from
		/// </param>
		/// <param name='startLine'>
		/// The first line in the documents to get the words from
		/// </param>
		/// <param name='lineCount'>
		/// The number of lines to get words from
		/// </param>
		public static List<ISegment> BreakLinesIntoWords (Document document, int startLine, int lineCount)
		{
			var result = new List<ISegment> ();
			for (int line = startLine; line < startLine + lineCount; line++) {
				var lineSegment = document.GetLine (line);
				int offset = lineSegment.Offset;
				bool wasIdentifierPart = false;
				int lastWordEnd = 0;
				for (int i = 0; i < lineSegment.EditableLength; i++) {
					char ch = document.GetCharAt (offset + i);
					bool isIdentifierPart = char.IsLetterOrDigit (ch) || ch == '_';
					if (!isIdentifierPart) {
						if (wasIdentifierPart) {
							result.Add (new Mono.TextEditor.Segment (offset + lastWordEnd, i - lastWordEnd));
						}
						result.Add (new Mono.TextEditor.Segment (offset + i, 1));
						lastWordEnd = i + 1;
					}
					wasIdentifierPart = isIdentifierPart;
				}
				
				if (lastWordEnd != lineSegment.EditableLength) {
					result.Add (new Mono.TextEditor.Segment (offset + lastWordEnd, lineSegment.EditableLength - lastWordEnd));
				}
			}
			
			return result;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:44,代码来源:TextBreaker.cs

示例3: FindNextSubwordOffset

		/// <summary>
		/// Move to next non-whitespace change in character class.
		/// </summary>
		public override int FindNextSubwordOffset (Document doc, int offset)
		{
			int myoffset = offset;
			if (0 > myoffset || doc.Length-1 <= myoffset){ return myoffset; }
			
			char c = doc.GetCharAt (myoffset);
			CharacterClass initialClass = GetCharacterClass (c);
			
			while (GetCharacterClass (c) == initialClass && 0 <= myoffset && doc.Length-1 > myoffset) {
				c = doc.GetCharAt (++myoffset);
			}
			for (c = doc.GetCharAt (myoffset);
			     char.IsWhiteSpace (c) && 0 <= myoffset && doc.Length-1 > myoffset;
			     c = doc.GetCharAt (++myoffset));
			     
			return (myoffset == offset)? myoffset+1: myoffset;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:20,代码来源:ViWordFindStrategy.cs

示例4: GetFoldSegments

		static List<FoldSegment> GetFoldSegments (Document doc)
		{
			List<FoldSegment> result = new List<FoldSegment> ();
			Stack<FoldSegment> foldSegments = new Stack<FoldSegment> ();
			
			for (int i = 0; i < doc.Length - 1; ++i) {
				char ch = doc.GetCharAt (i);
				
				if ((ch == '+' || ch == '-') && doc.GetCharAt(i + 1) == '[') {
					FoldSegment segment = new FoldSegment (doc, "...", i, 0, FoldingType.None);
					segment.IsFolded = ch == '+';
					foldSegments.Push (segment);
				} else if (ch == ']' && foldSegments.Count > 0) {
					FoldSegment segment = foldSegments.Pop ();
					segment.Length = i - segment.Offset;
					result.Add (segment);
				}
			}
			return result;
		}
开发者ID:thild,项目名称:monodevelop,代码行数:20,代码来源:FoldingTests.cs

示例5: TryMatch

		public RegexMatch TryMatch (Document doc, int offset)
		{
			foreach (string pattern in patterns) {
				int curOffset = offset;
				bool match = true;
				for (int i = 0; i < pattern.Length; i++) {
					if (curOffset >= doc.Length) {
						match = false;
						break;
					}
					
					if (doc.GetCharAt (curOffset) != pattern[i]) {
						match = false;
						break;
					}
					curOffset++;
					
				}
				if (match) 
					return new RegexMatch (pattern.Length);
			}
			return RegexMatch.NoMatch;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:23,代码来源:Regex.cs

示例6: GetChunks

		public override Chunk GetChunks (Document doc, Style style, LineSegment line, int offset, int length)
		{
			int endOffset = System.Math.Min (offset + length, doc.Length);
			Stack<Tag> tagStack = new Stack<Tag> ();
			TextChunk curChunk = new TextChunk (new ChunkStyle (), offset);
			Chunk startChunk = curChunk;
			Chunk endChunk = curChunk;
			bool inTag = true, inSpecial = false;
			int specialBegin = -1;
			StringBuilder tagBuilder = new StringBuilder ();
			StringBuilder specialBuilder = new StringBuilder ();
			for (int i = offset; i < endOffset; i++) {
				char ch = doc.GetCharAt (i);
				switch (ch) {
				case '<':
					curChunk.Length = i - curChunk.Offset;
					if (curChunk.Length > 0) {
						curChunk.ChunkStyle = GetChunkStyle (style, tagStack);
						endChunk = endChunk.Next = curChunk;
						curChunk = new TextChunk (new ChunkStyle (), offset);
					}
					tagBuilder.Length = 0;
					specialBuilder.Length = 0;
					inTag = true;
					break;
				case '&':
					curChunk.Length = i - curChunk.Offset;
					if (curChunk.Length > 0) {
						curChunk.ChunkStyle = GetChunkStyle (style, tagStack);
						endChunk = endChunk.Next = curChunk;
						curChunk = new TextChunk (new ChunkStyle (), offset);
					}
					
					inSpecial = true;
					specialBuilder.Length = 0;
					tagBuilder.Length = 0;
					specialBegin = i;
					break;
				case ';':
					if (inSpecial) {
						string specialText = specialBuilder.ToString ();
						switch (specialText) {
						case "lt":
							endChunk = endChunk.Next = new TextChunk (GetChunkStyle (style, tagStack), specialBegin, "<");
							break;
						case "gt": 
							endChunk = endChunk.Next = new TextChunk (GetChunkStyle (style, tagStack), specialBegin, ">");
							break;
						case "amp": 
							endChunk = endChunk.Next = new TextChunk (GetChunkStyle (style, tagStack), specialBegin, "&");
							break;
						}
						curChunk.Offset = i + 1;
						inSpecial = false;
						specialBuilder.Length = 0;
						tagBuilder.Length = 0;
					}
					break;
				case '>':
					if (!inTag)
						break;
					string tagText = tagBuilder.ToString ();
					tagBuilder.Length = 0;
					if (tagText.StartsWith ("/")) {
						if (tagStack.Count > 0)
							tagStack.Pop ();
					} else {
						tagStack.Push (Tag.Parse (tagText));
					}
					curChunk.Offset = i + 1;
					inTag = false;
					specialBuilder.Length = 0;
					tagBuilder.Length = 0;
					break;
				default:
					if (inSpecial) {
						specialBuilder.Append (ch);
					} else {
						tagBuilder.Append (ch);
					}
					break;
				}
			}
			curChunk.Length = endOffset - curChunk.Offset;
			if (curChunk.Length > 0) {
				curChunk.ChunkStyle = GetChunkStyle (style, tagStack);
				endChunk = endChunk.Next = curChunk;
			}
			endChunk.Next = null;
			return startChunk;
		}
开发者ID:thild,项目名称:monodevelop,代码行数:91,代码来源:MarkupSyntaxMode.cs

示例7: GetKeyword

		public Keywords GetKeyword (Document doc, int offset, int length)
		{
			KeyTable[] curTable = table;
			int max = offset + length - 1;
			uint idx;
			for (int i = offset; i < max; i++) {
				idx = (uint)(IgnoreCase ? Char.ToUpper (doc.GetCharAt (i)) : doc.GetCharAt (i));
				if (idx >= curTable.Length || curTable[idx] == null)
					return null;
				curTable = curTable[idx].table;
			}
			idx = (uint)(IgnoreCase ? Char.ToUpper (doc.GetCharAt (max)) : doc.GetCharAt (max));
			if (idx > 255 || curTable[idx] == null)
				return null;
			return curTable[idx].keywords;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:16,代码来源:Rule.cs

示例8: FindPrevSubwordOffset

		/// <summary>
		/// Move to previous non-whitespace change in character class.
		/// </summary>
		public override int FindPrevSubwordOffset (Document doc, int offset)
		{
			int myoffset = offset-1;
			char c;
			if (0 > myoffset || doc.Length-1 <= myoffset){ return myoffset; }
			
			for (c = doc.GetCharAt (myoffset);
			     char.IsWhiteSpace (c) && 0 <= myoffset && doc.Length-1 > myoffset;
			     c = doc.GetCharAt (--myoffset));
			     
			CharacterClass initialClass = GetCharacterClass (c);
			
			for (; GetCharacterClass (c) == initialClass && 
			     0 <= myoffset && doc.Length-1 > myoffset;
			     c = doc.GetCharAt (--myoffset));
			     
			return (0 == myoffset)? myoffset: myoffset+1;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:21,代码来源:ViWordFindStrategy.cs

示例9: FindPrevWordOffset

		/// <summary>
		/// Move to end of previous whitespace group.
		/// </summary>
		public override int FindPrevWordOffset (Document doc, int offset)
		{
			--offset;
			if (0 > offset || doc.Length-1 <= offset){ return offset; }
			
			for (char c = doc.GetCharAt (offset);
			     char.IsWhiteSpace (c) && 0 < offset && doc.Length > offset;
			     c = doc.GetCharAt (--offset));
			for (char c = doc.GetCharAt (offset);
			     !char.IsWhiteSpace (c) && 0 < offset && doc.Length > offset;
			     c = doc.GetCharAt (--offset));
			     
			return (0 == offset)? offset: offset+1;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:17,代码来源:ViWordFindStrategy.cs

示例10: CreateNewFoldings

        /// <summary>
        /// Create <see cref="NewFolding"/>s for the specified document.
        /// </summary>
        public IEnumerable<NewFolding> CreateNewFoldings(Document.ITextSource document)
        {
            List<NewFolding> newFoldings = new List<NewFolding>();

            Stack<int> startOffsets = new Stack<int>();
            int lastNewLineOffset = 0;
            char openingBrace = this.OpeningBrace;
            char closingBrace = this.ClosingBrace;
            for (int i = 0; i < document.TextLength; i++) {
                char c = document.GetCharAt(i);
                if (c == openingBrace) {
                    startOffsets.Push(i);
                } else if (c == closingBrace && startOffsets.Count > 0) {
                    int startOffset = startOffsets.Pop();
                    // don't fold if opening and closing brace are on the same line
                    if (startOffset < lastNewLineOffset) {
                        newFoldings.Add(new NewFolding(startOffset, i + 1));
                    }
                } else if (c == '\n' || c == '\r') {
                    lastNewLineOffset = i + 1;
                }
            }
            newFoldings.Sort((a,b) => a.StartOffset.CompareTo(b.StartOffset));
            return newFoldings;
        }
开发者ID:m3zercat,项目名称:EditorThing,代码行数:28,代码来源:BraceFoldingStrategy.cs


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