Exemple #1
0
        private bool HandleKeys(Keys key)
        {
            // UITools is currently broadcasting a shortcut, ignore!
            if (ignoreKeys || DisableEvents)
            {
                return(false);
            }

            // list/tip shortcut dispatching
            if ((key == (Keys.Control | Keys.Space)) || (key == (Keys.Shift | Keys.Control | Keys.Space)))
            {
                /*if (CompletionList.Active || callTip.CallTipActive)
                 * {
                 *  UnlockControl();
                 *  CompletionList.Hide();
                 *  callTip.Hide();
                 * }*/
                // offer to handle the shortcut
                ignoreKeys = true;
                KeyEvent ke = new KeyEvent(EventType.Keys, key);
                EventManager.DispatchEvent(this, ke);
                ignoreKeys = false;
                // if not handled - show snippets
                if (!ke.Handled && PluginBase.MainForm.CurrentDocument.IsEditable &&
                    !PluginBase.MainForm.CurrentDocument.SciControl.IsSelectionRectangle)
                {
                    PluginBase.MainForm.CallCommand("InsertSnippet", "null");
                }
                return(true);
            }

            // toggle "long-description" for the hover tooltip
            if (key == Keys.F1 && Tip.Visible && !CompletionList.Active)
            {
                showDetails = !showDetails;
                simpleTip.UpdateTip(PluginBase.MainForm.CurrentDocument.SciControl);
                return(true);
            }

            // are we currently displaying something?
            if (!CompletionList.Active && !callTip.CallTipActive)
            {
                return(false);
            }

            // hide if pressing Esc or Ctrl+Key combination
            if (lockedSciControl == null || !lockedSciControl.IsAlive || key == Keys.Escape ||
                ((Control.ModifierKeys & Keys.Control) != 0 && Control.ModifierKeys != (Keys.Control | Keys.Alt)))
            {
                if (key == (Keys.Control | Keys.C) || key == (Keys.Control | Keys.A))
                {
                    return(false); // let text copy in tip
                }
                UnlockControl();
                CompletionList.Hide((char)27);
                callTip.Hide();
                return(false);
            }
            ScintillaControl sci = (ScintillaControl)lockedSciControl.Target;
            // chars
            string ks = key.ToString();

            if (ks.Length == 1 || (ks.EndsWithOrdinal(", Shift") && ks.IndexOf(',') == 1) || ks.StartsWithOrdinal("NumPad"))
            {
                return(false);
            }

            // toggle "long-description"
            if (key == Keys.F1)
            {
                showDetails = !showDetails;
                if (callTip.CallTipActive)
                {
                    callTip.UpdateTip(sci);
                }
                else
                {
                    CompletionList.UpdateTip(null, null);
                }
                return(true);
            }

            // switches
            else if ((key & Keys.ShiftKey) == Keys.ShiftKey || (key & Keys.ControlKey) == Keys.ControlKey || (key & Keys.Menu) == Keys.Menu)
            {
                return(false);
            }

            // handle special keys
            bool handled = false;

            if (callTip.CallTipActive)
            {
                handled |= callTip.HandleKeys(sci, key);
            }
            if (CompletionList.Active)
            {
                handled |= CompletionList.HandleKeys(sci, key);
            }
            return(handled);
        }