home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / utilitys / windom2.arc / TERMATT.MOD < prev    next >
Text File  |  1990-07-21  |  7KB  |  275 lines

  1. IMPLEMENTATION MODULE TermAtt;
  2. (*                                                             *)
  3. (*(C)Copyright 1987 Bob Catiller all commercial rights reserved*)
  4. (*                                                             *)
  5.  
  6. FROM Terminal IMPORT
  7.   WriteChar, WriteString;
  8.  
  9. FROM Terminal IMPORT
  10.   BusyRead, ClearToEOL;
  11.  
  12. FROM Convert IMPORT
  13.   StrToCard;
  14.  
  15. (* ******** IReadChar ******* *)
  16. (* This procedure is used in place of the ReadChar *)
  17. (* procedure from the texts module. This procedure *)
  18. (* provides for time sharing of independently running *)
  19. (* tasks while the system is waiting for console input. *)
  20. (* The procedure functions identical to the ReadChar *)
  21. (* procedure by returning with a character when a *)
  22. (* key is pressed on the terminal. *)
  23.  
  24. PROCEDURE IReadChar():CHAR;
  25.  
  26. VAR
  27.   c: CHAR;
  28.  
  29. BEGIN
  30.   c := CHR(0);
  31.   WHILE c = CHR(0) DO
  32.     BusyRead(c)
  33.     (* Time sharing of other tasks occurs at this point. *)
  34.     (* Calls to independently running proceedures will *)
  35.     (* be placed at this point in the program. *)
  36.   END;(* WHILE *)
  37.   IF c = CHR(27) THEN
  38.     escape := TRUE;
  39.   END;(* IF *)
  40.   RETURN c;
  41. END IReadChar;
  42.  
  43. (* ******** RangeCard ******* *)
  44. (* Reads a cardinal with the selected input range. *)
  45.  
  46. VAR
  47.   i1:CARDINAL;
  48.  
  49. PROCEDURE RangeCard(min,max: CARDINAL): CARDINAL;
  50. BEGIN
  51.   GetRC();
  52.   LOOP
  53.     i1:= max+1;(* Force out-of-range *)
  54.     SetRC(r,c);
  55.     i1 := IReadCard();
  56.     IF escape THEN
  57.       EXIT;
  58.     END;(* IF *)
  59.     IF NOT Valid THEN
  60.       SetRC(CHR(ORD(r)+1),c);
  61.       WriteString("Invalid entry.");
  62.       SetRC(r, c);
  63.       ClearToEOL;
  64.     ELSE
  65.       SetRC(CHR(ORD(r)+1),c);
  66.       ClearToEOL;
  67.     END;(* IF *)
  68.     SetRC(CHR(ORD(r)+1),c);
  69.     IF i1 < min THEN
  70.       WriteString("Value too small.");
  71.       SetRC(r, c);
  72.       ClearToEOL;
  73.     ELSIF i1 > max THEN
  74.       WriteString("Value too large.");
  75.       SetRC(r, c);
  76.       ClearToEOL;
  77.     ELSE
  78.       EXIT;
  79.     END;(* IF *)
  80.   END;(* LOOP *)
  81.   RETURN i1;
  82. END RangeCard;
  83.  
  84. (* ******** IReadCard ******** *)
  85. (* Reads a cardinal value from the terminal *)
  86. (* and returns with it. *)
  87.  
  88. VAR
  89.   i2: CARDINAL;
  90. VAR
  91.   str: ARRAY [0..1] OF CHAR;
  92.  
  93. PROCEDURE IReadCard():CARDINAL;
  94. BEGIN
  95.   IReadString(str);
  96.   Valid := StrToCard(str,i2);
  97.   RETURN i2;
  98. END IReadCard;
  99.  
  100. (* ******** IReadString ******** *)
  101. (* reads a 2 character numeric string from the terminal *)
  102.  
  103. VAR
  104.   c4: CHAR;
  105.  
  106. PROCEDURE IReadString(VAR str: ARRAY OF CHAR);
  107. BEGIN
  108.   LOOP
  109.     REPEAT
  110.       CursorOn;
  111.       c4 := IReadChar();
  112.       IF escape THEN
  113.         CursorOff;
  114.         EXIT;
  115.       END;(* IF *)
  116.     UNTIL ((c4 >= "0") AND (c4 <= "9"));
  117.     str[0] := c4;
  118.     WriteChar(c4);
  119.     REPEAT
  120.       c4 := IReadChar();
  121.       IF escape THEN
  122.         CursorOff;
  123.         EXIT;
  124.       END;(* IF *)
  125.     UNTIL ((c4 >= "0") AND (c4 <= "9"));
  126.     str[1] := c4;
  127.     WriteChar(c4);
  128.     CursorOff;
  129.     EXIT;
  130.   END;(* LOOP *)
  131. END IReadString;
  132.  
  133. (* ******** GetRC ******* *)
  134. (* Gets current Row (r) and Column (c) cursor *)
  135. (* position from Wyse 50 terminal. *)
  136.  
  137. PROCEDURE GetRC();
  138. BEGIN
  139.   WriteChar(CHR(27));(* ASCII escape character *)
  140.   WriteChar("?");
  141.   r := IReadChar();(* Get row address *)
  142.   c := IReadChar();(* Get Column address *)
  143. END GetRC;
  144.  
  145. (* ******** SetRC ******* *)
  146. (* Set selected Row (row) and Column (col) cursor address *)
  147. (* on Wyse 50 terminal. *)
  148.  
  149. PROCEDURE SetRC(row,col: CHAR);
  150. BEGIN
  151.   WriteChar(CHR(27));(* ASCII escape character *)
  152.   WriteChar("=");
  153.   WriteChar(row);(* Set Row address *)
  154.   WriteChar(col);(* Set Column address *)
  155. END SetRC;
  156.  
  157. (* ******** SetAtt ******* *)
  158. (* Set selected attribute at present cursor location *)
  159. (* on Wyse 50 terminal. *)
  160.  
  161. PROCEDURE SetAtt(ch: CHAR);
  162. BEGIN
  163. (* Control sequence to set attributes on Wyse 50 *)
  164.   WriteChar(CHR(27));(* ASCII escape character *)
  165.   WriteChar("G");
  166.   WriteChar(ch);
  167. END SetAtt;
  168.  
  169. (* ******** RevVideo ********* *)
  170. (* Set reverse video attribute at present cursor *)
  171. (* location on Wyse 50. *)
  172.  
  173. PROCEDURE RevVideo();
  174. BEGIN(* Attribute code to activate reverse video on Wyse 50 *)
  175.   SetAtt("4");
  176. END RevVideo;
  177.  
  178. (* ******** DimRevVideo ********* *)
  179. (* Set dim and reverse video attribute at present cursor *)
  180. (* location on Wyse 50. *)
  181.  
  182. PROCEDURE DimRevVideo();
  183. BEGIN(* Attribute code to activate reverse video on Wyse 50 *)
  184.   SetAtt("t");
  185. END DimRevVideo;
  186.  
  187. (* ********* NormVideo ******** *)
  188. (* Set normal (non-reverse) video on Wyse 50. *)
  189.  
  190. PROCEDURE NormVideo();
  191. BEGIN
  192. (* Attribute code to activate normal video on Wyse 50 *)
  193.   SetAtt("0");
  194. END NormVideo;
  195.  
  196. (* ********* Dim ******** *)
  197. (* Set dim attribute on Wyse 50. *)
  198.  
  199. PROCEDURE Dim();
  200. BEGIN
  201. (* Attribute code to activate dim video on Wyse 50 *)
  202.   SetAtt("p");
  203. END Dim;
  204.  
  205. (* ********* Blink ******** *)
  206. (* Set dim attribute on Wyse 50. *)
  207.  
  208. PROCEDURE Blink();
  209. BEGIN
  210. (* Attribute code to activate blinking on Wyse 50 *)
  211.   SetAtt("2");
  212. END Blink;
  213.  
  214. (* ********** CursorOn ************ *)
  215.   (* Turns on cursor *)
  216.   (* Sends cursor on control sequence *)
  217.   (* for Wyse 50 terminal. *)
  218.  
  219.   PROCEDURE CursorOn;
  220.  
  221.   BEGIN
  222.     WriteChar(CHR(27));(* escape character *)
  223.     WriteChar("`");
  224.     WriteChar("1");(* cursor on code *)
  225.   END CursorOn;
  226.  
  227. (* ********** CursorOff ************ *)
  228.   (* Turns off cursor *)
  229.   (* Sends cursor off control sequence *)
  230.   (* for Wyse 50 terminal. *)
  231.  
  232.   PROCEDURE CursorOff();
  233.  
  234.   BEGIN
  235.     WriteChar(CHR(27));(* escape character *)
  236.     WriteChar("`");
  237.     WriteChar("0");(* cursor off code *)
  238.   END CursorOff;
  239.  
  240. (* ********** GraphicOn ************ *)
  241. (* Initiate graphics mode on a Wyse 50 terminal. *)
  242.  
  243.   PROCEDURE GraphicOn();
  244.  
  245.   BEGIN
  246.     WriteChar(CHR(27));(* ASCII escape character *)
  247.     WriteChar("H");
  248.     WriteChar(CHR(2));(* ASCII STX character *)
  249.   END GraphicOn;
  250.  
  251. (* ********** GraphicOff ************ *)
  252. (* Wyse 50 terminal to normal display mode. *)
  253.  
  254.   PROCEDURE GraphicOff();
  255.  
  256.   BEGIN
  257.     WriteChar(CHR(27));(* ASCII escape character *)
  258.     WriteChar("H");
  259.     WriteChar(CHR(3));(* ASCII ETX character *)
  260.   END GraphicOff;
  261.  
  262. (* ********** GraphicChar ************ *)
  263. (* Outputs single character as graphic character *)
  264. (* on Wyse 50 terminal. *)
  265.  
  266.   PROCEDURE GraphicChar(ch: CHAR);
  267.  
  268.   BEGIN
  269.     WriteChar(CHR(27));(* ASCII escape character *)
  270.     WriteChar("H");
  271.     WriteChar(ch);(* write graphics char *)
  272.   END GraphicChar;
  273.  
  274.  
  275. END TermAtt.