Example #1
0
        //=========================================================================================
        void DeterminCurrentToken()
        {
            var tokens = this.Parent.Viewer.Tokens;

            for (int iToken = this.Parent.FirstVisibleToken; iToken < tokens.Count; iToken++)
            {
                var oToken = tokens[iToken];
                if (oToken.Start.Line == this.Line)
                {
                    if (oToken.End.Char >= this.Char)
                    {
                        if (oToken.End.Char == this.Char)
                        {
                            this._CurrentTokenIndex = iToken;
                            this._RegardingToken    = CaretLocationType.WordEnd;
                        }
                        else if (oToken.Start.Char < this.Char)
                        {
                            this._CurrentTokenIndex = iToken;
                            this._RegardingToken    = CaretLocationType.WordCenter;
                        }
                        else if (oToken.Start.Char == this.Char)
                        {
                            this._CurrentTokenIndex = iToken;
                            this._RegardingToken    = CaretLocationType.WordStart;
                        }
                        else
                        {
                            this._CurrentTokenIndex = iToken - 1;
                            this._RegardingToken    = CaretLocationType.BetweenWords;
                        }
                        return;
                    }
                }
            }
            if (tokens.Count > 0)
            {
                int iLastTokenIndex = tokens.Count - 1;
                var oToken          = tokens[iLastTokenIndex];
                if (this.Point > oToken.Start)
                {
                    this._CurrentTokenIndex = iLastTokenIndex;
                    this._RegardingToken    = CaretLocationType.BetweenWords;
                    return;
                }
            }
            this._CurrentTokenIndex = -1;
            this._RegardingToken    = CaretLocationType.WordStart;
        }
Example #2
0
 //=========================================================================================
 public CaretLocation(int tokenIndex, CaretLocationType type)
 {
     this.TokenIndex = tokenIndex;
     this.Location   = type;
 }
Example #3
0
		//=========================================================================================
		public CaretLocation(int tokenIndex, CaretLocationType type)
		{
			this.TokenIndex = tokenIndex;
			this.Location = type;
		}
Example #4
0
		//=========================================================================================
		void DeterminCurrentToken()
		{
			var tokens = this.Parent.Viewer.Tokens;
			for (int iToken = this.Parent.FirstVisibleToken; iToken < tokens.Count; iToken++)
			{
				var oToken = tokens[iToken];
				if (oToken.Start.Line == this.Line)
					if (oToken.End.Char >= this.Char)
					{
						if (oToken.End.Char == this.Char)
						{
							this._CurrentTokenIndex = iToken;
							this._RegardingToken = CaretLocationType.WordEnd;
						}
						else if (oToken.Start.Char < this.Char)
						{
							this._CurrentTokenIndex = iToken;
							this._RegardingToken = CaretLocationType.WordCenter;
						}
						else if (oToken.Start.Char == this.Char)
						{
							this._CurrentTokenIndex = iToken;
							this._RegardingToken = CaretLocationType.WordStart;
						}
						else
						{
							this._CurrentTokenIndex = iToken - 1;
							this._RegardingToken = CaretLocationType.BetweenWords;
						}
						return;
					}
			}
			if (tokens.Count > 0)
			{
				int iLastTokenIndex = tokens.Count - 1;
				var oToken = tokens[iLastTokenIndex];
				if (this.Point > oToken.Start)
				{
					this._CurrentTokenIndex = iLastTokenIndex;
					this._RegardingToken = CaretLocationType.BetweenWords;
					return;
				}
			}
			this._CurrentTokenIndex = -1;
			this._RegardingToken = CaretLocationType.WordStart;
		}