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 OS2}
  26. dword
  27. {$endif OS2}
  28. {$ifdef UNIX}
  29. TermIos
  30. {$endif UNIX}
  31. {$ifdef Win32}
  32. dword
  33. {$endif Win32}
  34. {$ifdef go32v2}
  35. longint
  36. {$endif go32v2}
  37. ;
  38. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  39. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  40. implementation
  41. {$ifdef Win32}
  42. uses
  43. windows;
  44. {$endif Win32}
  45. Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
  46. Begin
  47. {$ifdef UNIX}
  48. TCGetAttr(1,ConsoleMode);
  49. {$endif UNIX}
  50. {$ifdef Win32}
  51. GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  52. {$endif Win32}
  53. {$ifdef go32v2}
  54. ConsoleMode:=0;
  55. {$endif go32v2}
  56. End;
  57. Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);
  58. Begin
  59. {$ifdef UNIX}
  60. TCSetAttr(1,TCSANOW,ConsoleMode);
  61. {$endif UNIX}
  62. {$ifdef Win32}
  63. SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ConsoleMode);
  64. {$endif Win32}
  65. {$ifdef go32v2}
  66. {$endif go32v2}
  67. End;
  68. end.
  69. {
  70. $Log$
  71. Revision 1.5 2002-10-12 19:42:01 hajny
  72. + OS/2 support
  73. Revision 1.4 2002/09/07 15:40:48 peter
  74. * old logs removed and tabs fixed
  75. }