Ver código fonte

* the cygwin1.dll messes with the console mode so store and restore the console mode if necessary

git-svn-id: trunk@7218 -
florian 18 anos atrás
pai
commit
91cdcff845
3 arquivos alterados com 21 adições e 2 exclusões
  1. 9 2
      ide/fp.pas
  2. 10 0
      rtl/win32/sysinitcyg.pp
  3. 2 0
      rtl/win32/system.pp

+ 9 - 2
ide/fp.pas

@@ -30,6 +30,9 @@ program FP;
 (**********************************************************************)
 (**********************************************************************)
 
 
 uses
 uses
+{$ifdef Windows}
+  windows,
+{$endif Windows}
 {$ifndef NODEBUG}
 {$ifndef NODEBUG}
 {$ifdef Windows}
 {$ifdef Windows}
   fpcygwin,
   fpcygwin,
@@ -523,9 +526,13 @@ BEGIN
 {$ifdef VESA}
 {$ifdef VESA}
   DoneVESAScreenModes;
   DoneVESAScreenModes;
 {$endif}
 {$endif}
-{$ifdef unix}
+{$if defined(unix)}
   Keyboard.RestoreStartMode;
   Keyboard.RestoreStartMode;
-{$endif unix}
+{$endif defined(unix)}
+{$if defined(windows)}
+  writeln(hexstr(StartupConsoleMode,8));
+  SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)),StartupConsoleMode);
+{$endif defined(windows)}
   StreamError:=nil;
   StreamError:=nil;
 {$ifdef DEBUG}
 {$ifdef DEBUG}
   if CloseImmediately then
   if CloseImmediately then

+ 10 - 0
rtl/win32/sysinitcyg.pp

@@ -28,6 +28,12 @@ unit sysinitcyg;
     procedure Cygwin_crt0(p : pointer);cdecl;external name 'cygwin_crt0';
     procedure Cygwin_crt0(p : pointer);cdecl;external name 'cygwin_crt0';
     procedure __main;cdecl;external name '__main';
     procedure __main;cdecl;external name '__main';
 
 
+    const
+      STD_INPUT_HANDLE = dword(-10);
+
+    function GetStdHandle(nStdHandle:DWORD) : THandle; stdcall; external 'kernel32' name 'GetStdHandle';
+    function GetConsoleMode(hConsoleHandle: THandle; var lpMode: DWORD): Boolean; stdcall; external 'kernel32' name 'GetConsoleMode';
+
     procedure CMainEXE;cdecl;
     procedure CMainEXE;cdecl;
       begin
       begin
         asm
         asm
@@ -57,6 +63,10 @@ unit sysinitcyg;
           subl   $0x8,%esp
           subl   $0x8,%esp
           andl   $0xfffffff0,%esp
           andl   $0xfffffff0,%esp
         end;
         end;
+        { it seems cygwin messed around with the console mode so we've to
+          store the startup console mode before cygwin can do anything (FK)
+        }
+        GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
         Cygwin_crt0(@CMainEXE);
         Cygwin_crt0(@CMainEXE);
       end;
       end;
 
 

+ 2 - 0
rtl/win32/system.pp

@@ -95,6 +95,8 @@ var
   MainInstance,
   MainInstance,
   cmdshow     : longint;
   cmdshow     : longint;
   DLLreason,DLLparam:longint;
   DLLreason,DLLparam:longint;
+  StartupConsoleMode : DWORD;
+
 type
 type
   TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
   TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
   TDLL_Entry_Hook = procedure (dllparam : longint);
   TDLL_Entry_Hook = procedure (dllparam : longint);