Exemple #1
0
        /// <summary>
        /// Updates the caret position.
        /// </summary>
        public void UpdateCaretPosition()
        {
            if (_textArea.MotherTextAreaControl.TextEditorProperties.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.TextView.GetDrawingXPos(lineNr, _column);
            Point pos    = ScreenPosition;

            if (xpos >= 0)
            {
                CreateCaret();
                bool success = SetCaretPos(pos.X, pos.Y);
                if (!success)
                {
                    DestroyCaret();
                    _caretCreated = false;
                    UpdateCaretPosition();
                }
            }
            else
            {
                DestroyCaret();
            }
            // set the input method editor location
            if (_ime == null)
            {
                _ime = new Ime(_textArea.Handle, _textArea.Document.TextEditorProperties.Font);
            }
            else
            {
                _ime.HWnd = _textArea.Handle;
                _ime.Font = _textArea.Document.TextEditorProperties.Font;
            }
            _ime.SetIMEWindowLocation(pos.X, pos.Y);

            _currentPos = pos;
        }
Exemple #2
0
        /// <summary>
        /// Raises the <see cref="AbstractMargin.MouseDown"/> event.
        /// </summary>
        /// <param name="eventArgs">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        protected override void OnMouseDown(MouseEventArgs eventArgs)
        {
            Point        mousePos     = eventArgs.Location;
            MouseButtons mouseButtons = eventArgs.Button;

            int clickedVisibleLine = (mousePos.Y + TextArea.VirtualTop.Y) / TextArea.TextView.LineHeight;
            int lineNumber         = TextArea.Document.GetFirstLogicalLine(clickedVisibleLine);

            if ((mouseButtons & MouseButtons.Right) == MouseButtons.Right)
            {
                if (TextArea.Caret.Line != lineNumber)
                {
                    TextArea.Caret.Line = lineNumber;
                }
            }

            IList <Bookmark> marks       = TextArea.Document.BookmarkManager.Marks;
            List <Bookmark>  marksInLine = new List <Bookmark>();
            int oldCount = marks.Count;

            foreach (Bookmark mark in marks)
            {
                if (mark.LineNumber == lineNumber)
                {
                    marksInLine.Add(mark);
                }
            }

            for (int i = marksInLine.Count - 1; i >= 0; i--)
            {
                Bookmark mark = marksInLine[i];
                if (mark.Click(TextArea, eventArgs))
                {
                    if (oldCount != marks.Count)
                    {
                        TextArea.UpdateLine(lineNumber);
                    }

                    return;
                }
            }
            base.OnMouseDown(eventArgs);
        }