My implementation inherits attributes from the previous character. Doing so seems logical for me, but it makes a problem. I have to activate EM_HIDESELECTION to stop the flashing, and I have not found a way to hide the caret. The caret dances around as it searches for a valid character to use as a basis for determining the active language.
...
Do you have a way for hiding the caret?
I can think of two ways to do that:
1:
try to use
GetStyleRange in conjunction with
GetText.
GetStyleRange - should find the style range for you.
GetText - should extract the text for you w/o tempering with the current selection. (you might need to update to the latest revision for that, since there was a bug, that prevent any text from being extracted)
2: use Lines.BeginUpdate / Lines.EndUpdate.
Whenever a Lines.BeginUpdate is called all visual updates are stopped and will not happen (thus the caret would not flicker).
Lines.BeginUpdate;
try
...search for the word/style...
... other code...
finally
Lines.EndUpdate;
end;
It is highly recommended to use try .. finally, in order to start and finish the update operation.
If there's any exception occurs during the processing, you want to make sure that EndUpdate is called.
Otherwise your component might look up frozen, after the exception is processed.
(an exception might be presented to a user as an error dialog. And it might not cause the application crash).
Oh yes... you also need to test the code on Phoenician languages too. Since a character for them occupies more than a single widechar, you'll need to make your case statement more complex.