コード例 #1
0
        public void UpdateCaretPosition()
        {
            if (Shared.TEP.CaretLine)
            {
                _textArea.Invalidate();
            }
            else
            {
                if (_caretImplementation.RequireRedrawOnPositionChange)
                {
                    _textArea.UpdateLine(_oldLine);
                    if (_line != _oldLine)
                    {
                        _textArea.UpdateLine(_line);
                    }
                }
                else
                {
                    if (Shared.TEP.LineViewerStyle == LineViewerStyle.FullRow && _oldLine != _line)
                    {
                        _textArea.UpdateLine(_oldLine);
                        _textArea.UpdateLine(_line);
                    }
                }
            }
            _oldLine = _line;

            if (_hidden || _textArea.MotherTextEditorControl.IsInUpdate)
            {
                _outstandingUpdate = true;
                return;
            }
            else
            {
                _outstandingUpdate = false;
            }

            ValidateCaretPos();
            int lineNr = _line;
            int xpos   = _textArea.GetDrawingXPos(lineNr, this._column);
            //LineSegment lineSegment = textArea.Document.GetLineSegment(lineNr);
            Point pos = ScreenPosition;

            if (xpos >= 0)
            {
                CreateCaret();
                bool success = _caretImplementation.SetPosition(pos.X, pos.Y);
                if (!success)
                {
                    _caretImplementation.Destroy();
                    _caretCreated = false;
                    UpdateCaretPosition();
                }
            }
            else
            {
                _caretImplementation.Destroy();
            }

            //// set the input method editor location
            //if (ime == null)
            //{
            //    ime = new Ime(textArea.Handle, Shared.FontContainer.DefaultFont);
            //}
            //else
            //{
            //    ime.HWnd = textArea.Handle;
            //    ime.Font = Shared.FontContainer.DefaultFont;
            //}
            //ime.SetIMEWindowLocation(pos.X, pos.Y);

            _currentPos = pos;
        }