if I write A there is no problem
if I write # or : there is a problem
Ah, well that explains it.
The completion module only looks for "A" to "Z", "0" to "9" and "_", even an accented char, or any none latin letter will not work.
Yes, that all needs to be fixed. The entire completion module needs a lot of work.
Anyway, What you need to do:
YourCompletion.OnCodeCompletion := @YourCodeToCopyTheSelectedWordIntoTheText;
// As procedure of TForm1, or any other object you choose
procedure YourCodeToCopyTheSelectedWordIntoTheText
(var Value: string; // the new/selected text/value
SourceValue: string; // the text currently between the 2 points
var SourceStart, SourceEnd: TPoint; // the begin/end of the a-z word
KeyChar: TUTF8Char;
Shift: TShiftState) of object;
2 possibilities:
1)
Adjust SourceStart, SourceEnd (both TPoint, containing line/column) to the range which you want to be replaced.
Then the module will do the replacement with your updated coordinates.
2)
Update the SynEdit yourself, and set
SourceStart := SourceEnd;
Value := '';
You can also look at SynEdit.CaretXy (or LogicalCaretXY) to find out where the Caret (| text-cursor) is
SourceStart, SourceEnd are LOGICAL
LOGICAL means the x pos is in byte, instead of screen pos.
Look at this line
xäz
x is at pos 1 (screen and logical
ä is at pos 2 and has 2 bytes in UTF8, but takes only one pos on the screen
z is at screenpos 3, BUT Logical pos 4 (because ä took 2 bytes)
similar with tabs. Tabs increase the screenpos by more than 1, but they are only 1 byte.
That probably should be added to the example.... Well if I find time...