Exemplo n.º 1
0
        public bool CtrlSpace(ITextEditor editor)
        {
            int elementStartIndex = XmlParser.GetActiveElementStartIndex(editor.Document.Text, editor.Caret.Offset);

            if (elementStartIndex <= -1)
            {
                return(false);
            }
            if (ElementStartsWith("<!", elementStartIndex, editor.Document))
            {
                return(false);
            }
            if (ElementStartsWith("<?", elementStartIndex, editor.Document))
            {
                return(false);
            }

            XmlSchemaCompletion defaultSchema = schemaFileAssociations.GetSchemaCompletion(editor.FileName);

            XmlCompletionItemCollection completionItems = GetCompletionItems(editor, defaultSchema);

            if (completionItems.HasItems)
            {
                completionItems.Sort();
                string identifier = XmlParser.GetXmlIdentifierBeforeIndex(editor.Document, editor.Caret.Offset);
                completionItems.PreselectionLength = identifier.Length;
                ICompletionListWindow completionWindow = editor.ShowCompletionWindow(completionItems);
                if (completionWindow != null)
                {
                    SetCompletionWindowWidth(completionWindow, completionItems);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
        {
            XmlSchemaCompletion         defaultSchema   = schemaFileAssociations.GetSchemaCompletion(editor.FileName);
            XmlCompletionItemCollection completionItems = GetCompletionItems(editor, ch, defaultSchema);

            if (completionItems.HasItems)
            {
                completionItems.Sort();
                ICompletionListWindow completionWindow = editor.ShowCompletionWindow(completionItems);
                if (completionWindow != null)
                {
                    SetCompletionWindowWidth(completionWindow, completionItems);
                }
            }

            if ((ch == '<') || (ch == ' ') || (ch == '='))
            {
                return(CodeCompletionKeyPressResult.Completed);
            }
            return(CodeCompletionKeyPressResult.None);
        }