wconsole.pas 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 2001 by Pierre Muller
  5. This unit is used to save and restore console modes
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit WConsole;
  13. interface
  14. {$ifdef UNIX}
  15. uses
  16. TermInfo,
  17. {$Ifdef ver1_0}
  18. linux;
  19. {$else}
  20. Unix;
  21. {$endif}
  22. {$endif UNIX}
  23. type
  24. TConsoleMode =
  25. {$ifdef UNIX}
  26. TermIos
  27. {$endif UNIX}
  28. {$ifdef Win32}
  29. dword
  30. {$endif Win32}
  31. {$ifdef go32v2}
  32. longint
  33. {$endif go32v2}
  34. ;
  35. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  36. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  37. implementation
  38. {$ifdef Win32}
  39. uses
  40. windows;
  41. {$endif Win32}
  42. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  43. Begin
  44. {$ifdef UNIX}
  45. TCGetAttr(1,ConsoleMode);
  46. {$endif UNIX}
  47. {$ifdef Win32}
  48. GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  49. {$endif Win32}
  50. {$ifdef go32v2}
  51. ConsoleMode:=0;
  52. {$endif go32v2}
  53. End;
  54. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  55. Begin
  56. {$ifdef UNIX}
  57. TCSetAttr(1,TCSANOW,ConsoleMode);
  58. {$endif UNIX}
  59. {$ifdef Win32}
  60. SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  61. {$endif Win32}
  62. {$ifdef go32v2}
  63. {$endif go32v2}
  64. End;
  65. end.
  66. {
  67. $Log$
  68. Revision 1.3 2001-10-09 12:10:48 marco
  69. * fix.
  70. Revision 1.2 2001/10/02 23:58:51 pierre
  71. * fix linux code
  72. Revision 1.1 2001/10/02 23:40:44 pierre
  73. New unit to preserve console mode
  74. }