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(); }
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("<", "<") + ")" + ((func.func_descr != "") ? "<br />[" + func.func_descr.Replace("<", "<") + "]" : "")); } 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; }
private void MergeInherited(ClassEntry base_cls, string class_name) { if (!this._obj.ContainsKey(class_name.ToLower())) { return; } CAutoComplete.ClassEntry cls = (ClassEntry)this._obj[class_name.ToLower()]; if (cls.ClassInheritsFrom == cls.ClassName) { return; } if (cls.ClassInheritsFrom != "") { MergeInherited(cls, cls.ClassInheritsFrom); } foreach (ClassEntry.FuncEntry func in cls.func_list.Values) { if (base_cls.func_list.ContainsKey(func.func_name.ToLower())) { //base_cls.func_list.Remove(base_cls.func_list[func.func_name.ToLower()]); continue; } base_cls.func_list.Add(func.func_name.ToLower(), func); } foreach (ClassEntry.PropEntry prop in cls.prop_list.Values) { if (base_cls.prop_list.ContainsKey(prop.prop_name.ToLower())) { //base_cls.prop_list.Remove(base_cls.prop_list[prop.prop_name.ToLower()]); continue; } base_cls.prop_list.Add(prop.prop_name.ToLower(), prop); } }
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(); } }
private void UpdateClassMembers(CAutoComplete.ClassEntry cls) { this.lvAutoComplete.Focus(); this.lvAutoComplete.Select(); this.lvAutoComplete.Items.Clear(); this.lvAutoComplete.BeginUpdate(); string item_header = "! " + cls.ClassName + ((cls.ClassInheritsFrom == "") ? "" : " : " + cls.ClassInheritsFrom) + " Members"; int longest_member = item_header.Length; this.lvAutoComplete.Items.Add(new ListViewItem(item_header, 3)); // Add all the functions foreach (CAutoComplete.ClassEntry.FuncEntry func in cls.func_list.Values) { string entryname = func.func_name; ListViewItem newitem = new ListViewItem(entryname, 0); newitem.Tag = func; if (this.prevfunc != null) { if (func == prevfunc) { newitem.Focused = true; newitem.Selected = true; } } this.lvAutoComplete.Items.Add(newitem); if (entryname.Length > longest_member) { longest_member = entryname.Length; } } // Add all the properties foreach (CAutoComplete.ClassEntry.PropEntry prop in cls.prop_list.Values) { string entryname = prop.prop_name; ListViewItem newitem = new ListViewItem(entryname, 4); newitem.Tag = prop; this.lvAutoComplete.Items.Add(newitem); if (entryname.Length > longest_member) { longest_member = entryname.Length; } } this.col1.Width = -1; this.Width = col1.Width + 25; this.lvAutoComplete.EndUpdate(); if (this.lvAutoComplete.SelectedItems.Count > 0) { this.lvAutoComplete.SelectedItems[0].EnsureVisible(); this.lvAutoComplete.SelectedItems[0].Focused = true; this.lvAutoComplete.SelectedItems[0].Selected = true; } else { this.lvAutoComplete.Items[0].EnsureVisible(); this.lvAutoComplete.Items[0].Selected = true; this.lvAutoComplete.Items[0].Focused = true; } this.lvAutoComplete.Focus(); SelectPrompt(); }