@@ -468,24 +468,37 @@ function FlagsToByte(const flags: EDebugLnFlags): Byte; inline;
468468
469469function FlagsToString (const flags: EDebugLnFlags; const bgColor: TColor): String; inline;
470470begin
471- Result := DebugLnFlagsHeader;
472- Result := Result + Chr(FlagsToByte(flags));
471+ Result := DebugLnFlagsHeader + Chr(FlagsToByte(flags));
473472 if (EDebugLn.BACKGROUND_COLOR in flags) then
474- Result := Result + Chr((bgColor shr 16 ) and $FF) +
475- Chr((bgColor shr 8 ) and $FF) +
476- Chr(bgColor and $FF) ;
473+ Result += Format( ' %.6X ' , [bgColor])
474+ else
475+ Result += ' 000000 ' ;
477476end ;
478477
479478function FlagsFromString (var str: String; out bgColor: TColor): EDebugLnFlags;
480- function _HexToColor (const hex: String): TColor;
479+ function HexToColor (P: PChar): TColor; inline;
480+ var
481+ N, I: Integer;
482+ Val: Char;
481483 begin
482- if Length(hex) = 6 then
483- Result := (StrToInt(' $' + Copy(hex,1 ,2 )) shl 16 ) or
484- (StrToInt(' $' + Copy(hex,3 ,2 )) shl 8 ) or
485- StrToInt(' $' + Copy(hex,5 ,2 ))
486- else
487- Result := 0 ;
484+ Result := 0 ;
485+
486+ for I := 1 to 6 do
487+ begin
488+ Val := P^;
489+ case Val of
490+ ' 0' ..' 9' : N := Ord(Val) - (Ord(' 0' ));
491+ ' a' ..' f' : N := Ord(Val) - (Ord(' a' ) - 10 );
492+ ' A' ..' F' : N := Ord(Val) - (Ord(' A' ) - 10 );
493+ else
494+ Exit(0 );
495+ end ;
496+ Inc(P);
497+
498+ Result := Result*16 +N;
499+ end ;
488500 end ;
501+
489502var
490503 flagsByte: Byte;
491504begin
@@ -500,16 +513,15 @@ function FlagsFromString(var str: String; out bgColor: TColor): EDebugLnFlags;
500513 // maybe in the future... would like multi color support per line
501514
502515 if EDebugLn.BACKGROUND_COLOR in Result then
503- begin
504- bgColor := _HexToColor(Copy(str, 4 , 6 ));
505- end
516+ bgColor := HexToColor(@Str[4 ])
506517 else
507518 bgColor := $0 ;
508519
509520 Delete(str, 1 , DebugLnFlagsHeaderLength);
510521 end ;
511522end ;
512523
524+
513525function InRange (const AValue, AMin, AMax: Integer): Boolean;
514526begin
515527 Result := (AValue >= AMin) and (AValue <= AMax);
0 commit comments