wconsole.pas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. linux;
  18. {$endif UNIX}
  19. type
  20. TConsoleMode =
  21. {$ifdef UNIX}
  22. TermIos
  23. {$endif UNIX}
  24. {$ifdef Win32}
  25. dword
  26. {$endif Win32}
  27. {$ifdef go32v2}
  28. longint
  29. {$endif go32v2}
  30. ;
  31. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  32. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  33. implementation
  34. {$ifdef Win32}
  35. uses
  36. windows;
  37. {$endif Win32}
  38. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  39. Begin
  40. {$ifdef UNIX}
  41. TCGetAttr(1,ConsoleMode);
  42. {$endif UNIX}
  43. {$ifdef Win32}
  44. GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  45. {$endif Win32}
  46. {$ifdef go32v2}
  47. ConsoleMode:=0;
  48. {$endif go32v2}
  49. End;
  50. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  51. Begin
  52. {$ifdef UNIX}
  53. TCSetAttr(1,TCSANOW,ConsoleMode);
  54. {$endif UNIX}
  55. {$ifdef Win32}
  56. SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  57. {$endif Win32}
  58. {$ifdef go32v2}
  59. {$endif go32v2}
  60. End;
  61. end.
  62. {
  63. $Log$
  64. Revision 1.2 2001-10-02 23:58:51 pierre
  65. * fix linux code
  66. Revision 1.1 2001/10/02 23:40:44 pierre
  67. New unit to preserve console mode
  68. }