コード例 #1
0
        public bool HandleKeys(ScintillaControl sci, Keys key)
        {
            switch (key)
            {
            case Keys.Multiply:
            case Keys.Subtract:
            case Keys.Divide:
            case Keys.Decimal:
            case Keys.Add:
                return(false);

            case Keys.Up:
                if (!CompletionList.Active)
                {
                    sci.LineUp();
                }
                return(false);

            case Keys.Down:
                if (!CompletionList.Active)
                {
                    sci.LineDown();
                }
                return(false);

            case Keys.Up | Keys.Shift:
                sci.LineUpExtend();
                return(false);

            case Keys.Down | Keys.Shift:
                sci.LineDownExtend();
                return(false);

            case Keys.Left | Keys.Shift:
                sci.CharLeftExtend();
                return(false);

            case Keys.Right | Keys.Shift:
                sci.CharRightExtend();
                return(false);

            case Keys.Right:
                if (!CompletionList.Active)
                {
                    sci.CharRight();
                    currentPos = sci.CurrentPos;
                    if (sci.LineFromPosition(sci.CurrentPos) != currentLine)
                    {
                        Hide();
                    }
                    else if (OnUpdateCallTip != null)
                    {
                        OnUpdateCallTip(sci, currentPos);
                    }
                }
                return(true);

            case Keys.Left:
                if (!CompletionList.Active)
                {
                    sci.CharLeft();
                    currentPos = sci.CurrentPos;
                    if (currentPos < startPos)
                    {
                        Hide();
                    }
                    else
                    {
                        if (sci.LineFromPosition(sci.CurrentPos) != currentLine)
                        {
                            Hide();
                        }
                        else if (OnUpdateCallTip != null)
                        {
                            OnUpdateCallTip(sci, currentPos);
                        }
                    }
                }
                return(true);

            case Keys.Back:
                sci.DeleteBack();
                currentPos = sci.CurrentPos;
                if (currentPos + deltaPos < startPos)
                {
                    Hide();
                }
                else if (OnUpdateCallTip != null)
                {
                    OnUpdateCallTip(sci, currentPos);
                }
                return(true);

            case Keys.Tab:
            case Keys.Space:
                return(false);

            default:
                if (!CompletionList.Active)
                {
                    Hide();
                }
                return(false);
            }
        }