public bool InsertAction(TextArea textArea, char ch) { if ((dataType == DataType.XmlElement)) { textArea.InsertString(text); } else if (dataType == DataType.XmlAttributeValue) { if( XmlParser.IsInsideAttributeValue(textArea.Document.TextContent,textArea.Caret.Offset)) { int first, last; XmlParser.GetCurrentAttributeValueSpan(textArea.Document.TextContent, textArea.Caret.Offset, out first, out last); if (last > first && last > 0) { textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(first) , textArea.Document.OffsetToPosition(last) ); textArea.SelectionManager.RemoveSelectedText(); } } textArea.InsertString(text); Caret caret = textArea.Caret; // Move caret outside of the attribute quotes. caret.Position = textArea.Document.OffsetToPosition(caret.Offset + 1); } else if (dataType == DataType.NamespaceUri) { textArea.InsertString(String.Concat("\"", text, "\"")); } else { // Insert an attribute. Caret caret = textArea.Caret; textArea.InsertString(String.Concat(text, "=\"")); // Move caret into the middle of the attribute quotes. caret.Position = textArea.Document.OffsetToPosition(caret.Offset - 1); textArea.SimulateKeyPress('\"'); } return false; }