Beispiel #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();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Is the caret not in : an include, a string, a comment
 /// </summary>
 /// <returns></returns>
 public static bool IsCarretInNormalContext(int curPos)
 {
     try {
         var curContext = (UdlStyles)Sci.GetStyleAt(curPos);
         if (curPos <= 0)
         {
             return(true);
         }
         if (IsNormalContext(curContext))
         {
             return(true);
         }
         var prevContext = (UdlStyles)Sci.GetStyleAt(curPos - 1);
         return(IsNormalContext(prevContext));
     } catch (Exception) {
         // we can be here if the style ID isn't in the UdlStyles enum
         return(true);
     }
 }