コード例 #1
0
ファイル: AutoCompleteHelper.cs プロジェクト: zhh007/MyGen
        public static void CharAdded(ZeusScintillaControl scintilla, char ch)
        {
            AutoCompleteHelper ach = null;
            bool isTagged          = (scintilla.ConfigurationLanguage == null) ? false : scintilla.ConfigurationLanguage.StartsWith("Tagged");

            switch (scintilla.ConfigurationLanguage)
            {
            case "TaggedC#":
            case "C#":
                ach = _cSharpAutoCompleteHelper;
                break;

            case "TaggedVB.Net":
            case "VB.Net":
                ach = _vbNetAutoCompleteHelper;
                break;

            case "TaggedJScript":
            case "JScript":
                ach = _jScriptAutoCompleteHelper;
                break;

            case "TaggedVBScript":
            case "VBScript":
                ach = _vbScriptAutoCompleteHelper;
                break;
            }


            if (ach != null)
            {
                ach.HandleCharAdded(scintilla, isTagged, ch);
            }
        }
コード例 #2
0
        public static void CharAdded(ZeusScintillaControl scintilla, char ch)
        {
            AutoCompleteHelper ach = null;
            bool isTagged = (scintilla.ConfigurationLanguage == null) ? false : scintilla.ConfigurationLanguage.StartsWith("Tagged");

            switch (scintilla.ConfigurationLanguage) 
            {
                case "TaggedC#":
                case "C#":
                    ach = _cSharpAutoCompleteHelper;
                    break;
                case "TaggedVB.Net":
                case "VB.Net":
                    ach = _vbNetAutoCompleteHelper;
                    break;
                case "TaggedJScript":
                case "JScript":
                    ach = _jScriptAutoCompleteHelper;
                    break;
                case "TaggedVBScript":
                case "VBScript":
                    ach = _vbScriptAutoCompleteHelper;
                    break;
            }


            if (ach != null) 
            {
                ach.HandleCharAdded(scintilla, isTagged, ch);        
            }
        }
コード例 #3
0
        public ConsoleForm(IMyGenerationMDI mdi)
        {
            this.mdi = mdi;

            zcs = new ZeusScintillaControl();
            zcs.Dock = DockStyle.Fill;
            zcs.IsReadOnly = true;
            zcs.BringToFront();
            zcs.Name = "ScintillaConsole";
            this.Controls.Add(zcs);

            InitializeComponent();
        }
コード例 #4
0
ファイル: ConsoleForm.cs プロジェクト: zhh007/MyGen
        public ConsoleForm(IMyGenerationMDI mdi)
        {
            this.mdi = mdi;

            zcs            = new ZeusScintillaControl();
            zcs.Dock       = DockStyle.Fill;
            zcs.IsReadOnly = true;
            zcs.BringToFront();
            zcs.Name = "ScintillaConsole";
            this.Controls.Add(zcs);

            InitializeComponent();
        }
