Browse Source

port XmlEditor CC to NR5

newNRvisualizers
Siegfried Pammer 14 years ago
parent
commit
8af8988104
  1. 18
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
  2. 3
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs

18
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs

@ -31,15 +31,7 @@ namespace ICSharpCode.XmlEditor
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{ {
if (char.IsWhiteSpace(ch) || editor.SelectionLength > 0) return CodeCompletionKeyPressResult.None;
return CodeCompletionKeyPressResult.None;
if (ignoredChars.Contains(ch))
return CodeCompletionKeyPressResult.None;
if (XmlParser.GetXmlIdentifierBeforeIndex(editor.Document, editor.Caret.Offset).Length > 0)
return CodeCompletionKeyPressResult.None;
editor.Document.Insert(editor.Caret.Offset, ch.ToString());
CtrlSpace(editor);
return CodeCompletionKeyPressResult.EatKey;
} }
XmlCompletionItemCollection GetCompletionItems(ITextEditor editor, XmlSchemaCompletion defaultSchema) XmlCompletionItemCollection GetCompletionItems(ITextEditor editor, XmlSchemaCompletion defaultSchema)
@ -88,7 +80,13 @@ namespace ICSharpCode.XmlEditor
public bool HandleKeyPressed(ITextEditor editor, char ch) public bool HandleKeyPressed(ITextEditor editor, char ch)
{ {
return false; if (char.IsWhiteSpace(ch) || editor.SelectionLength > 0)
return false;
if (ignoredChars.Contains(ch))
return false;
if (XmlParser.GetXmlIdentifierBeforeIndex(editor.Document, editor.Caret.Offset).Length > 1)
return false;
return CtrlSpace(editor);
} }
} }
} }

3
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs

@ -7,6 +7,7 @@ using System.IO;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
namespace ICSharpCode.XmlEditor namespace ICSharpCode.XmlEditor
@ -689,7 +690,7 @@ namespace ICSharpCode.XmlEditor
return (ch == '\"') || (ch == '\''); return (ch == '\"') || (ch == '\'');
} }
public static string GetXmlIdentifierBeforeIndex(ITextBuffer document, int index) public static string GetXmlIdentifierBeforeIndex(ITextSource document, int index)
{ {
if (document == null) if (document == null)
throw new ArgumentNullException("document"); throw new ArgumentNullException("document");

Loading…
Cancel
Save