wconsole.pas 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. TermInfo,
  16. {$Ifdef ver1_0}
  17. linux;
  18. {$else}
  19. termio;
  20. {$endif}
  21. {$endif UNIX}
  22. type
  23. TConsoleMode =
  24. {$ifdef OS2}
  25. dword
  26. {$endif OS2}
  27. {$ifdef UNIX}
  28. TermIos
  29. {$endif UNIX}
  30. {$ifdef Win32}
  31. dword
  32. {$endif Win32}
  33. {$ifdef go32v2}
  34. longint
  35. {$endif go32v2}
  36. {$ifdef netware}
  37. longint
  38. {$endif netware}
  39. ;
  40. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  41. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  42. implementation
  43. {$ifdef Win32}
  44. uses
  45. windows;
  46. {$endif Win32}
  47. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  48. Begin
  49. {$ifdef UNIX}
  50. TCGetAttr(1,ConsoleMode);
  51. {$endif UNIX}
  52. {$ifdef Win32}
  53. GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  54. {$endif Win32}
  55. {$ifdef go32v2}
  56. ConsoleMode:=0;
  57. {$endif go32v2}
  58. {$ifdef netware}
  59. ConsoleMode:=0;
  60. {$endif}
  61. End;
  62. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  63. Begin
  64. {$ifdef UNIX}
  65. TCSetAttr(1,TCSANOW,ConsoleMode);
  66. {$endif UNIX}
  67. {$ifdef Win32}
  68. SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  69. {$endif Win32}
  70. {$ifdef go32v2}
  71. {$endif go32v2}
  72. End;
  73. end.