Exemple #1
0
        private void ScEdit_CharAdded(object sender, CharAddedEventArgs e)
        {
            var currentPos   = scEdit.CurrentPosition;
            var wordStartPos = scEdit.WordStartPosition(currentPos, true);

            // Display the autocompletion list
            var lenEntered = currentPos - wordStartPos;

            if (lenEntered > 0)
            {
                methodKey = scEdit.Text.Substring(wordStartPos, lenEntered);
            }
            string key = "";
            //if (e.Char== '.'|| lenEntered > 0)
            {
                if (e.Char == '.' && methodKey.Length > 0 && MethodNameDic.ContainsKey(methodKey))
                {
                    key = MethodNameDic[methodKey].ToString();
                    if (!scEdit.AutoCActive)
                    {
                        scEdit.AutoCShow(lenEntered, key);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary> Tested ? Working ? </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        private void selectedScintilla_CharAdded(object sender, CharAddedEventArgs e)
        {
            // Find the word start
            var currentPos   = selectedScintilla.CurrentPosition;
            var wordStartPos = selectedScintilla.WordStartPosition(currentPos, true);

            //string AutoCompleteList = "Gen_SQLite Gen_TreeView Gen_Grid List<int> List<TreeNode>";  // list of words to offer autocomplete options

            //string AutoCompleteString = String.Join(" ", AutoCompleteList.ToArray());

            selectedScintilla.AutoCAutoHide = false;  // hide popup after text is ruled out

            string trimmedWordList = "";
            // Display the autocompletion list
            var lenEntered = currentPos - wordStartPos;

            if (lenEntered > 0)
            {
                selectedScintilla.AutoCIgnoreCase     = true;
                selectedScintilla.AutoCChooseSingle   = false;
                selectedScintilla.AutoCMaxHeight      = 10;
                selectedScintilla.AutoCDropRestOfWord = true;

                string SoFarText = selectedScintilla.GetWordFromPosition(wordStartPos);  // word typed so far
                //ahk.MsgBox(Text);

                //string[] words = AutoCompleteList.Split(' ');
                string[] words = autoCompleteList.ToArray();

                foreach (string word in words)
                {
                    string TextInList = ahk.FirstCharacters(word, lenEntered); // returns first X characters in string
                    if (TextInList.ToUpper() == SoFarText.ToUpper())
                    {
                        trimmedWordList = trimmedWordList + " " + word;
                    }
                    //if (TextInList.ToUpper().Contains(SoFarText.ToUpper())) { trimmedWordList = trimmedWordList + " " + word; }
                }
                selectedScintilla.AutoCShow(lenEntered, trimmedWordList.Trim());

                //if (lenEntered > 3) { scintilla1.AutoCComplete(); }  // autocomplete past X characters

                selectedScintilla.AutoCCompleted += new EventHandler <AutoCSelectionEventArgs>(selectedScintilla_AutoCompleteAccepted);
                hit = false;

                //scintilla1.AutoCShow(lenEntered, AutoCompleteList);
                //     regex pattern matching and highlighting - untested
                //foreach (Match m in Patterns.Keyword0.Matches(Encoding.ASCII.GetString(e.RawText)))
                //   e.GetRange(m.Index, m.Index + m.Length).SetStyle(1);
            }
        }
        void ShowAutoCompletion(int count, List <ObjDecl> lst)
        {
            if (lst.Count == 0)
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            foreach (ObjDecl item in lst)
            {
                if (sb.Length == 0)
                {
                    sb.Append(item.Function());
                }
                else
                {
                    sb.Append(" " + item.Function());
                }
            }

            TextArea.AutoCShow(count, sb.ToString());
            //?? can only display AC or CT  Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_CALLTIPSHOW, 1, sb.ToString());
        }
Exemple #4
0
        //  Simple word autocompletion method
        private static void charAdded(object sender, SN.CharAddedEventArgs e)
        {
            //  Find the word start
            int currentPos   = languageEditor.CurrentPosition;
            int wordStartPos = languageEditor.WordStartPosition(currentPos, true);

            //  Display the autocompletion list
            int lenEntered = currentPos - wordStartPos;

            if (lenEntered > 0)
            {
                if (!languageEditor.AutoCActive)
                {
                    languageEditor.AutoCShow(lenEntered, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while void Console System");
                }
            }
        }
    /// <summary>
    /// Show an autocomplete listbox with methods and properties from the object with the entered keyword.
    /// </summary>
    /// <param name="scintilla"></param>
    /// <remarks></remarks>
    public static void ShowAutoComplete(this ScintillaNET.Scintilla scintilla)
    {
        string suggestions = "";

        //parses the last keyword (object) (before the ".") and get suggestions for the autocomplete box from its properties and methods

        string [] splitters =
        {
            ".",
            "(",
            ")",
            " ",
            "\r",
            "\n",
            "\r\n"
        };

        dynamic text     = ScintillaExtender.getLastWord(scintilla).Split(splitters, StringSplitOptions.RemoveEmptyEntries);
        dynamic lastchar = Convert.ToChar(scintilla.GetCharAt(scintilla.CurrentPosition));

        //text2 = text2.Remove(text2.Length - 2).Trim();
        string lastkeyword = "";


        if (text.Length >= 1)
        {
            if (text.Length >= 2)
            {
                lastkeyword = text[text.Length - 2].Trim();
                // System.Windows.MessageBox.Show("[1] " + lastkeyword);
            }
            else
            {
                lastkeyword = text[text.Length - 1].Trim();
                // System.Windows.MessageBox.Show("[2] " + lastkeyword);
            }

            switch (lastkeyword)
            {
            case "Browser":
                dynamic props = typeof(TopDown_QA_FrameWork.Driver).GetProperties();
                foreach (var p_loopVariable in props)
                {
                    //System.Windows.Forms.MessageBox.Show(p_loopVariable.Name);
                    var p = p_loopVariable;
                    suggestions += (p.Name) + " ";
                }

                dynamic methods = typeof(TopDown_QA_FrameWork.Driver).GetMethods();
                foreach (var m_loopVariable in methods)
                {
                    var m = m_loopVariable;
                    suggestions += (m.Name) + " ";
                }
                break;

            default:
                if ((Convert.ToInt32(scintilla.Tag)) == 1)
                {
                    suggestions = "Browser teste1";
                }
                else
                {
                    suggestions = "Browser teste2";
                }
                break;
            }
        }
        else
        {
            if (Convert.ToInt32(scintilla.Tag) == 1)
            {
                //editor is being used at flowsheet level.
                suggestions = "Browser teste3";
            }
            else
            {
                //editor is being used at script unit operation level
                suggestions = "Browser teste4 solver zinbu";
            }
        }

        dynamic currentPos   = scintilla.CurrentPosition;
        dynamic wordStartPos = scintilla.WordStartPosition(currentPos, true);

        // Display the autocompletion list
        dynamic lenEntered = currentPos - wordStartPos;

        //System.Windows.Forms.MessageBox.Show(lenEntered.ToString() + " lastChar= " + lastchar );
        //System.Windows.Forms.MessageBox.Show(suggestions);
        //System.Windows.Forms.MessageBox.Show(lastkeyword.ToString());

        if (lenEntered > 0 & lastchar != '.')
        {
            scintilla.AutoCShow(lenEntered, suggestions);
        }
        else
        {
            if (lastchar == '.' & text.Length >= 1)
            {
                //System.Windows.Forms.MessageBox.Show(suggestions);
                scintilla.AutoCShow(0, suggestions.Trim());
            }
            else
            {
                //System.Windows.Forms.MessageBox.Show("lenEntered: " + lenEntered.ToString() + "; lastChar: " + lastchar.ToString() + "; text.length: " + text.Length.ToString());
            }
        }
    }