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 CompleteElementTag(ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor, int offset) { string str = null; TextStream textStream = syntaxEditor.get_Document().GetTextStream(offset); if (textStream.GoToPreviousToken() && ((textStream.get_Token().get_Key() == "StartTagEndToken") && ((offset - textStream.get_Offset()) == 1))) { bool flag = false; while (textStream.GoToPreviousToken()) { string str2 = textStream.get_Token().get_Key(); if (str2 != null) { if (!(str2 == "StartTagNameToken")) { if ((str2 == "StartTagStartToken") || (str2 == "EndTagEndToken")) { return; } } else { str = textStream.get_TokenText().Trim(); flag = true; } } if (flag) { break; } } if (str != null) { textStream.set_Offset(offset); flag = false; while (!textStream.get_IsAtDocumentEnd()) { switch (textStream.get_Token().get_Key()) { case "EndTagDefaultToken": if (str == textStream.get_TokenText().Trim()) { return; } flag = true; break; case "StartTagStartToken": case "EndTagEndToken": flag = true; break; } if (flag) { break; } textStream.GoToNextToken(); } syntaxEditor.get_SelectedView().InsertSurroundingText(0, null, "</" + str + ">"); } } }