type
PHLAttrRec = ^THLAttrRec;
THLAttrRec = record
ForeGround: TColor;
BackGround: TColor;
Style: TFontStyles;
function ToString: String;
procedure Assign(Source: TSynHighlighterAttributes);
procedure AssignTo(Dest: TSynHighlighterAttributes);
end;
TPascalAttr = (paAsm,paCaseLabel,paComment,paDirective,paIdentifier,paKeyWord,paNumber,paSpace,paString,paSymbol);
TPascalAttrRecs = array[TPascalAttr] of THLAttrRec;
...
function THLAttrRec.ToString: String;
begin
Result := Format('{ForeGround: %s; BackGround: %s; FontStyle: %s}',
[ColorToStr(ForeGround),ColorToStr(BackGround),FontStyleToStr(Style)]);
end;
//will e.g. give: '{ForeGround: clFuchsia; BackGround: clNone; FontStyle: [fsItalic]}'
...
function FindPascalRec(Name: String; Options: TEPlusOptions): PHLAttrRec;
//finds the THLAttrRec that corresponds to Name in an array of THLAttrRec which is a field of the TEPlusOptions record, and returs a pointer to that.
//Now:
procedure TOptionsDlgForm.Button1Click(Sender: TObject);
type
TByteArr = Array[1..SizeOf(THLAttrRec)] of byte;
var
Attr: TPascalAttr;
S: String;
RecPtr: PHLAttrRec;
i: Integer;
begin
writeln('TOptionsDlgForm.Button1Click');
for Attr := Low(TPascalAttr) to Succ(Low(TPascalAttr)) do
begin
S := PascalAttrNames[Attr];
RecPtr := FindPascalRec(S, FOptions);
writeln('RecPtr=',PtrUint(RecPtr).ToHexString);
for i := 1 to SizeOf(TByteArr) do write(TByteArr(RecPtr^)[i].ToHexString,#32);writeln;
//writeln('RecPtr^=',RecPtr^.ToString);
writeln('RecPtr^.ForeGround=',ColorToStr(RecPtr^.ForeGround),' [',LongInt(RecPtr^.ForeGround).ToHexString,']');
writeln('RecPtr=',PtrUint(RecPtr).ToHexString);
for i := 1 to SizeOf(TByteArr) do write(TByteArr(RecPtr^)[i].ToHexString,#32);writeln;
//writeln('RecPtr^=',RecPtr^.ToString);
writeln('RecPtr^.ForeGround=',ColorToStr(RecPtr^.ForeGround),' [',LongInt(RecPtr^.ForeGround).ToHexString,']');
writeln;
end;
end;