コード例 #1
0
        bool checkForDotNetItem()
        {
            ICSharpCode.TextEditor.TextLocation      cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position;
            ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column);

            if (tw != null)
            {
                Position pos = default(Position);
                if (isDotNetItem(tw.Word, ref pos))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        void __showhelpf1(object state)
        {
            ICSharpCode.TextEditor.TextLocation      cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position;
            ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column);

            if (tw != null)
            {
                MetadataType metadata_type = MetadataType.Class;

                /*if (isDotNetItem(tw.Word, ref metadata_type))
                 * {
                 *  //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex);
                 *  //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word);
                 *  //Help.ShowHelp(this, DotNetHelpFileName);
                 *  //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex);
                 *  //Help.ShowHelpIndex(this, DotNetHelpFileName);
                 *  //Help.ShowHelp(this, DotNetHelpFileName,HelpNavigator.KeywordIndex, tw.Word);
                 *  AddTabWithUrl(MainDockPanel, tw.Word, getMSDNUrlByName(tw.Word));
                 *  Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.TableOfContents);
                 *
                 *  switch (metadata_type)
                 *  {
                 *      case MetadataType.Class: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " êëàññ"); break;
                 *      case MetadataType.Constructor: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + "." + tw.Word + " êîíñòðóêòîðû"); break;
                 *      case MetadataType.Delegate: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " äåëåãàò"); break;
                 *      case MetadataType.Enumeration: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ïåðå÷èñëåíèå"); break;
                 *      case MetadataType.EnumerationMember: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ýëåìåíò ïåðå÷èñëåíèÿ"); break;
                 *      case MetadataType.Event: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ñîáûòèå"); break;
                 *      case MetadataType.Field: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ïîëå"); break;
                 *      case MetadataType.Interface: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " èíòåðôåéñ"); break;
                 *      case MetadataType.Method: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ìåòîä"); break;
                 *      case MetadataType.Property: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ñâîéñòâî"); break;
                 *      case MetadataType.Struct: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " çàïèñü"); break;
                 *  }
                 *
                 * }
                 * else*/
                {
                    Help.ShowHelp(this, HelpFileName, HelpNavigator.TableOfContents);
                    Help.ShowHelp(this, HelpFileName, HelpNavigator.KeywordIndex, tw.Word);
                }
            }
            else
            {
                Help.ShowHelp(this, HelpFileName, HelpNavigator.KeywordIndex, "PascalABC"); // ôèêòèâíûé âûçîâ. Íóæåí ÷òîáû îêíî ñïðàâêè íå ïîêàçûâàëîñü Always on Top
                Help.ShowHelp(this, HelpFileName);
            }
        }
コード例 #3
0
        void __showDotNetHelp()
        {
            ICSharpCode.TextEditor.TextLocation      cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position;
            ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column);

            if (tw != null)
            {
                Position pos = default(Position);
                if (isDotNetItem(tw.Word, ref pos))
                {
                    if (pos.full_metadata_title != null)
                    {
                        AddTabWithUrl(MainDockPanel, pos.full_metadata_title, getMSDNUrlByName(tw.Word, pos));
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        bool TextAreaKeyEventHandler(char key)
        {
            if (m_code_complete != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it
                if (m_code_complete.ProcessKeyEvent(key))
                {
                    return(true);
                }
            }

            ICSharpCode.TextEditor.Gui.CompletionWindow.ICompletionDataProvider completionDataProvider = CodeComplete.GetCompletionProvider(this, key);
            if (completionDataProvider == null && key == '(')
            {
                ICSharpCode.TextEditor.Document.LineSegment line = this.Document.GetLineSegment(ActiveTextAreaControl.Caret.Line);
                if (null == line)
                {
                    return(false);
                }

                List <ICSharpCode.TextEditor.Document.TextWord> words = line.Words;
                if (words == null || words.Count < 1)
                {
                    return(false);
                }

                ICSharpCode.TextEditor.Document.TextWord lastWord = words[words.Count - 1];
                if (lastWord.Type != ICSharpCode.TextEditor.Document.TextWordType.Word)
                {
                    return(false);
                }
                // Todo: Remove hard coded colors
                if (lastWord.Color == System.Drawing.Color.Green || lastWord.Color == System.Drawing.Color.Red)
                {
                    return(false);
                }

                // make sure first real word on this line is not "def"
                for (int i = 0; i < words.Count; i++)
                {
                    if (words[i].Type != ICSharpCode.TextEditor.Document.TextWordType.Word)
                    {
                        continue;
                    }
                    if (words[i].Word.Equals("def", StringComparison.Ordinal))
                    {
                        return(false);
                    }
                    break;
                }

                char c = lastWord.Word[0];
                if (char.IsLetter(c))
                {
                    // Build up a python script to execute
                    int           line_number = this.ActiveTextAreaControl.TextArea.Caret.Line;
                    StringBuilder script      = new StringBuilder();
                    for (int i = 0; i < line_number; i++)
                    {
                        line = this.ActiveTextAreaControl.TextArea.Document.GetLineSegment(i);
                        if (line != null && line.Words.Count > 2)
                        {
                            string firstword = line.Words[0].Word;
                            if (firstword.Equals("import", StringComparison.Ordinal) || firstword.Equals("from"))
                            {
                                script.AppendLine(this.ActiveTextAreaControl.TextArea.Document.GetText(line));
                            }
                        }
                    }

                    ICSharpCode.TextEditor.Document.LineSegment lastLine = this.ActiveTextAreaControl.TextArea.Document.GetLineSegment(line_number);
                    if (null == lastLine)
                    {
                        return(false);
                    }

                    //walk backward through the line until we hit something that is NOT a word or period
                    string evaluation = "";
                    for (int i = lastLine.Words.Count - 1; i >= 0; i--)
                    {
                        ICSharpCode.TextEditor.Document.TextWord word = lastLine.Words[i];
                        if (word.Type != ICSharpCode.TextEditor.Document.TextWordType.Word)
                        {
                            break;
                        }
                        c = word.Word[0];
                        if (c != '.' && !char.IsLetter(c))
                        {
                            break;
                        }
                        evaluation = evaluation.Insert(0, word.Word);
                    }

                    if (evaluation != "if" && evaluation != "while")
                    {
                        RhinoDLR_Python.Intellisense isense = m_intellisense;
                        if (isense == null)
                        {
                            isense = CodeComplete.Intellisense;
                        }
                        string rc = isense.EvaluateHelp(script.ToString(), evaluation);
                        if (!string.IsNullOrEmpty(rc) && null != m_help_callback)
                        {
                            m_help_callback(rc);
                        }
                    }
                }
            }
            else if (completionDataProvider != null)
            {
                ScriptEditor.Model.ScriptDocument doc = ScriptEditor.Model.Documents.DocumentFromId(DocumentId);
                string path = "none";
                if (doc != null && !string.IsNullOrEmpty(doc.FullPath))
                {
                    path = doc.FullPath;
                }

                m_code_complete = ICSharpCode.TextEditor.Gui.CompletionWindow.CodeCompletionWindow.ShowCompletionWindow(
                    m_mainform,             // The parent window for the completion window
                    this,                   // The text editor to show the window for
                    path,                   // Filename - will be passed back to the provider
                    completionDataProvider, // Provider to get the list of possible completions
                    key                     // Key pressed - will be passed to the provider
                    );
                if (m_code_complete != null)
                {
                    // ShowCompletionWindow can return null when the provider returns an empty list
                    m_code_complete.Closed += new EventHandler(CloseCodeCompletionWindow);
                }
            }
            return(false);
        }