diff --git a/Examples/.dof b/Examples/.dof index 01e7ed9..5d4d37c 100644 --- a/Examples/.dof +++ b/Examples/.dof @@ -2,5 +2,6 @@ OutputDir=..\..\..\Bin\KoW UnitOutputDir=..\..\..\Bin\KoW\DCU SearchPath=..\..\..\Lib;..\..\..\Bin\KoW\DCU +Conditionals=Debug UnitAliases= UsePackages=0 \ No newline at end of file diff --git a/Lib/CRT.pas b/Lib/CRT.pas index 74969c2..71b58e1 100644 --- a/Lib/CRT.pas +++ b/Lib/CRT.pas @@ -87,8 +87,8 @@ var procedure InitConsole(Title: PKolibriChar; CloseWindowOnExit: Boolean; WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord); begin - con_init(WndWidth, WndHeight, ScrWidth, ScrHeight, Title); CloseWindow := CloseWindowOnExit; + con_init(WndWidth, WndHeight, ScrWidth, ScrHeight, Title); if ScrWidth <> LongWord(-1) then ClrEOLWidth := ScrWidth; end; @@ -278,11 +278,13 @@ initialization InitKoW; {$ENDIF} +{$IF defined(KolibriOS) or defined(Debug)} if IsConsole then InitConsole(AppPath); finalization if Assigned(System.con_exit) then con_exit(CloseWindow); +{$IFEND} end. diff --git a/Lib/KoW/CRT.inc b/Lib/KoW/CRT.inc index efc94cc..a087cdc 100644 --- a/Lib/KoW/CRT.inc +++ b/Lib/KoW/CRT.inc @@ -73,16 +73,21 @@ begin end; procedure con_init(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Title: PKolibriChar); stdcall; +{$IFDEF Debug} var Font: TConsoleFontInfo; R: TSmallRect; +{$ENDIF} begin +{$IFDEF Debug} if not IsConsole then AllocConsole; +{$ENDIF} TTextRec(Input).Handle := System.GetStdHandle(STD_INPUT_HANDLE); TTextRec(Output).Handle := System.GetStdHandle(STD_OUTPUT_HANDLE); +{$IFDEF Debug} SaveInputCP := GetConsoleCP; SetConsoleCP(CP_KOLIBRIOS); SaveOutputCP := GetConsoleOutputCP; @@ -95,8 +100,9 @@ begin if WndHeight <> LongWord(-1) then WndSize.Y := WndHeight; + MainWindow := GetConsoleWindow; GetCurrentConsoleFont(TTextRec(Output).Handle, False, Font); - SetWindowPos(GetConsoleWindow, 0, WndPos.X, WndPos.Y, + SetWindowPos(MainWindow, 0, WndPos.X, WndPos.Y, Font.Size.X * WndSize.X + GetSystemMetrics(SM_CXVSCROLL), Font.Size.Y * WndSize.Y + GetSystemMetrics(SM_CYHSCROLL), 0); if ScrWidth <> LongWord(-1) then @@ -113,6 +119,7 @@ begin Bottom := ScrSize.Y - 1; end; SetConsoleWindowInfo(TTextRec(Output).Handle, True, R); +{$ENDIF} end; function con_get_cursor_height: Integer; stdcall; diff --git a/Lib/KoW/System.inc b/Lib/KoW/System.inc index 38669f0..56fd410 100644 --- a/Lib/KoW/System.inc +++ b/Lib/KoW/System.inc @@ -38,23 +38,26 @@ const EOL: array[0..1] of KolibriChar = #13#10; var Buf: array[Low(Byte)..High(Byte) + 1] of KolibriChar; - BytesWritten, Flags: Cardinal; +{$IFNDEF Debug} + BytesWritten: LongWord; +{$ENDIF} + Flags: LongWord; begin +{$IFNDEF Debug} if TTextRec(Output).Handle <> 0 then begin WriteFile(TTextRec(Output).Handle, Msg^, Count, BytesWritten, nil); WriteFile(TTextRec(Output).Handle, EOL, SizeOf(EOL), BytesWritten, nil); - end - else - begin - if MainWindow <> 0 then - Flags := MB_ICONERROR - else - Flags := MB_ICONERROR or MB_TASKMODAL; - Move(Msg^, Buf, Count); - Msg[Count] := #0; - MessageBox(MainWindow, Msg, nil, Flags); + Exit; end; +{$ENDIF} + if MainWindow <> 0 then + Flags := MB_ICONERROR + else + Flags := MB_ICONERROR or MB_TASKMODAL; + Move(Msg^, Buf, Count); + Msg[Count] := #0; + MessageBox(MainWindow, Msg, nil, Flags); end; function SysFreeMem(P: Pointer): Integer; diff --git a/My/.dof b/My/.dof index ed9b0d7..fc9d4ec 100644 --- a/My/.dof +++ b/My/.dof @@ -2,5 +2,6 @@ OutputDir=..\..\Bin\KoW UnitOutputDir=..\..\Bin\KoW\DCU SearchPath=..\..\Lib;..\..\Bin\KoW\DCU +Conditionals=Debug UnitAliases= UsePackages=0 \ No newline at end of file diff --git a/init-for-IDE.bat b/init-for-IDE.bat index f8d80af..0df0e51 100644 --- a/init-for-IDE.bat +++ b/init-for-IDE.bat @@ -4,7 +4,7 @@ set DCU=%~dp0Bin\DCU set KoW=%~dp0Bin\KoW\DCU if #%1#==## ( - call "%~dp0Tools\init.bat" + call "%~dp0Tools\init.bat" -dDebug if errorlevel 1 goto exit if not exist "%KoW%" mkdir "%KoW%"