コード例 #5
0
ファイル: AutoCompleteHelper.cs プロジェクト: zhh007/MyGen
        public void HandleCharAdded(ZeusScintillaControl scintilla, bool isTagged, char ch)
        {
            bool isCtrlPressed = (Control.ModifierKeys == (System.Windows.Forms.Keys.Control | Control.ModifierKeys));
            bool isAutoSeek    = IsAutoCompleteSeek(ch, isCtrlPressed);
            bool isAutoMember  = IsAutoCompleteMember(ch);
            bool isCallTip     = IsCallTip(ch);

            if (isAutoSeek || isAutoMember || isCallTip)
            {
                int                       pos = scintilla.CurrentPos - 1;
                char                      c   = scintilla.CharAt(--pos);
                Stack <string>            stk = new Stack <string>();
                List <string>             lst = new List <string>();
                System.Text.StringBuilder tmp = new System.Text.StringBuilder();

                int style = scintilla.StyleAt(pos);
                if (IsCodeStyle(isTagged, style))
                {
                    while (IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (c == MemberSeperator)
                        {
                            if (tmp.Length > 0)
                            {
                                lst.Insert(0, tmp.ToString());
                                stk.Push(tmp.ToString());
                                tmp.Remove(0, tmp.Length);
                            }
                        }
                        else
                        {
                            tmp.Insert(0, c);
                        }
                        c = scintilla.CharAt(--pos);
                    }
                    if (tmp.Length > 0)
                    {
                        lst.Insert(0, tmp.ToString());
                        stk.Push(tmp.ToString());
                        tmp.Remove(0, tmp.Length);
                    }

                    AutoCompleteNodeInfo n = null;
                    AutoCompleteNodeInfo nextToLastNode = null;
                    System.Collections.Generic.List <AutoCompleteNodeInfo> ns = null;
                    string lastmsg = null, firstmsg = null;
                    int    memberDepth = stk.Count;
                    if (stk.Count > 0)
                    {
                        lastmsg = stk.Pop();
                        if ((lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) && (stk.Count > 0))
                        {
                            lastmsg = stk.Pop();
                        }

                        if (AutoCompleteHelper.RootNodes.ContainsKey(lastmsg))
                        {
                            n = AutoCompleteHelper.RootNodes[lastmsg];
                        }
                        else
                        {
                            AutoCompleteNodeInfo newRootNode;
                            if (ScanCodeForVariable(scintilla, lastmsg, out newRootNode))
                            {
                                n = newRootNode;
                            }
                        }
                    }

                    while (n != null && stk.Count > 0)
                    {
                        nextToLastNode = n;
                        int stkCount = stk.Count;
                        lastmsg = stk.Pop();

                        ns = n[lastmsg];
                        if (ns.Count == 1)
                        {
                            n = ns[0];
                        }
                        else
                        {
                            n = null;
                            if (stk.Count != 0)
                            {
                                ns = null;
                            }
                        }
                    }

                    if (isAutoSeek)
                    {
                        scintilla.DeleteBack();

                        if (n != null)
                        {
                            if (scintilla.CharAt(scintilla.CurrentPos - 1) == MemberSeperator)
                            {
                                scintilla.AutoCShow(0, n.MembersString);
                            }
                            else
                            {
                                scintilla.AutoCShow(n.Name.Length, nextToLastNode.MembersString);
                            }
                        }
                        else if (stk.Count == 0 && nextToLastNode != null)
                        {
                            scintilla.AutoCShow(lastmsg.Length, nextToLastNode.MembersString);
                        }
                        else if (stk.Count == 0 && n == null && nextToLastNode == null)
                        {
                            if (lastmsg == null)
                            {
                                lastmsg = string.Empty;
                            }

                            scintilla.AutoCShow(lastmsg.Length, AutoCompleteHelper.RootNodesAutoCompleteString);
                        }
                    }
                    if (isAutoMember || isCallTip)
                    {
                        if (n != null)
                        {
                            if (isAutoMember)
                            {
                                scintilla.AutoCShow(0, n.MembersString);
                            }
                        }
                        else
                        {
                            if (isAutoMember &&
                                (lastmsg != null) &&
                                (lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) &&
                                (memberDepth == 1))
                            {
                                scintilla.AutoCShow(0, AutoCompleteHelper.RootNodesAutoCompleteString);
                            }
                        }

                        if (ns != null)
                        {
                            if (isCallTip)
                            {
                                string methodSigs = string.Empty;
                                int    i          = 0;
                                foreach (AutoCompleteNodeInfo ni in ns)
                                {
                                    if (ni.MemberType == System.Reflection.MemberTypes.Method)
                                    {
                                        i++;
                                        if (methodSigs.Length > 0)
                                        {
                                            methodSigs += "\n";
                                        }
                                        //methodSigs += '\u0001' + i.ToString() + " of " + ns.Count + '\u0002' + " " + ni.ParameterString;
                                        methodSigs += ni.ParameterString;
                                    }
                                }
                                if (methodSigs.Length > 0)
                                {
                                    scintilla.CallTipShow(scintilla.CurrentPos - 1, methodSigs);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
ファイル: AutoCompleteHelper.cs プロジェクト: zhh007/MyGen
 public virtual bool ScanCodeForVariable(ZeusScintillaControl scintilla, string varname, out AutoCompleteNodeInfo node)
 {
     node = null;
     return(false);
 }
コード例 #7
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack<int> matches = new Stack<int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 86 || style == 7)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    int endWordIndex = m + word.Length;

                    char c = scintilla.CharAt(++endWordIndex);
                    List<string> words = new List<string>();
                   
                    //skip whitespace
                    while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex);

                    // get "As"
                    StringBuilder nextword = new StringBuilder();
                    do
                    {
                        nextword.Append(c);
                        c = scintilla.CharAt(++endWordIndex);
                    } while (!Char.IsWhiteSpace(c));

                    if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //skip whitespace
                        while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex);

                        // get Type
                        nextword.Remove(0, nextword.Length);
                        do
                        {
                            nextword.Append(c);
                            c = scintilla.CharAt(++endWordIndex);
                        } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator)));

                        string type = nextword.ToString();
                        List<Type> types = AutoCompleteHelper.SearchForType(type);
                        if (types.Count > 0)
                        {
                            node = new AutoCompleteNodeInfo(types[0], varname);
                            isFound = true;
                        }
                    }
                }
            }

            return isFound;
        }
