procedure TForm1.syntaxtimerTimer(Sender: TObject);
var textselstart,textsellength:integer;
var codetext:TRichEdit;
var temptext:TStringList;
Begin
textselstart:=text.SelStart;
textsellength:=text.SelLength;
temptext:=TStringList.Create;
codetext:=TRichEdit.Create(Form1);
temptext.Text:=text.Text;
temptext.Text:=StringReplace(temptext.text, '
}', '
[zU]', [rfReplaceAll]);
temptext.Text:=StringReplace(temptext.text, '
{', '
[aUF]', [rfReplaceAll]);
codetext.text:='
{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil MS Sans Serif;}}{\colortbl ;\red0\green0\blue255;\red100\green0\blue100;\red0\green200\blue0;\red150\green150\blue150;\red0\green150\blue150;}\viewkind4\uc1\pard\f0\fs16';
codetext.text:=codetext.text+StringReplace(temptext.Text, '
<', '
\cf1<', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
>', '
>\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
//', '
\cf4//\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
/*', '
\cf4/*\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
*/', '
\cf4*/\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
<script', '
\cf2<script', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
</script>', '
\cf2</script>\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
<!--', '
\cf2<!--', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
-->', '
\cf2-->\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
function', '
\b function\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
if', '
\b if\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
else', '
\b else\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
while', '
\b while\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
for', '
\b for\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
foreach', '
\b foreach\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
var', '
\b var\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
array', '
\b array\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
"', '
\b "\b0 ', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
<?', '
\cf3<?', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
?>', '
\cf3?>\cf0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
[zU]', '
{\}}', [rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '
[aUF]', '
{\{}', [rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, chr(13), '
\par', [rfIgnoreCase,rfReplaceAll])+'
}';
text.text:=codetext.Text;
text.SelStart:=textselstart+1000;
text.SelStart:=textselstart;
text.SelLength:=textsellength;
codetext.Destroy;
temptext.Destroy;
end;