| pes some lines in its editor, to see if it flickers at all. It does. But only when it is changing colors when it recognizes a change has occured. Otherwise it doesn''''t bother. Now look at what’s happening in our "editor". Do you see?
The problem is that we are not "conserving" what we are doing. If something is still the same TokenType it doesn''''t need to be re-highlighted because it already correct on the screen. We need to check if the TokenType of each token has changed since last time we repainted this line, and only then repaint to.
In fact we don''''t need to do even that - we can just check whether the SelAttributes (which represents the current selection''''s attributes) is any different from what we want to change it to i.e. FParseFont[MyTokenType]. This way if even the TokenType had changed, but the new and old TokenType shared the same display attributes, we would still conserve our drawing.
Actually the problems is that the RichEdit isn''''t doing the conserving. In the old text based system I used to use, if you printed something to the screen, and it was the same as something already on the screen, in the same position, then the program would not rewrite it to the screen. It would "conserve" the amount of writing it did, as in the old days 1200 baud screens were SLOW, and printing the same characters was a waste of time.
Huh - and people said we have come so dar with windows. Sloppy, Sloppy, Sloppy I say! :-)
So lets replace:
MyRe.SelAttributes.Assign(PasCon.FParseFont[MyTokenState]);
with:
If MyRe.SelAttributes.Name <> PasCon.FParseFont[MyTokenState].Name then MyRe.SelAttributes.Name := PasCon.FParseFont[MyTokenState].Name;
If MyRe.SelAttributes.Color <> PasCon.FParseFont[MyTokenState].Color then MyRe.SelAttributes.Color := PasCon.FParseFont[MyTokenState].Color;
if MyRe.SelAttributes.Style <> PasCon.FParseFont[MyTokenState].Style then MyRe.SelAttributes.Style := PasCon.FParseFont[MyTokenState].Style;
And off you go and try it out... (PS. Yes the last bit of code is bad programming...)
上一页 [1] [2] [3] |