ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 lines
3.7 KiB

  1. /***************************************************************
  2. bwx_tty.c TTY front-end
  3. for Bywater BASIC Interpreter
  4. Copyright (c) 1993, Ted A. Campbell
  5. Bywater Software
  6. email: tcamp@delphi.com
  7. Copyright and Permissions Information:
  8. All U.S. and international rights are claimed by the author,
  9. Ted A. Campbell.
  10. This software is released under the terms of the GNU General
  11. Public License (GPL), which is distributed with this software
  12. in the file "COPYING". The GPL specifies the terms under
  13. which users may copy and use the software in this distribution.
  14. A separate license is available for commercial distribution,
  15. for information on which you should contact the author.
  16. ***************************************************************/
  17. /*---------------------------------------------------------------*/
  18. /* NOTE: Modifications marked "JBV" were made by Jon B. Volkoff, */
  19. /* 11/1995 (eidetics@cerf.net). */
  20. /* */
  21. /* Those additionally marked with "DD" were at the suggestion of */
  22. /* Dale DePriest (daled@cadence.com). */
  23. /* */
  24. /* Version 3.00 by Howard Wulf, AF5NE */
  25. /* */
  26. /* Version 3.10 by Howard Wulf, AF5NE */
  27. /* */
  28. /* Version 3.20 by Howard Wulf, AF5NE */
  29. /* */
  30. /*---------------------------------------------------------------*/
  31. #include "bwbasic.h"
  32. extern void
  33. bwx_LOCATE (int Row, int Col)
  34. {
  35. /* position the cursor to Row and Col */
  36. /* Row is 1 based, 1..24 */
  37. /* Col is 1 based, 1..80 */
  38. assert (My != NULL);
  39. assert (My->SYSOUT != NULL);
  40. assert (My->SYSOUT->cfp != NULL);
  41. if (Row < 1 || Col < 1)
  42. {
  43. WARN_ILLEGAL_FUNCTION_CALL;
  44. return;
  45. }
  46. switch (My->OptionTerminalType)
  47. {
  48. case C_OPTION_TERMINAL_NONE:
  49. break;
  50. case C_OPTION_TERMINAL_ADM:
  51. fprintf (My->SYSOUT->cfp, "\e=%c%c", Row + 32, Col + 32);
  52. break;
  53. case C_OPTION_TERMINAL_ANSI:
  54. fprintf (My->SYSOUT->cfp, "\e[%d;%dH", Row, Col);
  55. break;
  56. default:
  57. WARN_ADVANCED_FEATURE;
  58. break;
  59. }
  60. fflush (My->SYSOUT->cfp);
  61. My->SYSOUT->row = Row;
  62. My->SYSOUT->col = Col;
  63. }
  64. extern void
  65. bwx_CLS (void)
  66. {
  67. /* clear screen */
  68. assert (My != NULL);
  69. assert (My->SYSOUT != NULL);
  70. assert (My->SYSOUT->cfp != NULL);
  71. switch (My->OptionTerminalType)
  72. {
  73. case C_OPTION_TERMINAL_NONE:
  74. break;
  75. case C_OPTION_TERMINAL_ADM:
  76. fputc(26, My->SYSOUT->cfp);
  77. break;
  78. case C_OPTION_TERMINAL_ANSI:
  79. fputs("\e[2J", My->SYSOUT->cfp);
  80. break;
  81. default:
  82. WARN_ADVANCED_FEATURE;
  83. break;
  84. }
  85. bwx_LOCATE (1, 1);
  86. }
  87. extern void
  88. bwx_COLOR (int Fore, int Back)
  89. {
  90. /* set foreground and background color */
  91. /* Fore is 0 based, 0..15 */
  92. /* Back is 0 based, 0..15 */
  93. assert (My != NULL);
  94. assert (My->SYSOUT != NULL);
  95. assert (My->SYSOUT->cfp != NULL);
  96. if (Fore < 0 || Fore > 15 || Back < 0 || Back > 15)
  97. {
  98. WARN_ILLEGAL_FUNCTION_CALL;
  99. return;
  100. }
  101. switch (My->OptionTerminalType)
  102. {
  103. case C_OPTION_TERMINAL_NONE:
  104. break;
  105. case C_OPTION_TERMINAL_ADM:
  106. break;
  107. case C_OPTION_TERMINAL_ANSI:
  108. fprintf (My->SYSOUT->cfp, "\e[%d;%dm",
  109. Fore+(Fore>7 ? 82 : 30),
  110. Back+(Back>7 ? 92 : 40)
  111. );
  112. break;
  113. default:
  114. WARN_ADVANCED_FEATURE;
  115. break;
  116. }
  117. fflush (My->SYSOUT->cfp);
  118. }
  119. /* EOF */