Пример #1
0
        /// <summary>
        /// Method called when the tooltip is opened from the mouse being inactive on scintilla
        /// </summary>
        public static void ShowToolTipFromDwell(bool openTemporary = true)
        {
            if (Config.Instance.ToolTipDeactivate)
            {
                return;
            }
            InitIfneeded();

            var position = Sci.GetPositionFromMouseLocation();

            if (position < 0)
            {
                return;
            }

            // check caret context, dont display a tooltip for comments
            var curContext = (UdlStyles)Sci.GetStyleAt(position);

            if (curContext == UdlStyles.Comment || curContext == UdlStyles.Delimiter8)
            {
                return;
            }

            // sets the tooltip content
            var data = AutoCompletion.FindInCompletionData(Sci.GetWordAtPosition(position, AutoCompletion.CurrentLangAllChars, AutoCompletion.CurrentLangAdditionalChars), Sci.LineFromPosition(position));

            if (data != null && data.Count > 0)
            {
                _currentCompletionList = data;
            }
            else
            {
                return;
            }

            // in strings, only functions trigger the tooltip
            if ((curContext == UdlStyles.Delimiter1 || curContext == UdlStyles.Delimiter2 || curContext == UdlStyles.Delimiter4 || curContext == UdlStyles.Delimiter5) && _currentCompletionList.First().Type != CompletionType.Function)
            {
                return;
            }

            SetToolTip();

            // update position
            var point = Sci.GetPointXyFromPosition(position);

            point.Offset(Sci.GetScintillaRectangle().Location);
            var lineHeight = Sci.TextHeight(Sci.Line.CurrentLine);

            point.Y       += lineHeight + 5;
            _form.Location = _form.GetBestAutocompPosition(point, lineHeight + 5);

            _openedFromDwell = openTemporary;
            if (!_form.Visible)
            {
                _form.UnCloak();
            }
        }