mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-07 20:46:06 +02:00
+ Fixed syntax highlighting. Asm blocks now also correct
git-svn-id: trunk@3859 -
This commit is contained in:
parent
42bd89095f
commit
8b6142e9b3
@ -1193,103 +1193,83 @@ end;
|
|||||||
|
|
||||||
function THTMLWriter.AppendPasSHFragment(Parent: TDOMNode;
|
function THTMLWriter.AppendPasSHFragment(Parent: TDOMNode;
|
||||||
const AText: String; AShFlags: Byte): Byte;
|
const AText: String; AShFlags: Byte): Byte;
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
CurParent: TDOMNode;
|
|
||||||
Line, Last, p: PChar;
|
Line, Last, p: PChar;
|
||||||
IsInSpecial: Boolean;
|
IsInSpecial: Boolean;
|
||||||
|
lastwasasm : boolean;
|
||||||
El: TDOMElement;
|
El: TDOMElement;
|
||||||
|
|
||||||
|
Procedure MaybeOutput;
|
||||||
|
|
||||||
|
Var
|
||||||
|
CurParent: TDomNode;
|
||||||
|
|
||||||
|
begin
|
||||||
|
If (Last<>Nil) then
|
||||||
|
begin
|
||||||
|
If (el<>Nil) then
|
||||||
|
CurParent:=El
|
||||||
|
else
|
||||||
|
CurParent:=Parent;
|
||||||
|
AppendText(CurParent,Last);
|
||||||
|
El:=Nil;
|
||||||
|
Last:=Nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function NewEl(Const ElType,Attr,AttrVal : String) : TDomElement;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=CreateEl(Parent,ElType);
|
||||||
|
Result[Attr]:=AttrVal;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function NewSpan(Const AttrVal : String) : TDomElement;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=CreateEl(Parent,'span');
|
||||||
|
Result['class']:=AttrVal;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GetMem(Line, Length(AText) * 3 + 4);
|
GetMem(Line, Length(AText) * 3 + 4);
|
||||||
|
Try
|
||||||
DoPascalHighlighting(AShFlags, PChar(AText), Line);
|
DoPascalHighlighting(AShFlags, PChar(AText), Line);
|
||||||
Result := AShFlags;
|
Result := AShFlags;
|
||||||
|
|
||||||
CurParent := Parent;
|
|
||||||
IsInSpecial := False;
|
IsInSpecial := False;
|
||||||
Last := Line;
|
Last := Nil;
|
||||||
p := Line;
|
p := Line;
|
||||||
|
el:=nil;
|
||||||
while p[0] <> #0 do
|
while p[0] <> #0 do
|
||||||
begin
|
begin
|
||||||
if p[0] = LF_ESCAPE then
|
if p[0] = LF_ESCAPE then
|
||||||
begin
|
begin
|
||||||
p[0] := #0;
|
p[0] := #0;
|
||||||
AppendText(CurParent, Last);
|
MaybeOutput;
|
||||||
|
|
||||||
if IsInSpecial then
|
|
||||||
CurParent := Parent;
|
|
||||||
case Ord(p[1]) of
|
case Ord(p[1]) of
|
||||||
shDefault:
|
shDefault: El:=Nil;
|
||||||
IsInSpecial := False;
|
shInvalid: El:=newel('font','color','red');
|
||||||
shInvalid:
|
shSymbol : El:=newspan('sym');
|
||||||
begin
|
shKeyword: El:=newspan('kw');
|
||||||
El := CreateEl(CurParent, 'font');
|
shComment: El:=newspan('cmt');
|
||||||
El['color'] := 'red';
|
shDirective: El:=newspan('dir');
|
||||||
CurParent := El;
|
shNumbers: El:=newspan('num');
|
||||||
IsInSpecial := True;
|
shCharacters: El:=newspan('chr');
|
||||||
end;
|
shStrings: El:=newspan('str');
|
||||||
shSymbol:
|
shAssembler: El:=newspan('asm');
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'sym';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shKeyword:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'kw';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shComment:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'cmt';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shDirective:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'dir';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shNumbers:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'num';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shCharacters:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'chr';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shStrings:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'str';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
shAssembler:
|
|
||||||
begin
|
|
||||||
El := CreateEl(CurParent, 'span');
|
|
||||||
El['class'] := 'asm';
|
|
||||||
CurParent := El;
|
|
||||||
IsInSpecial := True;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
Last := p + 2;
|
Inc(P);
|
||||||
end;
|
end
|
||||||
|
else If (Last=Nil) then
|
||||||
|
Last:=P;
|
||||||
Inc(p);
|
Inc(p);
|
||||||
end;
|
end;
|
||||||
if Last <> p then
|
MaybeOutput;
|
||||||
AppendText(CurParent, Last);
|
Finally
|
||||||
FreeMem(Line);
|
FreeMem(Line);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure THTMLWriter.AppendShortDescr(AContext: TPasElement; Parent: TDOMNode; DocNode : TDocNode);
|
Procedure THTMLWriter.AppendShortDescr(AContext: TPasElement; Parent: TDOMNode; DocNode : TDocNode);
|
||||||
|
Loading…
Reference in New Issue
Block a user