コード例 #8
0
        public void HandleCharAdded(ZeusScintillaControl scintilla, bool isTagged, char ch)
        {
            bool isCtrlPressed = (Control.ModifierKeys == (System.Windows.Forms.Keys.Control | Control.ModifierKeys));
            bool isAutoSeek = IsAutoCompleteSeek(ch, isCtrlPressed);
            bool isAutoMember = IsAutoCompleteMember(ch);
            bool isCallTip = IsCallTip(ch);

            if (isAutoSeek || isAutoMember || isCallTip)
            {
                int pos = scintilla.CurrentPos - 1;
                char c = scintilla.CharAt(--pos);
                Stack<string> stk = new Stack<string>();
                List<string> lst = new List<string>();
                System.Text.StringBuilder tmp = new System.Text.StringBuilder();

                int style = scintilla.StyleAt(pos);
                if (IsCodeStyle(isTagged, style))
                {
                    while (IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (c == MemberSeperator)
                        {
                            if (tmp.Length > 0)
                            {
                                lst.Insert(0, tmp.ToString());
                                stk.Push(tmp.ToString());
                                tmp.Remove(0, tmp.Length);
                            }
                        }
                        else
                        {
                            tmp.Insert(0, c);
                        }
                        c = scintilla.CharAt(--pos);
                    }
                    if (tmp.Length > 0)
                    {
                        lst.Insert(0, tmp.ToString());
                        stk.Push(tmp.ToString());
                        tmp.Remove(0, tmp.Length);
                    }

                    AutoCompleteNodeInfo n = null;
                    AutoCompleteNodeInfo nextToLastNode = null;
                    System.Collections.Generic.List<AutoCompleteNodeInfo> ns = null;
                    string lastmsg = null, firstmsg = null;
                    int memberDepth = stk.Count;
                    if (stk.Count > 0)
                    {
                        lastmsg = stk.Pop();
                        if ((lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) && (stk.Count > 0))
                        {
                            lastmsg = stk.Pop();
                        }

                        if (AutoCompleteHelper.RootNodes.ContainsKey(lastmsg))
                        {
                            n = AutoCompleteHelper.RootNodes[lastmsg];
                        }
                        else 
                        {
                            AutoCompleteNodeInfo newRootNode;
                            if (ScanCodeForVariable(scintilla, lastmsg, out newRootNode))
                            {
                                n = newRootNode;
                            }
                        }
                    }

                    while (n != null && stk.Count > 0)
                    {
                        nextToLastNode = n;
                        int stkCount = stk.Count;
                        lastmsg = stk.Pop();

                        ns = n[lastmsg];
                        if (ns.Count == 1)
                        {
                            n = ns[0];
                        }
                        else
                        {
                            n = null;
                            if (stk.Count != 0)
                            {
                                ns = null;
                            }
                        }
                    }

                    if (isAutoSeek)
                    {
                        scintilla.DeleteBack();

                        if (n != null)
                        {
                            if (scintilla.CharAt(scintilla.CurrentPos - 1) == MemberSeperator)
                            {
                                scintilla.AutoCShow(0, n.MembersString);
                            }
                            else
                            {
                                scintilla.AutoCShow(n.Name.Length, nextToLastNode.MembersString);
                            }
                        }
                        else if (stk.Count == 0 && nextToLastNode != null)
                        {
                            scintilla.AutoCShow(lastmsg.Length, nextToLastNode.MembersString);
                        }
                        else if (stk.Count == 0 && n == null && nextToLastNode == null)
                        {
                            if (lastmsg == null) lastmsg = string.Empty;

                            scintilla.AutoCShow(lastmsg.Length, AutoCompleteHelper.RootNodesAutoCompleteString);
                        }
                    }
                    if (isAutoMember || isCallTip)
                    {
                        if (n != null)
                        {
                            if (isAutoMember)
                            {
                                scintilla.AutoCShow(0, n.MembersString);
                            }
                        }
                        else
                        {
                            if (isAutoMember && 
                                (lastmsg != null) && 
                                (lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) && 
                                (memberDepth == 1))
                            {
                                scintilla.AutoCShow(0, AutoCompleteHelper.RootNodesAutoCompleteString);
                            }
                        }

                        if (ns != null)
                        {
                            if (isCallTip)
                            {
                                string methodSigs = string.Empty;
                                int i = 0;
                                foreach (AutoCompleteNodeInfo ni in ns)
                                {
                                    if (ni.MemberType == System.Reflection.MemberTypes.Method)
                                    {
                                        i++;
                                        if (methodSigs.Length > 0) methodSigs += "\n";
                                        //methodSigs += '\u0001' + i.ToString() + " of " + ns.Count + '\u0002' + " " + ni.ParameterString;
                                        methodSigs += ni.ParameterString;
                                    }
                                }
                                if (methodSigs.Length > 0)
                                {
                                    scintilla.CallTipShow(scintilla.CurrentPos - 1, methodSigs);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
 public virtual bool ScanCodeForVariable(ZeusScintillaControl scintilla, string varname, out AutoCompleteNodeInfo node)
 {
     node = null;
     return false;
 }
コード例 #10
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex   = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd   = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack <int> matches = new Stack <int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);

            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 86 || style == 7)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos     = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd   = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    int endWordIndex   = m + word.Length;

                    char          c     = scintilla.CharAt(++endWordIndex);
                    List <string> words = new List <string>();

                    //skip whitespace
                    while (Char.IsWhiteSpace(c))
                    {
                        c = scintilla.CharAt(++endWordIndex);
                    }

                    // get "As"
                    StringBuilder nextword = new StringBuilder();
                    do
                    {
                        nextword.Append(c);
                        c = scintilla.CharAt(++endWordIndex);
                    } while (!Char.IsWhiteSpace(c));

                    if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //skip whitespace
                        while (Char.IsWhiteSpace(c))
                        {
                            c = scintilla.CharAt(++endWordIndex);
                        }

                        // get Type
                        nextword.Remove(0, nextword.Length);
                        do
                        {
                            nextword.Append(c);
                            c = scintilla.CharAt(++endWordIndex);
                        } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator)));

                        string      type  = nextword.ToString();
                        List <Type> types = AutoCompleteHelper.SearchForType(type);
                        if (types.Count > 0)
                        {
                            node    = new AutoCompleteNodeInfo(types[0], varname);
                            isFound = true;
                        }
                    }
                }
            }

            return(isFound);
        }
