Hi all,
I have many instances of default SynEdit class in my application. So, A small procedure was performed (see below) to comments (under SQL highlighter).
The problem: if I have a single line to be commented and it has latin characters, the final comment symbol is not positioned correctly. For example:
I want to comment the line below:
test áéíóú
The result from the procedure is the below:
/*test áéíóú*/íóú
For selection it is working fine. I do not want to use the same solution for single line to not lose undo / redo resource in the instances of the class.
How can I fix this?
procedure pSyn_Comentar(synEdt: TSynEdit);
var
sTMP: string;
i : integer;
begin
with synEdt do begin
BeginUpdate;
if (SelText = '') then begin // Will comment the line where the cursor is
sTMP:= LineText;
i:= CaretX;
CaretX:= 0;
ExecuteCommand(ecDeleteEOL,
#0,
nil);
SelText:= '/*' +
sTMP +
'*/';
CaretX:= i + 2; // Return the cursor to the original position
end
else // Comment on the selection
SelText:= '/*' +
SelText +
'*/';
EndUpdate;
end;
end;