Skip to content

Commit 9d2aaa2

Browse files
committed
fixing things that I missed
1 parent c5d8ad8 commit 9d2aaa2

3 files changed

Lines changed: 26 additions & 21 deletions

File tree

Source/ide/simba.form_output.pas

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ procedure TSimbaOutputBox.DoSpecialLineMarkup(Sender: TObject; Line: Integer; va
257257
Exit;
258258
end;
259259

260-
if EDebugLn.BACKGROUND_COLOR in lineData.Flags then
260+
if EDebugLn.BACKGROUND_COLOR in lineData^.Flags then
261261
begin
262-
AMarkup.Background := lineData.Color;
262+
AMarkup.Background := lineData^.Color;
263263
AMarkup.BackAlpha := 115;
264264
AMarkup.Foreground := clNone;
265265
Special := True;
@@ -319,7 +319,7 @@ destructor TSimbaOutputBox.Destroy;
319319
if (FBuffer <> nil) then
320320
begin
321321
for i := 0 to FBuffer.Count - 1 do
322-
Dispose(PLineFlagsData(FBuffer.Objects[i]))
322+
Dispose(PLineFlagsData(FBuffer.Objects[i]));
323323
FreeAndNil(FBuffer);
324324
end;
325325
if (FLock <> nil) then
@@ -401,7 +401,7 @@ function TSimbaOutputBox.Add(const S: String): String;
401401
Arr: TStringArray;
402402
I: Integer;
403403
Line: String;
404-
lineData: PLineData;
404+
lineData: PLineFlagsData;
405405
begin
406406
Arr := S.Split(LineEnding, False);
407407
if (Length(Arr) = 0) then
@@ -419,7 +419,7 @@ function TSimbaOutputBox.Add(const S: String): String;
419419
Line := Arr[I];
420420
New(lineData);
421421
lineData^.Flags := FlagsFromString(Line, lineData^.Color);
422-
FBuffer.AddObject(Line, TObject(data));
422+
FBuffer.AddObject(Line, TObject(lineData));
423423
end;
424424
end else
425425
begin
@@ -430,7 +430,7 @@ function TSimbaOutputBox.Add(const S: String): String;
430430
Line := Arr[I];
431431
New(lineData);
432432
lineData^.Flags := FlagsFromString(Line, lineData^.Color);
433-
FBuffer.AddObject(Line, TObject(data));
433+
FBuffer.AddObject(Line, TObject(lineData));
434434
end;
435435
end;
436436

@@ -447,7 +447,7 @@ procedure TSimbaOutputBox.AddLine(Flags: EDebugLnFlags; const S: String);
447447

448448
procedure TSimbaOutputBox.Empty;
449449
begin
450-
Add(FlagsToString([EDebugLn.CLEAR]) + LineEnding);
450+
Add(FlagsToString([EDebugLn.CLEAR], $0) + LineEnding);
451451
end;
452452

453453
procedure TSimbaOutputBox.Flush;

Source/ide/simba.ide_package_autoupdater.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ procedure TPackageUpdater.Execute;
228228

229229
if Package.HasUpdate() and Package.AutoUpdateEnabled then
230230
begin
231-
DebugLn([EDebugLn.FOCUS, EDebugLn.YELLOW], 'Automatically updating %s', [Package.Name]);
231+
DebugLn([EDebugLn.FOCUS, EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.YELLOW), 'Automatically updating %s', [Package.Name]);
232232
Sleep(750); // whatever, let above flush... TSimbaPackageInstaller directly writes to the synedit.
233233

234234
try
@@ -247,16 +247,16 @@ procedure TPackageUpdater.Execute;
247247

248248
if Install(InstallOpts) then
249249
begin
250-
DebugLn([EDebugLn.FOCUS, EDebugLn.GREEN], 'Succesfully updated "%s"', [Package.Name]);
251-
DebugLn([EDebugLn.FOCUS, EDebugLn.GREEN], 'Now at version: %s', [Package.InstalledVersion]);
250+
DebugLn([EDebugLn.FOCUS, EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.GREEN), 'Succesfully updated "%s"', [Package.Name]);
251+
DebugLn([EDebugLn.FOCUS, EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.GREEN), 'Now at version: %s', [Package.InstalledVersion]);
252252
end else
253-
DebugLn([EDebugLn.FOCUS, EDebugLn.RED], 'Failed to update: %s', [Package.Name]);
253+
DebugLn([EDebugLn.FOCUS, EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.RED), 'Failed to update: %s', [Package.Name]);
254254
finally
255255
Free();
256256
end;
257257
except
258258
on E: Exception do
259-
DebugLn([EDebugLn.FOCUS, EDebugLn.RED], 'Failed to update: %s (%s)', [Package.Name, E.Message]);
259+
DebugLn([EDebugLn.FOCUS, EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.RED), 'Failed to update: %s (%s)', [Package.Name, E.Message]);
260260
end;
261261
end;
262262
end;

Source/simba.base.pas

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,9 @@ procedure DebugLn(const Flags: EDebugLnFlags; bgColor: TColor; const Msg: String
298298

299299
function GetLineColor(const color: EDebugLnColor): TColor;
300300

301+
function FlagsToByte(const flags: EDebugLnFlags): Byte;
301302
function FlagsToString(const flags: EDebugLnFlags; const bgColor: TColor): String;
302-
function FlagsFromString(var Str: String; out bgColor: Int32): EDebugLnFlags;
303+
function FlagsFromString(var Str: String; out bgColor: TColor): EDebugLnFlags;
303304

304305
function InRange(const AValue, AMin, AMax: Integer): Boolean; inline; overload;
305306
function InRange(const AValue, AMin, AMax: Int64): Boolean; inline; overload;
@@ -448,30 +449,34 @@ procedure SimbaException(Message: String);
448449

449450
function GetLineColor(const color: EDebugLnColor): TColor; inline;
450451
const
451-
DEBUG_LINE_COLORS: array [EDebugLnColor] of TColor = [
452-
$00BFFF, $0000A5, $228B22
453-
];
452+
DEBUG_LINE_COLORS: TColorArray = ($00BFFF, $0000A5, $228B22);
454453
begin
455-
Result := DEBUG_LINE_COLORS[color];
454+
Result := DEBUG_LINE_COLORS[Ord(color)];
456455
end;
457456

458457
const
459458
DebugLnFlagsHeader = String(#0#0);
460459
DebugLnFlagsHeaderLength = Length(DebugLnFlagsHeader) + 6;
461460

461+
function FlagsToByte(const flags: EDebugLnFlags): Byte; inline;
462+
begin
463+
Result := 0;
464+
if EDebugLn.CLEAR in flags then Result := Result or 1;
465+
if EDebugLn.FOCUS in flags then Result := Result or 2;
466+
if EDebugLn.BACKGROUND_COLOR in flags then Result := Result or 4;
467+
end;
468+
462469
function FlagsToString(const flags: EDebugLnFlags; const bgColor: TColor): String; inline;
463470
begin
464471
Result := DebugLnFlagsHeader;
465-
Result := Result + Chr(Byte(flags));
472+
Result := Result + Chr(FlagsToByte(flags));
466473
if (EDebugLn.BACKGROUND_COLOR in flags) then
467-
begin
468474
Result := Result + Chr((bgColor shr 16) and $FF) +
469475
Chr((bgColor shr 8) and $FF) +
470476
Chr(bgColor and $FF);
471-
end;
472477
end;
473478

474-
function FlagsFromString(var str: String; out bgColor: Int32): EDebugLnFlags;
479+
function FlagsFromString(var str: String; out bgColor: TColor): EDebugLnFlags;
475480
var
476481
flagsByte: Byte;
477482
idx: Integer;

0 commit comments

Comments
 (0)