Skip to content

Commit c025dd7

Browse files
committed
more tweaks and fixes
1 parent 14a7314 commit c025dd7

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Source/ide/simba.form_output.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,14 @@ function TSimbaOutputBox.Add(const S: String): String;
439439
end;
440440

441441
procedure TSimbaOutputBox.AddLine(Flags: EDebugLnFlags; const S: String);
442+
var
443+
lineData: PLineFlagsData;
442444
begin
443445
FLock.Enter();
444-
FBuffer.AddObject(S, TObject(PtrUInt(Integer(Flags))));
446+
New(lineData);
447+
lineData^.Flags := Flags;
448+
lineData^.Color := $0;
449+
FBuffer.AddObject(S, TObject(lineData));
445450
FLock.Leave();
446451
end;
447452

Source/simba.base.pas

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@ function GetLineColor(const color: EDebugLnColor): TColor; inline;
456456

457457
const
458458
DebugLnFlagsHeader = String(#0#0);
459-
DebugLnFlagsHeaderLength = Length(DebugLnFlagsHeader) + 6;
459+
DebugLnFlagsHeaderLength = Length(DebugLnFlagsHeader) + 7;
460460

461461
function FlagsToByte(const flags: EDebugLnFlags): Byte; inline;
462462
begin
463463
Result := 0;
464-
if EDebugLn.CLEAR in flags then Result := Result or 1;
465-
if EDebugLn.FOCUS in flags then Result := Result or 2;
464+
if EDebugLn.CLEAR in flags then Result := Result or 1;
465+
if EDebugLn.FOCUS in flags then Result := Result or 2;
466466
if EDebugLn.BACKGROUND_COLOR in flags then Result := Result or 4;
467467
end;
468468

@@ -477,9 +477,17 @@ function FlagsToString(const flags: EDebugLnFlags; const bgColor: TColor): Strin
477477
end;
478478

479479
function FlagsFromString(var str: String; out bgColor: TColor): EDebugLnFlags;
480+
function _HexToColor(const hex: String): TColor;
481+
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;
488+
end;
480489
var
481490
flagsByte: Byte;
482-
idx: Integer;
483491
begin
484492
Result := [];
485493
if (Length(Str) >= DebugLnFlagsHeaderLength) and (Str[1] = DebugLnFlagsHeader[1]) and (Str[2] = DebugLnFlagsHeader[2]) then
@@ -491,11 +499,9 @@ function FlagsFromString(var str: String; out bgColor: TColor): EDebugLnFlags;
491499
//if (flagsByte and 8 <> 0) then Include(Result, EDebugLn.TEXT_COLOR);
492500
//maybe in the future... would like multi color support per line
493501

494-
idx := 4;
495502
if EDebugLn.BACKGROUND_COLOR in Result then
496503
begin
497-
bgColor := (Ord(Str[idx]) shl 16) or (Ord(str[idx+1]) shl 8) or Ord(str[idx+2]);
498-
Inc(idx, 3);
504+
bgColor := _HexToColor(Copy(str, 4, 6));
499505
end
500506
else
501507
bgColor := $0;

0 commit comments

Comments
 (0)