コード例 #11
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack<int> matches = new Stack<int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 61 || style == 11)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    //scintilla.
                    char c = scintilla.CharAt(--beginWordIndex);
                    while (Char.IsWhiteSpace(c) && (beginWordIndex > 0)) c = scintilla.CharAt(--beginWordIndex);
                    StringBuilder typeName = new StringBuilder();
                    while (this.IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (typeName.Length == 0)
                            typeName.Append(c);
                        else 
                            typeName.Insert(0, c);

                        c = scintilla.CharAt(--beginWordIndex);
                    }
                    
                    string type = typeName.ToString();
                    List<Type> types = AutoCompleteHelper.SearchForType(type);
                    if (types.Count > 0)
                    {
                        node = new AutoCompleteNodeInfo(types[0], varname);
                        isFound = true;
                    }
                } 
            }

            return isFound;
        }
コード例 #12
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex   = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd   = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack <int> matches = new Stack <int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);

            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 61 || style == 11)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos     = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd   = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    //scintilla.
                    char c = scintilla.CharAt(--beginWordIndex);
                    while (Char.IsWhiteSpace(c) && (beginWordIndex > 0))
                    {
                        c = scintilla.CharAt(--beginWordIndex);
                    }
                    StringBuilder typeName = new StringBuilder();
                    while (this.IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (typeName.Length == 0)
                        {
                            typeName.Append(c);
                        }
                        else
                        {
                            typeName.Insert(0, c);
                        }

                        c = scintilla.CharAt(--beginWordIndex);
                    }

                    string      type  = typeName.ToString();
                    List <Type> types = AutoCompleteHelper.SearchForType(type);
                    if (types.Count > 0)
                    {
                        node    = new AutoCompleteNodeInfo(types[0], varname);
                        isFound = true;
                    }
                }
            }

            return(isFound);
        }