コード例 #1
0
ファイル: TextCaret.cs プロジェクト: RellikJaeger/SA.CodeView
        //=========================================================================================
        void MoveLeft(MovementType movementType, bool clearSelection)
        {
            if (this.Doc.Count == 0)
            {
                this.MoveDocHome();
                return;
            }
            int iCol, iChar, iLine = this._Point.Line;

            //if caret at the beginning of the line we should to move up
            if (this._Point.Char == 0)
            {
                if (iLine == 0)
                {
                    return;
                }
                iLine--;
                string sLine = this.Doc[iLine].Text;
                iChar = sLine.Length;
                iCol  = GetLastCol(sLine, this.Parent.Viewer._TabSize);
            }
            else
            {
                string sLine = this.Doc[iLine].Text;
                if (movementType == MovementType.Char)
                {
                    iChar = this._Point.Char - 1;
                }
                else
                {
                    iChar = WordFinder.GetWordStart(sLine, this._Point.Char);
                }
                iCol = this.GetColumn(sLine, iChar);
            }
            this.SetCaretPos(iLine, iChar, iCol, true, clearSelection);
        }