示例#1
0
        private void TextArea_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            char cc = (char)TextArea.GetCharAt(TextArea.CurrentPosition - 1);

            switch (AutoCompleteVer)
            {
            case 1:
                if (cc != '\r' && cc != '\n' && cc != '\t')
                {
                    TextArea.AutoCShow(0, AutoCompletev1);
                }
                break;

            case 2:
                if (cc != '\r' && cc != '\n' && cc != '\t')
                {
                    TextArea.AutoCShow(0, AutoCompletev2);
                }
                break;

            case 3:
                if (cc != '\r' && cc != '\n' && cc != '\t')
                {
                    TextArea.AutoCShow(0, AutoCompletevB);
                }
                break;
            }
        }
示例#2
0
        private void Editor_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            AutoComplete match = _CurScheme.GetMatches(e.Ch, Editor.NativeInterface.GetStyleAt(Editor.CurrentPos));

            if (match != null)
            {
                DisplayAutoComplete(match);
            }
        }
示例#3
0
        void editSource_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            if (e.Ch == '"')
            {
                m_StringEnterMode = !m_StringEnterMode;
            }

            // and in this Method you could check, if your Autocompletelist contains the last insterted Characters. If so you call the this.sciDocument.AutoComplete.Show(); Method of the Control
            // and it shows the AutocompleteList with the value that machtes the inserted Characters.
            int    lineIndex = editSource.Lines.FromPosition(editSource.CurrentPos - 1).Number;
            string wordBelow = FindWordFromPosition(editSource.CurrentPos - 1, lineIndex);
            string zone      = FindZoneFromLine(lineIndex);

            if (wordBelow.Length == 0)
            {
                return;
            }
            List <string> newList = new List <string>();

            foreach (string entry in DocumentInfo.KnownKeywords)
            {
                if (entry.StartsWith(wordBelow))
                {
                    newList.Add(entry);
                }
                if ((wordBelow.StartsWith(".")) &&
                    (entry.StartsWith(zone + "." + wordBelow.Substring(1))))
                {
                    newList.Add(entry.Substring(zone.Length + 1));
                }
            }
            if (newList.Count > 0)
            {
                if (newList.Count == 1)
                {
                    if ((newList[0] == wordBelow) ||
                        (newList[0] == zone + "." + wordBelow.Substring(1)))
                    {
                        // only have the correct entry
                        return;
                    }
                }

                editSource.AutoComplete.DropRestOfWord  = true;
                editSource.AutoComplete.IsCaseSensitive = false;
                editSource.AutoComplete.Show(wordBelow.Length, newList);
            }
        }
示例#4
0
        private void Editor_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            ScintillaNET.Scintilla Editor = sender as ScintillaNET.Scintilla;

            curWord = Editor.GetWordFromPosition(Editor.SelectionStart);
            if (curWord.Length == 0)
            {
                return;
            }
            Predicate <string> startWord = compareWithCurrentWord;
            List <string>      list      = autoCompleteList.FindAll(startWord);

            if (list.Count > 0)
            {
                Editor.AutoCShow(curWord.Length, string.Join(SciEditor.AutoCSeparator.ToString(), list.ToArray()));
            }
        }
示例#5
0
        private void intellua_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            //ShowCalltip();
            const string brackets = "()[]{}";
            const string newline  = "\r\n";

            if (newline.Contains(e.Ch))
            {
                if (e.Ch == '\n')
                {
                    InsertText(string.Concat(Enumerable.Repeat("\t", Lines.Current.Previous.Indentation / Indentation.TabWidth)));

                    if (Lines.Current.FoldParent != null && Lines.Current.FoldParent.StartPosition == Lines.Current.Previous.StartPosition)
                    {
                        InsertText("\t");
                    }
                }

                return;
            }

            if (!Parse)
            {
                return;
            }
            if (brackets.Contains(e.Ch))
            {
                return;
            }

            MemberChain chain = MemberChain.ParseBackward(m_source);

            if (chain.Elements.Count == 1)
            {
                string word = chain.Elements[0].Name;
                if (char.IsLetterOrDigit(e.Ch) && word.Length >= 3)
                {
                    List <IAutoCompleteItem> list = m_autoCompleteData.Variables.getList(word, CurrentPos);
                    m_autoCompleteData.Types.appendList(list, word);
                    m_autoCompleteData.Keywords.appendList(list, word);

                    list.Sort();
                    if (list.Count > 0)
                    {
                        ShowAutoComplete(word.Length, list);
                    }
                }
            }
            else
            {
                Type t = chain.getType(m_autoCompleteData);
                if (t != null)
                {
                    List <IAutoCompleteItem> list = t.getList(chain.IsNamespace);
                    if (list.Count > 0)
                    {
                        ShowAutoComplete(chain.getLastElement().Length, list);
                    }
                }
            }

            if (!AutoComplete.IsActive)
            {
                m_tooltip.Hide();
            }
        }
