wconsole.pas 1.7 KB

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