Skip to content

Commit

Permalink
Remove console window on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jan 14, 2024
1 parent 180e96e commit b9feea5
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 158 deletions.
39 changes: 35 additions & 4 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -117,6 +122,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand All @@ -126,10 +136,6 @@
-dStaticFFI
-dLape_CDECL
-dLape_NoExtended"/>
<OtherDefines Count="2">
<Define0 Value="StaticFFI"/>
<Define1 Value="Lape_CDECL"/>
</OtherDefines>
<CreateMakefileOnBuild Value="True"/>
</Other>
</CompilerOptions>
Expand Down Expand Up @@ -165,6 +171,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -208,6 +219,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -250,6 +266,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -298,6 +319,11 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -1163,6 +1189,11 @@
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down
2 changes: 1 addition & 1 deletion Source/forms/simba.debugimageform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ procedure TSimbaDebugImageForm.FormCreate(Sender: TObject);

procedure TSimbaDebugImageForm.ImageDoubleClick(Sender: TObject);
begin
SimbaDebugLn([EDebugLn.FOCUS], 'Debug Image Click: (%d, %d)'.Format([ImageBox.MousePoint.X, ImageBox.MousePoint.Y]));
DebugLn([EDebugLn.FOCUS], 'Debug Image Click: (%d, %d)', [ImageBox.MousePoint.X, ImageBox.MousePoint.Y]);
end;

procedure TSimbaDebugImageForm.SetSize(AWidth, AHeight: Integer; AForce: Boolean; AEnsureVisible: Boolean);
Expand Down
2 changes: 1 addition & 1 deletion Source/forms/simba.dtmeditor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ procedure TSimbaDTMEditorForm.ButtonPrintDTMClick(Sender: TObject);
begin
FDTMString := GetDTM().ToString();

