Пример #1
0
        public frmIntellisense(UCEditor editor, string var, int up)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.editor    = editor;
            this.prevclass = editor.prevclass;
            this.prevfunc  = editor.prevfunc;
            this.var       = var;
            this.up        = up;

            //this.fIP = new frmIntellisensePrompt(new Point(Screen.PrimaryScreen.WorkingArea.Left, Screen.PrimaryScreen.WorkingArea.Bottom));
            this.fIP = new frmIntellisensePrompt(new Point(0, 0));

            //this.fIP.Show();
            //this.fIP.Hide();
        }
Пример #2
0
        private void SelectPrompt()
        {
            if (this.lvAutoComplete.SelectedItems.Count == 0)
            {
                return;
            }

            bDisplayingPrompt = true;

            ListViewItem selitem = this.lvAutoComplete.SelectedItems[0];
            Rectangle    rect    = selitem.GetBounds(ItemBoundsPortion.Entire);
            Point        cltpt   = new Point(lvAutoComplete.Width + 3, rect.Top);

            this.fIP.Location = this.lvAutoComplete.PointToScreen(cltpt);

            if (selitem.Tag is CAutoComplete.ClassEntry)
            {
                CAutoComplete.ClassEntry cls = (CAutoComplete.ClassEntry)selitem.Tag;
                this.fIP.SetPrompt("<b>" + cls.ClassName + "</b>" + ((cls.ClassInheritsFrom == "") ? "" : " Inherits <u>" + cls.ClassInheritsFrom + "</u>")
                                   + "<br /><i>(" + cls.func_list.Count.ToString() + " functions)</i>");
            }
            else if (selitem.Tag is CAutoComplete.ClassEntry.FuncEntry)
            {
                CAutoComplete.ClassEntry.FuncEntry func = (CAutoComplete.ClassEntry.FuncEntry)selitem.Tag;
                this.fIP.SetPrompt("<u>" + func.func_ret + "</u> <b>" + func.func_name + "</b> (" + func.func_params.Replace("<", "&lt;") + ")" + ((func.func_descr != "") ? "<br />[" + func.func_descr.Replace("<", "&lt;") + "]" : ""));
            }
            else if (selitem.Tag is CAutoComplete.ClassEntry.PropEntry)
            {
                CAutoComplete.ClassEntry.PropEntry prop = (CAutoComplete.ClassEntry.PropEntry)selitem.Tag;
                this.fIP.SetPrompt(prop.prop_type + " <b>" + prop.prop_name + "</b>");
            }
            else
            {
                this.fIP.SetPrompt("<i>" + selitem.Text + "</i>");
            }

            this.fIP.Show();
            this.fIP.BringToFront();

            this.lvAutoComplete.Focus();

            bDisplayingPrompt = false;
        }
Пример #3
0
        private void lvAutoComplete_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            this.fIP.Hide();

            if (e.KeyCode == Keys.Escape)
            {
                editor.txtEditor.Focus();
                this.Close();
                this.Dispose();
            }
            else if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.End || e.KeyCode == Keys.Home)
            {
                // Update the side listing
                SelectPrompt();
            }
            else if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Right)
            {
                // Displays the members of the selected object, if it's a class
                if (this.lvAutoComplete.SelectedItems.Count == 0)
                {
                    return;
                }

                if (!(this.lvAutoComplete.SelectedItems[0].Tag is CAutoComplete.ClassEntry))
                {
                    return;
                }

                this.prevclass = (CAutoComplete.ClassEntry) this.lvAutoComplete.SelectedItems[0].Tag;

                UpdateClassMembers((CAutoComplete.ClassEntry) this.lvAutoComplete.SelectedItems[0].Tag);
            }
            else if (e.KeyCode == Keys.Left)
            {
                // Displays the previous class's information
                if (this.lvAutoComplete.SelectedItems.Count > 0 && this.lvAutoComplete.SelectedItems[0].Tag is CAutoComplete.ClassEntry.FuncEntry)
                {
                    this.prevfunc = (CAutoComplete.ClassEntry.FuncEntry)lvAutoComplete.SelectedItems[0].Tag;
                }

                UpdateMainClassList();
            }
            else if (e.KeyCode == Keys.Enter)
            {
                // Commit an item to the active editor
                if (this.lvAutoComplete.SelectedItems.Count == 0)
                {
                    return;
                }

                if (this.lvAutoComplete.SelectedItems[0].Tag is CAutoComplete.ClassEntry)
                {
                    this.prevclass = (CAutoComplete.ClassEntry)lvAutoComplete.SelectedItems[0].Tag;

                    if (var != "")
                    {
                        int line = editor.txtEditor.SelectedView.Selection.EndPosition.Line;
                        int chr  = editor.txtEditor.SelectedView.Selection.EndPosition.Character;

                        TextStream ts = editor.txtEditor.Document.GetTextStream(editor.txtEditor.SelectedView.Selection.StartOffset);
                        ts.GoToPreviousToken("LineTerminatorToken");

                        editor.txtEditor.SelectedView.Selection.StartOffset = ts.CurrentToken.EndOffset;
                        editor.txtEditor.SelectedView.InsertLineBreak();
                        ts = editor.txtEditor.Document.GetTextStream(ts.CurrentToken.StartOffset);
                        ts.GoToNextToken("LineTerminatorToken");
                        editor.txtEditor.SelectedView.Selection.StartOffset = ts.CurrentToken.EndOffset;

                        editor.txtEditor.SelectedView.Selection.StartOffset = ts.CurrentToken.EndOffset;
                        editor.txtEditor.SelectedView.InsertText("//# DECLARE " + var + " as " + (this.lvAutoComplete.SelectedItems[0].Tag as CAutoComplete.ClassEntry).ClassName);

                        editor.txtEditor.SelectedView.Selection.StartOffset = editor.txtEditor.Document.PositionToOffset(new Position(line + 1, chr));
                    }
                    else
                    {
                        editor.txtEditor.SelectedView.InsertText((this.lvAutoComplete.SelectedItems[0].Tag as CAutoComplete.ClassEntry).ClassName + " ");
                    }
                }
                else if (this.lvAutoComplete.SelectedItems[0].Tag is CAutoComplete.ClassEntry.FuncEntry)
                {
                    this.prevfunc = (CAutoComplete.ClassEntry.FuncEntry)lvAutoComplete.SelectedItems[0].Tag;
                    editor.txtEditor.SelectedView.InsertText((this.lvAutoComplete.SelectedItems[0].Tag as CAutoComplete.ClassEntry.FuncEntry).func_name);
                }
                else if (this.lvAutoComplete.SelectedItems[0].Tag is CAutoComplete.ClassEntry.PropEntry)
                {
                    editor.txtEditor.SelectedView.InsertText((this.lvAutoComplete.SelectedItems[0].Tag as CAutoComplete.ClassEntry.PropEntry).prop_name);
                }
                else
                {
                    return;
                }

                editor.txtEditor.Focus();
                this.Close();
                this.Dispose();

                this.fIP.Close();
                this.fIP.Dispose();
            }
        }