This is how it is parsed in Microsoft SQL server Management Studio:
RadSyntaxEditorElement offers the following method: public CaretPosition GetPositionFromPoint(System.Drawing.Point point)
However, it doesn't return the correct CaretPosition as it requires to transform the System.Drawing.Point first:
private void MySyntaxEditor1_MouseDown(object sender, MouseEventArgs e)
{
CaretPosition pos = mySyntaxEditor1.SyntaxEditorElement.GetPositionFromPoint(GetPosition(e, mySyntaxEditor1.SyntaxEditorElement.EditorPresenter));
CaretPosition start = new CaretPosition(pos);
start.MoveToCurrentWordStart();
CaretPosition end = new CaretPosition(pos);
end.MoveToCurrentWordEnd();
mySyntaxEditor1.SyntaxEditorElement.Selection.Select(start, end);
}
public Telerik.WinControls.SyntaxEditor.UI.Point GetPosition(System.Windows.Forms.MouseEventArgs args, Telerik.WinControls.SyntaxEditor.UI.UIElement element)
{
System.Drawing.Point screenLocation = mySyntaxEditor1.SyntaxEditorElement.PointToScreen(args.Location);
System.Drawing.Point point = element.PointFromScreen(screenLocation);
Telerik.WinControls.Layouts.RadMatrix matrix = element.TotalTransform;
matrix.Invert();
return new System.Drawing.PointF(point.X * matrix.ScaleX, point.Y * matrix.ScaleY);
}
This is the current implementation that is used in RadSyntaxEditor when navigating to the next/previous word, start/end of the current word, etc. It would be good to have an event that allows you to specify the ChartType according to your needs and thus affecting the words navigation in the document.
internal static CharType GetCharType(char c)
{
if (CharsToBeTreatedAsDefault.Contains(c))
{
return CharType.Default;
}
if (LineBreak.IsLineBreak(c))
{
return CharType.NewLine;
}
if (char.IsWhiteSpace(c))
{
return CharType.WhiteSpace;
}
if (char.IsPunctuation(c) || char.IsSymbol(c))
{
return CharType.PunctuationOrSymbol;
}
return CharType.Default;
}
RadSyntaxEditor allows the end-users to select a part of the text and drag the selection to a new position.
Currently, there is no public API that allows you to control whether the drag operation should start, on what target line you are dragging over (and whether you can drop on it) and when you drop the selection.