示例#6
0
        /// <summary>
        /// CharAdded event attached to scintilla control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Editor_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            if (e.Ch == '"')
            {
                ScintillaNET.Scintilla editor = GetScintilla(sender);
                if (editor != null)
                {
                    int curPos = editor.CurrentPos;

                    // We only care about hypertext
                    if (editor.Lexing.Lexer != ScintillaNET.Lexer.Hypertext)
                    {
                        return;
                    }

                    int curStyle = editor.Styles.GetStyleAt(curPos);

                    if (curStyle == 6 || curStyle > 20)
                    {
                        return;
                    }

                    string att = getAttribute(curPos, editor);

                    if (att == "src")
                    {
                        IDocument doc = GetDocument(sender);
                        if (doc != null)
                        {
                            showFilePopup(curPos, editor, doc);
                        }
                    }
                }
            }
            if (e.Ch == '<')
            {
                ScintillaNET.Scintilla editor = GetScintilla(sender);
                if (editor != null)
                {
                    int curPos = editor.CurrentPos;
                    if (editor.Lexing.Lexer != ScintillaNET.Lexer.Hypertext)
                    {
                        return;
                    }

                    int curStyle = editor.Styles.GetStyleAt(curPos);

                    if (curStyle > 20)
                    {
                        return;
                    }
                    editor.AutoComplete.List = _HtmlTags;
                    editor.AutoComplete.Show();
                }
            }
            if (e.Ch == ' ')
            {
                ScintillaNET.Scintilla editor = GetScintilla(sender);
                if (editor != null)
                {
                    int curPos = editor.CurrentPos;
                    // Don't handle these in strings
                    if (editor.Lexing.Lexer != ScintillaNET.Lexer.Hypertext)
                    {
                        return;
                    }

                    if (InTag(curPos, editor))
                    {
                        int curStyle = editor.Styles.GetStyleAt(curPos);

                        if (curStyle == 6 || curStyle > 20)
                        {
                            return;
                        }
                        editor.AutoComplete.List = _HtmlAttributes;
                        editor.AutoComplete.Show();
                    }
                }
            }
        }
