Posted 15 years ago
by Alessandro Sorcinelli
Hello,
I've some problem with caret offset and substring function.
I need to replace some old control in an old editor.
In this editor I have a function that insert text in the middle of his content.
This function use the current caret position and the String.substring method.
I would like to replicate this base funcionality with SyntaxEditor. I know that there are multiple
other ways to insert code, but I need to use the old funcion.
What I'm trying to do is very very simple:
Dim pos As Integer = editor.Caret.Offset
Dim txt As String = "<sample text>"
editor.Text = editor.Text.Substring(0, pos) + txt + editor.Text.Substring(pos)
The old editor (a simple RichTextBox) works fine with this code.
With SyntaxEditor I have a strange behavior.
I'm using HTML syntax file and I have the seguent sample file:
<script runat="server">
private sub TestFunction()
end sub
</script>
<BR />
If I move the caret before the <br/> and call the previous code lines, my sample string is inserted in the middle of the </script> tag.
Is it bug?
Is it possible to correct this behaviour?
Thanks, Alessandro
[Modified at 11/17/2009 01:10 PM]
I've some problem with caret offset and substring function.
I need to replace some old control in an old editor.
In this editor I have a function that insert text in the middle of his content.
This function use the current caret position and the String.substring method.
I would like to replicate this base funcionality with SyntaxEditor. I know that there are multiple
other ways to insert code, but I need to use the old funcion.
What I'm trying to do is very very simple:
Dim pos As Integer = editor.Caret.Offset
Dim txt As String = "<sample text>"
editor.Text = editor.Text.Substring(0, pos) + txt + editor.Text.Substring(pos)
The old editor (a simple RichTextBox) works fine with this code.
With SyntaxEditor I have a strange behavior.
I'm using HTML syntax file and I have the seguent sample file:
<script runat="server">
private sub TestFunction()
end sub
</script>
<BR />
If I move the caret before the <br/> and call the previous code lines, my sample string is inserted in the middle of the </script> tag.
Is it bug?
Is it possible to correct this behaviour?
Thanks, Alessandro
[Modified at 11/17/2009 01:10 PM]