Skip to content

Commit 893eaa8

Browse files
committed
last tweaks
1 parent c025dd7 commit 893eaa8

3 files changed

Lines changed: 34 additions & 21 deletions

File tree

Source/ide/simba.form_output.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@ procedure TSimbaOutputBox.DoSpecialLineMarkup(Sender: TObject; Line: Integer; va
251251
begin
252252
lineData := PLineFlagsData(Lines.Objects[Line - 1]);
253253

254-
if lineData = nil then
255-
begin
256-
Special := False;
257-
Exit;
258-
end;
254+
//99.99% sure there's no need to check, should never be nil
255+
//if lineData = nil then
256+
//begin
257+
// Special := False;
258+
// Exit;
259+
//end;
259260

260261
if EDebugLn.BACKGROUND_COLOR in lineData^.Flags then
261262
begin

Source/script/simba.script_runner.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ implementation
4444
procedure TSimbaScriptRunner.DoDebugLn(Flags: EDebugLnFlags; color: EDebugLnColor; Text: String);
4545
begin
4646
if (SimbaProcessType = ESimbaProcessType.SCRIPT_WITH_COMMUNICATION) then // Only add flags if we have communication with simba to use them
47-
DebugLn(Flags, Text)
47+
DebugLn(Flags, GetLineColor(color), Text)
4848
else
4949
begin
5050
if Application.HasOption('silent') then

Source/simba.base.pas

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -468,24 +468,37 @@ function FlagsToByte(const flags: EDebugLnFlags): Byte; inline;
468468

469469
function FlagsToString(const flags: EDebugLnFlags; const bgColor: TColor): String; inline;
470470
begin
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';
477476
end;
478477

479478
function 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+
489502
var
490503
flagsByte: Byte;
491504
begin
@@ -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;
511522
end;
512523

524+
513525
function InRange(const AValue, AMin, AMax: Integer): Boolean;
514526
begin
515527
Result := (AValue >= AMin) and (AValue <= AMax);

0 commit comments

Comments
 (0)