Skip to content

Commit 14a7314

Browse files
committed
better DoDebugLn without extra unit
1 parent 74d3c7b commit 14a7314

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

Source/script/simba.script_runner.pas

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
interface
1111

1212
uses
13-
Classes, SysUtils, Graphics,
13+
Classes, SysUtils,
1414
lptypes, lpvartypes, lpmessages,
1515
simba.script, simba.base;
1616

@@ -20,7 +20,7 @@ TSimbaScriptRunner = class(TThread)
2020
FScript: TSimbaScript;
2121
FCompileOnly: Boolean;
2222

23-
procedure DoDebugLn(Flags: EDebugLnFlags; bgColor: TColor; Text: String);
23+
procedure DoDebugLn(Flags: EDebugLnFlags; color: EDebugLnColor; Text: String);
2424
procedure DoCompilerHint(Sender: TLapeCompilerBase; Hint: lpString);
2525

2626
procedure DoApplicationTerminate(Sender: TObject);
@@ -41,7 +41,7 @@ implementation
4141
simba.env, simba.fs, simba.datetime, simba.script_communication, simba.vartype_string,
4242
simba.baseclass;
4343

44-
procedure TSimbaScriptRunner.DoDebugLn(Flags: EDebugLnFlags; bgColor: TColor; Text: String);
44+
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
4747
DebugLn(Flags, Text)
@@ -50,10 +50,8 @@ procedure TSimbaScriptRunner.DoDebugLn(Flags: EDebugLnFlags; bgColor: TColor; Te
5050
if Application.HasOption('silent') then
5151
begin
5252
if (Flags * [EDebugLn.BACKGROUND_COLOR] <> []) then
53-
begin
54-
if bgColor = GetLineColor(EDebugLnColor.RED) then
55-
DebugLn(Text);
56-
end;
53+
if color = EDebugLnColor.RED then
54+
DebugLn(Text);
5755
Exit;
5856
end;
5957

@@ -90,15 +88,15 @@ procedure TSimbaScriptRunner.DoError(E: Exception);
9088
begin
9189
ExitCode := 1;
9290

93-
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], GetLineColor(EDebugLnColor.RED), E.Message);
91+
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], EDebugLnColor.RED, E.Message);
9492

9593
if (E is lpException) then
9694
with lpException(E) do
9795
begin
9896
for Line in StackTrace.Split(LineEnding) do
99-
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], GetLineColor(EDebugLnColor.RED), Line);
97+
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], EDebugLnColor.RED, Line);
10098
for Line in Hint.Split(LineEnding) do
101-
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], GetLineColor(EDebugLnColor.YELLOW), Line);
99+
DoDebugLn([EDebugLn.BACKGROUND_COLOR, EDebugLn.FOCUS], EDebugLnColor.YELLOW, Line);
102100

103101
if (FScript.SimbaCommunication <> nil) then
104102
FScript.SimbaCommunication.ScriptError(Message, DocPos.Line, DocPos.Col, DocPos.FileName);
@@ -112,7 +110,7 @@ procedure TSimbaScriptRunner.Execute;
112110

113111
try
114112
if FScript.Compile() then
115-
DoDebugLn([EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.GREEN), 'Succesfully compiled in %.2f milliseconds.'.Format([FScript.CompileTime]));
113+
DoDebugLn([EDebugLn.BACKGROUND_COLOR], EDebugLnColor.GREEN, 'Succesfully compiled in %.2f milliseconds.'.Format([FScript.CompileTime]));
116114
except
117115
on E: Exception do
118116
begin
@@ -126,9 +124,9 @@ procedure TSimbaScriptRunner.Execute;
126124
FScript.Run();
127125

128126
if (FScript.RunningTime < 10000) then
129-
DoDebugLn([EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.GREEN), 'Succesfully executed in %.2f milliseconds.'.Format([FScript.RunningTime]))
127+
DoDebugLn([EDebugLn.BACKGROUND_COLOR], EDebugLnColor.GREEN, 'Succesfully executed in %.2f milliseconds.'.Format([FScript.RunningTime]))
130128
else
131-
DoDebugLn([EDebugLn.BACKGROUND_COLOR], GetLineColor(EDebugLnColor.GREEN), 'Succesfully executed in %s.'.Format([FormatMilliseconds(Round(FScript.RunningTime), '\[hh:mm:ss\]')]));
129+
DoDebugLn([EDebugLn.BACKGROUND_COLOR], EDebugLnColor.GREEN, 'Succesfully executed in %s.'.Format([FormatMilliseconds(Round(FScript.RunningTime), '\[hh:mm:ss\]')]));
132130
except
133131
on E: Exception do
134132
DoError(E);

0 commit comments

Comments
 (0)