We would stop prematurely. So this "logic" wont help in all situations.
You can still get the "someone is chasing you effect" - except now its "someone is fleeing from you" effect. It happens when you have (* This is a comment *) and delete the first *-character. The control takes an appreciable time to rehighlight the text.
While looking for a fix for the last problem, I remembered the Richedit.Lines.BeginUpdate function. But that didn''''t help either. What we need is a Richedit.BeginUpdate. What would that do? It would increase an internal counter by one everytime it was called. RichEdit.EndUpdate would do the opposite. Then we would create our own WM_PAINT message handler. This is received everytime Windows wants the control to repaint a portion of itself. If we catch this message then we can stop processing of these message until the internal counter = 0 again. Then, and only then, will the Control repaint itself - ditching we would hope most of the intervening steps.
Fixing the mult-line comments:
My current idea is to use the RichEdit.Lines.Object to store the TokenType of the first token on each line. This way we could easily know how far we need to go when re-hightlighting multi-line comments. Initially this would be set to nil. I think this will work.
[Editor update: This didn''''t actually work - as the RichEdit.Lines.Object isn''''t implemented in TRichEdit control. It is always nil regardless of what you assigned to it]
Upgrading to RichEdit98:
I''''m also in the process of updating to the RichEdit98 components for Delphi 3.0-4.0. version 1.34 Author Alexander Obukhov, Minsk, Belarus. This control has a number of advances on the standard RichEdit control that ships with Delphi. Included in this are:
- BeginUpdate,EndUpdate
- Independant background colours
- Margins
- Hotspots
- (Source code in full)
Anyway I hope you have enjoyed the adventure.I''''m sorry if not all the examples compile as written. They may need some fixing to compile if you copy straight from the Browser into the Delphi Editor. Please send any comments to jonhd@hotmail.com.
Jon HogDog
上一页 [1] [2] |