baseconi.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. Constructor TPTCBaseConsole.Create;
  18. Begin
  19. FReleaseEnabled := False;
  20. End;
  21. Procedure TPTCBaseConsole.open(Const _title : String);{ Overload;}
  22. Begin
  23. open(_title, 0);
  24. End;
  25. Procedure TPTCBaseConsole.open(Const _title : String; Const _format : TPTCFormat);{ Overload;}
  26. Begin
  27. open(_title, _format, 0);
  28. End;
  29. Procedure TPTCBaseConsole.open(Const _title : String; _width, _height : Integer;
  30. Const _format : TPTCFormat);{ Overload;}
  31. Begin
  32. open(_title, _width, _height, _format, 0);
  33. End;
  34. Procedure TPTCBaseConsole.open(Const _title : String; Const _mode : TPTCMode);{ Overload;}
  35. Begin
  36. open(_title, _mode, 0);
  37. End;
  38. Function TPTCBaseConsole.KeyPressed : Boolean;
  39. Var
  40. k : TPTCKey;
  41. Begin
  42. k := TPTCKey.Create;
  43. Try
  44. Repeat
  45. If internal_PeekKey(k) = False Then
  46. Exit(False);
  47. If FReleaseEnabled Or k.Press Then
  48. Exit(True);
  49. internal_ReadKey(k);
  50. Until False;
  51. Finally
  52. k.Free;
  53. End;
  54. End;
  55. Procedure TPTCBaseConsole.ReadKey(k : TPTCKey);
  56. Begin
  57. Repeat
  58. internal_ReadKey(k);
  59. Until FReleaseEnabled Or k.Press;
  60. End;
  61. Function TPTCBaseConsole.PeekKey(k : TPTCKey) : Boolean;
  62. Begin
  63. If KeyPressed Then
  64. Begin
  65. ReadKey(k);
  66. Result := True;
  67. End
  68. Else
  69. Result := False;
  70. End;
  71. Procedure TPTCBaseConsole.ReadKey;
  72. Var
  73. k : TPTCKey;
  74. Begin
  75. k := TPTCKey.Create;
  76. Try
  77. ReadKey(k);
  78. Finally
  79. k.Free;
  80. End;
  81. End;