SimbaDebugLn([EDebugLn.FOCUS], 'DTM := TDTM.CreateFromString(' + #39 + FDTMString + #39 + ');');
DebugLn([EDebugLn.FOCUS], 'DTM := TDTM.CreateFromString(' + #39 + FDTMString + #39 + ');');
end;

procedure TSimbaDTMEditorForm.ListBoxSelectionChange(Sender: TObject; User: boolean);
Expand Down
2 changes: 1 addition & 1 deletion Source/forms/simba.imagetostringform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ procedure TSimbaImageToStringForm.ToStringButtonClick(Sender: TObject);
except
end;

SimbaDebugLn([EDebugLn.FOCUS], ImageString);
DebugLn([EDebugLn.FOCUS], ImageString);
end;
end;

Expand Down
7 changes: 1 addition & 6 deletions Source/forms/simba.main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object SimbaForm: TSimbaForm
OnDestroy = FormDestroy
OnWindowStateChange = FormWindowStateChange
Position = poScreenCenter
LCLVersion = '3.0.0.2'
LCLVersion = '3.0.0.3'
object DockPanel: TAnchorDockPanel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
Expand Down Expand Up @@ -389,11 +389,6 @@ object SimbaForm: TSimbaForm
ShowAlwaysCheckable = True
OnClick = MenuItemTrayIconClick
end
object MenuItemConsole: TMenuItem
AutoCheck = True
Caption = 'Console'
OnClick = MenuItemConsoleClick
end
object MenuItem4: TMenuItem
Caption = '-'
end
Expand Down
19 changes: 0 additions & 19 deletions Source/forms/simba.main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ TSimbaForm = class(TForm)
MenuItemCloseTabs: TMenuItem;
MenuItemColourHistory: TMenuItem;
MenuItemCompile: TMenuItem;
MenuItemConsole: TMenuItem;
MenuItemCopy: TMenuItem;
MenuItemCut: TMenuItem;
MenuItemDebugImage: TMenuItem;
Expand Down Expand Up @@ -231,7 +230,6 @@ TSimbaForm = class(TForm)
procedure DoSettingChanged_CustomFontSize(Setting: TSimbaSetting);
procedure DoSettingChanged_LockLayout(Setting: TSimbaSetting);
procedure DoSettingChanged_TrayIconVisible(Setting: TSimbaSetting);
procedure DoSettingChanged_ConsoleVisible(Setting: TSimbaSetting);

procedure HandleRecentFileClick(Sender: TObject);
procedure HandleException(Sender: TObject; E: Exception);
Expand All @@ -243,7 +241,6 @@ TSimbaForm = class(TForm)
procedure DoTabLoaded(Sender: TObject);

procedure SetCustomFontSize(Value: Integer);
procedure SetConsoleVisible(Value: Boolean);
procedure SetLayoutLocked(Value: Boolean);
procedure SetTrayIconVisible(Value: Boolean);

Expand Down Expand Up @@ -350,16 +347,6 @@ procedure TSimbaForm.SetCustomFontSize(Value: Integer);
Screen.CustomForms[I].Font.Size := Value;
end;

procedure TSimbaForm.SetConsoleVisible(Value: Boolean);
begin
MenuItemConsole.Checked := Value;

if Value then
SimbaNativeInterface.ShowTerminal()
else
SimbaNativeInterface.HideTerminal();
end;

procedure TSimbaForm.SetLayoutLocked(Value: Boolean);
begin
MenuItemLockLayout.Checked := Value;
Expand Down Expand Up @@ -587,7 +574,6 @@ procedure TSimbaForm.Setup;
RegisterChangeHandler(Self, General.CustomFontSize, @DoSettingChanged_CustomFontSize, True);
RegisterChangeHandler(Self, General.LockLayout, @DoSettingChanged_LockLayout, True);
RegisterChangeHandler(Self, General.TrayIconVisible, @DoSettingChanged_TrayIconVisible, True);
RegisterChangeHandler(Self, General.ConsoleVisible, @DoSettingChanged_ConsoleVisible, True);
end;

// Create things
Expand Down Expand Up @@ -766,11 +752,6 @@ procedure TSimbaForm.DoSettingChanged_TrayIconVisible(Setting: TSimbaSetting);
SetTrayIconVisible(Setting.Value);
end;

procedure TSimbaForm.DoSettingChanged_ConsoleVisible(Setting: TSimbaSetting);
begin
SetConsoleVisible(Setting.Value);
end;

procedure TSimbaForm.MenuCloseTabClick(Sender: TObject);
begin
SimbaScriptTabsForm.CloseTab(SimbaScriptTabsForm.CurrentTab, True);
Expand Down
2 changes: 1 addition & 1 deletion Source/forms/simba.outputform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ constructor TSimbaOutputForm.Create(AOwner: TComponent);

FSimbaOutputBox := AddSimbaOutput();

DoSimbaDebugLn := @DebugLn;
OnDebugLn := @DebugLn;

SimbaIDEEvents.Register(Self, SimbaIDEEvent.TAB_CHANGE, @DoScriptTabChange);
end;
Expand Down
13 changes: 4 additions & 9 deletions Source/package/simba.package_autoupdater.pas
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,16 @@ procedure TPackageUpdater.Execute;

if Package.HasUpdate() and Package.AutoUpdateEnabled then
begin
SimbaDebugLn([EDebugLn.FOCUS], 'Automatically updating ' + Package.Info.FullName);
DebugLn([EDebugLn.FOCUS], 'Automatically updating %s', [Package.Info.FullName]);

with TSimbaPackageInstaller.Create(Package, SimbaOutputForm.SimbaOutputBox) do
try
if InstallLatestVersion() then
begin
SimbaDebugLn([EDebugLn.FOCUS, EDebugLn.GREEN], [
'Succesfully updated "' + Package.Info.FullName + '"',
'Now at version: ' + Package.InstalledVersion,
'Scripts will need to be restarted for changes to take effect.'
]);
DebugLn([EDebugLn.FOCUS, EDebugLn.GREEN], 'Succesfully updated "%s"', [Package.Info.FullName]);
DebugLn([EDebugLn.FOCUS, EDebugLn.GREEN], 'Now at version: %s', [Package.InstalledVersion]);
end else
SimbaDebugLn([EDebugLn.FOCUS, EDebugLn.RED], [
'Failed to update "' + Package.Info.FullName + '"'
]);
DebugLn([EDebugLn.FOCUS, EDebugLn.RED], 'Failed to update: %s', [Package.Info.FullName]);
finally
Free();
end;
Expand Down
2 changes: 1 addition & 1 deletion Source/script/imports/simba.import_misc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ implementation
*)
procedure ClearSimbaOutput(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
SimbaDebugLn([EDebugLn.CLEAR], '');
DebugLn([EDebugLn.CLEAR], '');
end;

(*
Expand Down
2 changes: 1 addition & 1 deletion Source/script/simba.script.pas
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function TSimbaScript.DoCompilerMacro(Sender: TLapeCompiler; Name, Argument: lpS

procedure TSimbaScript.DoCompilerHint(Sender: TLapeCompilerBase; Hint: lpString);
begin
SimbaDebugLn([EDebugLn.YELLOW], Hint);
DebugLn([EDebugLn.YELLOW], Hint);
end;

procedure TSimbaScript.DoCompilerFindFile(Sender: TLapeCompiler; var FileName: lpString);
Expand Down
2 changes: 1 addition & 1 deletion Source/script/simba.script_runner.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ implementation
procedure TSimbaScriptRunner.DoDebugLn(Flags: EDebugLnFlags; Text: String);
begin
if (SimbaProcessType = ESimbaProcessType.SCRIPT_WITH_COMMUNICATION) then // Only add flags if we have communication with simba to use them
SimbaDebugLn(Flags, Text)
DebugLn(Flags, Text)
else
begin
if Application.HasOption('silent') and (Flags * [EDebugLn.YELLOW, EDebugLn.GREEN] <> []) then
Expand Down
59 changes: 26 additions & 33 deletions Source/simba.base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,14 @@ TCircle = record
{$POP}

var
DoSimbaDebugLn: procedure(const S: String) of object = nil;
OnDebugLn: procedure(const S: String) of object = nil;

procedure Debug(const Msg: String); overload;
procedure Debug(const Msg: String; Args: array of const); overload;
procedure DebugLn(const Msg: String); overload;
procedure DebugLn(const Msg: String; Args: array of const); overload;

procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: String); overload;
procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: TStringArray); overload;
procedure DebugLn(const Flags: EDebugLnFlags; const Msg: String); overload;
procedure DebugLn(const Flags: EDebugLnFlags; const Msg: String; Args: array of const); overload;

function FlagsToString(const Flags: EDebugLnFlags): String;
function FlagsFromString(var Str: String): EDebugLnFlags;
Expand Down Expand Up @@ -431,20 +430,30 @@ implementation

procedure Debug(const Msg: String);
begin
if Assigned(OnDebugLn) then
begin
OnDebugLn(Msg);
Exit;
end;

{$I-}
Write(Msg);
{$I+}
end;

procedure Debug(const Msg: String; Args: array of const);
begin
{$I-}
Write(Format(Msg, Args));
{$I+}
Debug(Format(Msg, Args));
end;

procedure DebugLn(const Msg: String);
begin
if Assigned(OnDebugLn) then
begin
OnDebugLn(Msg);
Exit;
end;

{$I-}
WriteLn(Msg);
Flush(Output);
Expand All @@ -453,37 +462,34 @@ procedure DebugLn(const Msg: String);

procedure DebugLn(const Msg: String; Args: array of const);
begin
{$I-}
WriteLn(Format(Msg, Args));
Flush(Output);
{$I+}
DebugLn(Format(Msg, Args));
end;

procedure SimbaException(Message: String; Args: array of const);
procedure DebugLn(const Flags: EDebugLnFlags; const Msg: String);
begin
raise ESimbaException.CreateFmt(Message, Args);
DebugLn(FlagsToString(Flags) + Msg);
end;

procedure SimbaException(Message: String);
procedure DebugLn(const Flags: EDebugLnFlags; const Msg: String; Args: array of const);
begin
raise ESimbaException.Create(Message);
DebugLn(FlagsToString(Flags) + Format(Msg, Args));
end;

procedure SimbaDebugLn(const Msg: String);
procedure SimbaException(Message: String; Args: array of const);
begin
DebugLn(Msg);
raise ESimbaException.CreateFmt(Message, Args);
end;

procedure SimbaDebugLn(const Msg: String; Args: array of const);
procedure SimbaException(Message: String);
begin
DebugLn(Msg.Format(Args));
raise ESimbaException.Create(Message);
end;

const
DebugLnFlagsHeader = String(#0#0);
DebugLnFlagsHeaderLength = Length(DebugLnFlagsHeader) + 6;

function FlagsToString(const Flags: EDebugLnFlags): String;
function FlagsToString(const Flags: EDebugLnFlags): String; inline;
begin
Result := DebugLnFlagsHeader + IntToHex(Integer(Flags), 6);
end;
Expand Down Expand Up @@ -523,19 +529,6 @@ function FlagsFromString(var Str: String): EDebugLnFlags;
Result := [];
end;

procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: String);
begin
if Assigned(DoSimbaDebugLn) then
DoSimbaDebugLn(FlagsToString(Flags) + Msg)
else
DebugLn(FlagsToString(Flags) + Msg);
end;

procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: TStringArray);
begin
SimbaDebugLn(Flags, LineEnding.Join(Msg));
end;

function InRange(const AValue, AMin, AMax: Integer): Boolean;
begin
Result := (AValue>=AMin) and (AValue<=AMax);
Expand Down
Loading

0 comments on commit b9feea5

Please sign in to comment.