示例#7
0
        //
        //  --- Autocomplete:
        //
        private void codeEditor_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            if (e.Ch == '{' && autoCompleteBraces)
            {
                string text  = codeEditor.Lines.Current.Text;
                int    count = 0;
                foreach (char c in text.ToCharArray())
                {
                    if (c == '\t')
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }
                codeEditor.InsertText("\n");
                for (int i = 0; i != count + 1; i++)
                {
                    codeEditor.InsertText("\t");
                }
                int pos = codeEditor.CurrentPos;
                codeEditor.InsertText("\n");
                for (int i = 0; i != count; i++)
                {
                    codeEditor.InsertText("\t");
                }
                codeEditor.InsertText("}");
                codeEditor.CurrentPos = pos;
            }

            if (e.Ch == ' ')
            {
                return;
            }
            //Get word written until now:
            string word = codeEditor.GetWordFromPosition(codeEditor.NativeInterface.GetCurrentPos());

            if (word == "")
            {
                return;
            }

            //Compile a list with possible functions:
            List <string> possibleWords = null;

            possibleWords = new List <string>();
            if (word == "for")  //Enable for loop
            {
                possibleWords.Add("for");
            }
            foreach (lexer.functionData i in (userFunctionList.FindAll(item => item.identifer.StartsWith(word, StringComparison.OrdinalIgnoreCase))))
            {
                possibleWords.Add(i.identifer);
            }
            foreach (lexer.functionData i in (includeFunctionList.FindAll(item => item.identifer.StartsWith(word, StringComparison.OrdinalIgnoreCase))))
            {
                possibleWords.Add(i.identifer);
            }
            //Add defines to the list:
            foreach (TreeNode node in defineView.Nodes)
            {
                foreach (TreeNode i in node.Nodes)
                {
                    if (i.Text.StartsWith(word, StringComparison.OrdinalIgnoreCase))
                    {
                        possibleWords.Add((i.Text.Split(' '))[0]);
                    }
                }
            }

            //Add PVars to the list:
            string pword = word.ToLower();

            if (pword.Contains("getpvar") || pword.Contains("setpvar") || ac_state == ac_states.pvar)
            {
                if (ac_state == ac_states.none)
                {
                    ac_state = ac_states.pvar;
                    ac_line  = codeEditor.Lines.Current.Number;
                }
                foreach (TreeNode node in pvarView.Nodes)
                {
                    if (node.Text.StartsWith(pword, StringComparison.OrdinalIgnoreCase))
                    {
                        possibleWords.Add(node.Text);
                    }
                }
            }
            if (ac_state == ac_states.pvar)
            {
                if (ac_line != codeEditor.Lines.Current.Number)
                {
                    ac_state = ac_states.none;
                }
            }

            if (possibleWords.Count > 0)
            {
                //Show the options:
                codeEditor.AutoComplete.List.Clear();
                codeEditor.AutoComplete.List = possibleWords;
                codeEditor.AutoComplete.Show();
            }
        }
        private void CodeEditor_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
        {
            var scintilla = (ScintillaNET.Scintilla)sender;

            // Find the word start
            var currentPos   = scintilla.CurrentPosition;
            var wordStartPos = scintilla.WordStartPosition(currentPos, true);

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

            if (lenEntered > 0)
            {
                if (!scintilla.AutoCActive)
                {
                    try
                    {
                        scintilla.SearchFlags = (ScintillaNET.SearchFlags.MatchCase | ScintillaNET.SearchFlags.WholeWord);

                        string word = scintilla.GetTextRange(scintilla.WordStartPosition(currentPos, true), lenEntered);

                        switch (word)
                        {
                        case "igpTopo":

                            scintilla.AutoCShow(lenEntered, DumbSense(word, "shift.yggdrasil2.Topology.IGP.Topology"));

                            break;

                        case "mplsTopo":

                            scintilla.AutoCShow(lenEntered, DumbSense(word, "shift.yggdrasil2.Topology.MPLS.Topology"));

                            break;

                        case "nm2":

                            scintilla.AutoCShow(lenEntered, DumbSense(word, "shift.yggdrasil2.PathComputation.PathComputation+YggdrasilNM2"));

                            break;

                        default:

                            int scopeStart = scintilla.Text.LastIndexOf("{", wordStartPos);
                            int scopeEnd   = scintilla.Text.IndexOf("}", wordStartPos);

                            scintilla.TargetStart = scopeStart;
                            scintilla.TargetEnd   = scopeEnd;

                            int firstSeen = scintilla.SearchInTarget(word);

                            string typeName = scintilla.GetTextRange(scintilla.Text.LastIndexOf("\n", firstSeen), firstSeen - scintilla.Text.LastIndexOf("\n", firstSeen)).Trim();

                            scintilla.TargetStart = 0;
                            scintilla.TargetEnd   = scopeStart;

                            firstSeen = scintilla.SearchInTarget(typeName);

                            string namespaceName = scintilla.GetTextRange(scintilla.Text.IndexOf("=", firstSeen), scintilla.Text.IndexOf("\n", firstSeen) - scintilla.Text.IndexOf("=", firstSeen)).Trim("= ; \r".ToCharArray());

                            scintilla.AutoCShow(lenEntered, DumbSense(word, namespaceName));

                            break;
                        }
                    }
                    catch (Exception)
                    {
                        scintilla.AutoCShow(lenEntered, "HierarchicalLabelSwitchedPath((string)SymbolicPathName) LabelSwitchedPath((string)ParentId) 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");
                    }
                }
            }
        }