"Thomas Due" <
XXXX@XXXXX.COM>writes
Quote
Ryan VanIderstine writes:
Yeah I struggled with the AV too. It _seems_ that it happens if I miss a
character in HighlightCodes.
You should be able to clear those up with the following code at the start of
the Tokenize method
var
i: Integer;
p: POTASyntaxCode;
begin
if LineBufLen <= 0 then Exit;
p := HighlightCodes;
for i := 0 to LineBufLen - 1 do begin
p^ := 0;
Inc( p );
end;
Sometimes the highlight codes are altogether out of wack (in the incoming
bytes) so I assume you are responsible for actually setting them each and
every time. Rather than using 0 you might use atHotLink so it points out
where you are skipping chars if you are doing that. The code above will do
it but you can probably get away with a FillChar( p^, LineBufLen, 0 ); for
an added performance boost.
I did play with it a bit. I think you will need to use the TokenizeLineClass
to assist in classifying the lines. I started playing your code a bit but
found a pretty strange behaviour. I set up line classes of (0, 1, 2) which
map to normal, start of a comment, and in a comment. However, when I return
the type that line maps to it actually uses the +last+ one I returned (i.e.
so line #2 has the StartClass I returned for line #1 and so on).
Anyway, it was nice to see highlighted css files even if it was a bit on the
buggy side.
Perhaps one of the Borland people can shed some light on the LineClass bits
and any other helpful hints.