|
From: <520...@t-...> - 2001-03-25 11:09:32
|
Dear all,
i made a tex highlighter that is derivated from SynHighlighterHP48.pas.
First let me explain a bit of TeX: there is 'control-sequences' starting
with '\' and ending with ' ' (e.g: \bf) and their is environments (starting
either with '{', '[' or '$' and ending with '}', ']' or again '$'. Now I
want teXSyn2 have to background-color the text between these char, e.g.
'This is a text $mathmode says: a^2+b^2=c^2$ ' --> 'mathmode says:
a^2+b^2=c^2' should have text-foreground color and mathmode
background-color.
So I have:
---
procedure TSynTeX2Syn.MakeMethodTables;
var
i: Char;
begin
for i := #0 to #255 do
case i of
#0 : fProcTable[i] := NullProc;
#10 : fProcTable[i] := LFProc;
#13 : fProcTable[i] := CRProc;
#36 : fProcTable[i] := MathmodeProc;
...
#1..#9, #11, #12, #14..#32 : fProcTable[i] := SpaceProc;
else
fProcTable[i] := TextProc;
---
where MathmodeProc looks like:
procedure TSynTeX2Syn.MathModeProc;
begin
finMathMode:=not(finMathMode);
fTokenID:=tkMathMode;
Inc(Run);
end; { MathModeProc }
This changes a private finMathmode Boolean. Now TextProc looks like:
procedure TSynTeX2Syn.TextProc;
begin
if (finMathMode) then
fTokenID:=tkTextMMBK
else
fTokenID:=tkText;
inc(Run);
end; { TextProc }
tkTextMMBK is tkText with additional background color.
That all works fine if $-environment is single-line and if i don't change
the synedit content ;(. If I delete the first $ in 'test $A_t$ und $B_t$' it
bg colors his is a text 'test ' and not '$ und $'. But if the window
containing the synedit looses the focus and is activated again, everything
is fine.
makes sense to you ? please explain it to me - maybe synedit needs to redraw
everything if i change this '$' - but think about the speed loss if their
are many environments ...
Has anybody an idea how this could be solved ?
Many thanx in advance
Sören
P.s. plz excude the bad english...
|