Console.ob07 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. (*
  2. Copyright 2016, 2018 Anton Krotov
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  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. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. *)
  14. MODULE Console;
  15. IMPORT ConsoleLib, In, Out;
  16. CONST
  17. Black* = 0; Blue* = 1; Green* = 2; Cyan* = 3;
  18. Red* = 4; Magenta* = 5; Brown* = 6; LightGray* = 7;
  19. DarkGray* = 8; LightBlue* = 9; LightGreen* = 10; LightCyan* = 11;
  20. LightRed* = 12; LightMagenta* = 13; Yellow* = 14; White* = 15;
  21. PROCEDURE SetCursor* (X, Y: INTEGER);
  22. BEGIN
  23. ConsoleLib.set_cursor_pos(X, Y)
  24. END SetCursor;
  25. PROCEDURE GetCursor* (VAR X, Y: INTEGER);
  26. BEGIN
  27. ConsoleLib.get_cursor_pos(X, Y)
  28. END GetCursor;
  29. PROCEDURE Cls*;
  30. BEGIN
  31. ConsoleLib.cls
  32. END Cls;
  33. PROCEDURE SetColor* (FColor, BColor: INTEGER);
  34. VAR
  35. res: INTEGER;
  36. BEGIN
  37. IF (FColor IN {0..15}) & (BColor IN {0..15}) THEN
  38. res := ConsoleLib.set_flags(LSL(BColor, 4) + FColor)
  39. END
  40. END SetColor;
  41. PROCEDURE GetCursorX* (): INTEGER;
  42. VAR
  43. x, y: INTEGER;
  44. BEGIN
  45. ConsoleLib.get_cursor_pos(x, y)
  46. RETURN x
  47. END GetCursorX;
  48. PROCEDURE GetCursorY* (): INTEGER;
  49. VAR
  50. x, y: INTEGER;
  51. BEGIN
  52. ConsoleLib.get_cursor_pos(x, y)
  53. RETURN y
  54. END GetCursorY;
  55. PROCEDURE open*;
  56. BEGIN
  57. ConsoleLib.open(-1, -1, -1, -1, "");
  58. In.Open;
  59. Out.Open
  60. END open;
  61. PROCEDURE exit* (bCloseWindow: BOOLEAN);
  62. BEGIN
  63. ConsoleLib.exit(bCloseWindow)
  64. END exit;
  65. END Console.