Пример #1
0
    private void ShouldOpemPopupList()
    {
        List <JumpCommandObject> autoCompletions = JumpCommand.GetAutoCompletionCommandObjects(input);

        if (autoCompletions.Count > 0)
        {
            List <string> content = new List <string>();
            foreach (var command in autoCompletions)
            {
                content.Add(GetCommandRichText(command));
            }
            popupListCommand = autoCompletions;
            popupListContent = content.ToArray();
            if (!popupListOpen)
            {
                OpenPopupList();
            }
        }
        else
        {
            if (popupListOpen)
            {
                ClosePopupList();
            }
        }
    }
Пример #2
0
    private void HandleTab()
    {
        TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

        if (KeyDown("tab") && popupListOpen)
        {
            input        = popupListCommand[popupListSelIndex].Name;
            te.pos       = input.Length;
            te.selectPos = te.pos;
            ClosePopupList();
        }
        else if (KeyDown("tab") && !popupListOpen)
        {
            List <JumpCommandObject> autoCompletions = JumpCommand.GetAutoCompletionCommandObjects(input);
            if (autoCompletions.Count > 0)
            {
                List <string> content = new List <string>();
                foreach (var command in autoCompletions)
                {
                    content.Add(GetCommandRichText(command));
                }
                popupListCommand = autoCompletions;
                popupListContent = content.ToArray();
                input            = popupListCommand[popupListSelIndex].Name;
                te.pos           = input.Length;
                te.selectPos     = te.pos;
                OpenPopupList();
            }
        }
        // Press tab to switch among auto-completion commands

        // if (KeyDown("tab"))
        // {
        //     // eg: com[mand]
        //     // The unselected part of a command
        //     string substr  = input.Substring(0, te.pos);
        //     string command = JumpCommand.GetAutoCompletionCommand(substr, input);
        //     if(command != null) {
        //         input = command;
        //         te.pos = input.Length;
        //     }
        // }
    }