예제 #1
0
        public bool MoveAhead(int numChars)
        {
            Debug.Assert(numChars > 0);

            switch (state)
            {
            case TextIteratorState.Resetted:
                Position = endOffset;
                state    = TextIteratorState.Iterating;
                return(true);

            case TextIteratorState.Done:
                return(false);

            case TextIteratorState.Iterating:
                Position = (Position + numChars) % textBuffer.Length;
                bool finish = oldOffset != -1 && (oldOffset > Position || oldOffset < endOffset) && Position >= endOffset;

                oldOffset = Position;
                if (finish)
                {
                    state = TextIteratorState.Done;
                    return(false);
                }
                return(true);

            default:
                throw new Exception("Unknown text iterator state");
            }
        }
예제 #2
0
        public bool MoveAhead(int numChars)
        {
            Debug.Assert(numChars > 0);

            switch (state)
            {
            case TextIteratorState.Resetted:
                if (document.TextLength == 0)
                {
                    state = TextIteratorState.Done;
                    return(false);
                }
                Position = endOffset;
                state    = TextIteratorState.Iterating;
                return(true);

            case TextIteratorState.Done:
                return(false);

            case TextIteratorState.Iterating:
                if (oldOffset == -1 && document.TextLength == endOffset)
                {
                    // HACK: Take off one if the iterator start
                    // position is at the end of the text.
                    Position--;
                }

                if (oldOffset != -1 && Position == endOffset - 1 && document.TextLength == endOffset)
                {
                    state = TextIteratorState.Done;
                    return(false);
                }

                Position = (Position + numChars) % document.TextLength;
                bool finish = oldOffset != -1 && (oldOffset > Position || oldOffset < endOffset) && Position >= endOffset;

                // HACK: Iterating is complete if Position == endOffset - 1
                // when the iterator start position was initially at the
                // end of the text.
                if (oldOffset != -1 && oldOffset == endOffset - 1 && document.TextLength == endOffset)
                {
                    finish = true;
                }

                oldOffset = Position;
                if (finish)
                {
                    state = TextIteratorState.Done;
                    return(false);
                }
                return(true);

            default:
                throw new Exception("Unknown text iterator state");
            }
        }
		public bool MoveAhead(int numChars)
		{
			Debug.Assert(numChars > 0);
			
			switch (state) {
				case TextIteratorState.Resetted:
					Position = endOffset;
					state = TextIteratorState.Iterating;
					return true;
				case TextIteratorState.Done:
					return false;
				case TextIteratorState.Iterating:
					Position = (Position + numChars) % textBuffer.Length;
					bool finish = oldOffset != -1 && (oldOffset > Position || oldOffset < endOffset) && Position >= endOffset;
					
					oldOffset = Position;
					if (finish) {
						state = TextIteratorState.Done;
						return false;
					}
					return true;
				default:
					throw new Exception("Unknown text iterator state");
			}
		}
		public void Reset()
		{
			state      = TextIteratorState.Resetted;
			Position   = endOffset;
			oldOffset  = -1;
		}
예제 #5
0
 public void Reset()
 {
     state     = TextIteratorState.Resetted;
     Position  = endOffset;
     oldOffset = -1;
 }
 public virtual void Reset()
 {
     state = TextIteratorState.Resetted;
     currentOffset = endOffset;
 }
        public virtual void MoveToEnd()
        {
            if (endOffset > 0)
                currentOffset = endOffset - 1;
            else
                currentOffset = BufferLength - 1;

            state = TextIteratorState.Iterating;
        }
        public virtual bool MoveAhead(int numChars)
        {
            Debug.Assert(numChars > 0);

            switch (state) {
                case TextIteratorState.Resetted:
                    currentOffset = endOffset;
                    state = TextIteratorState.Iterating;
                    return true;
                case TextIteratorState.Done:
                    return false;
                case TextIteratorState.Iterating:
                    int oldOffset = currentOffset;
                    currentOffset = (currentOffset + numChars) % BufferLength;
                    bool finish = (oldOffset > currentOffset || oldOffset < endOffset) && currentOffset >= endOffset;
                    if (finish) {
                        state = TextIteratorState.Done;
                        currentOffset = endOffset;
                        return false;
                    }
                    return true;
                default:
                    throw new Exception("Unknown text iterator state");
            }
        }
		public bool MoveAhead(int numChars)
		{
			Debug.Assert(numChars > 0);
			
			switch (state) {
				case TextIteratorState.Resetted:
					if (textBuffer.Length == 0) {
						state = TextIteratorState.Done;
						return false;
					}
					Position = endOffset;
					state = TextIteratorState.Iterating;
					return true;
				case TextIteratorState.Done:
					return false;
				case TextIteratorState.Iterating:
					if (oldOffset == -1 && textBuffer.Length == endOffset) {
						// HACK: Take off one if the iterator start
						// position is at the end of the text.
						Position--;
					}
					
					if (oldOffset != -1 && Position == endOffset - 1 && textBuffer.Length == endOffset) {
						state = TextIteratorState.Done;
						return false;
					}
					
					Position = (Position + numChars) % textBuffer.Length;
					bool finish = oldOffset != -1 && (oldOffset > Position || oldOffset < endOffset) && Position >= endOffset;
					
					// HACK: Iterating is complete if Position == endOffset - 1 
					// when the iterator start position was initially at the
					// end of the text.
					if (oldOffset != -1 && oldOffset == endOffset - 1 && textBuffer.Length == endOffset) {
						finish = true;
					}
					
					oldOffset = Position;
					if (finish) {
						state = TextIteratorState.Done;
						return false;
					}
					return true;
				default:
					throw new Exception("Unknown text iterator state");
			}
		}
 public void Reset()
 {
     state         = TextIteratorState.Resetted;
     currentOffset = endOffset;
     oldOffset     = -1;
 }