home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / RIPSPEED.C < prev    next >
C/C++ Source or Header  |  1995-03-19  |  5KB  |  257 lines

  1. /* RIPspeed support functions, copyright (C) 1994 by Zachary G. Ives.   *
  2.  * All rights reserved.                                                 *
  3.  *                                                                      *
  4.  * Version 1.02, 6/6/94.                                                *
  5.  * Version 1.50, 6/20/94.                                               *
  6.  * For WWIV 4.24, 8/01/94.                                              */
  7.  
  8. #include "vars.h"
  9. #include "ripint.h"
  10.  
  11. #pragma hdrstop
  12.  
  13. #include <dir.h>
  14. #include <dos.h>
  15. #include <ctype.h>
  16.  
  17. char rd_on(void)
  18. {
  19. #ifdef RIPDRIVE
  20.   return (ripdrive && ((sysinfo.flags & OP_FLAGS_RIPDRIVE_ON) != 0));
  21. #else
  22.   return(0);
  23. #endif
  24. }
  25. /****************************************************************************/
  26.  
  27.  
  28. /* Function: return TRUE if rip menus are enabled.
  29.  */
  30. int menu_on(void)
  31. {
  32. //    return (rip && ((sysstatus_expert & thisuser.sysstatus)==0)); 
  33.     return (rip_on() && ((sysstatus_expert & thisuser.sysstatus)==0));
  34. }
  35.  
  36. /* Function: return TRUE if any RIP support is available.
  37.  */
  38. int rip_on(void)
  39. {
  40.   return (rip && ((thisuser.sysstatus & sysstatus_disable_rip)==0)); 
  41. }
  42.  
  43.  
  44. #ifdef RIPDRIVE
  45. void rd_print(char *s)
  46. {
  47.   struct localrip_screeninfo r;
  48.   if (rd_on()) {
  49.     localrip_readscene(s);
  50.     localrip_textinfo(&r);
  51.     screenbottom = r.w_bottom - r.w_top - 1;
  52.   }
  53. }
  54.  
  55. void rd_str(char *s)
  56. {
  57.   struct localrip_screeninfo r;
  58.  
  59.   if (rd_on()) {
  60.     localrip_display(s);
  61.     localrip_textinfo(&r);
  62.     screenbottom = r.w_bottom - r.w_top - 1;
  63.   }
  64. }
  65. #endif
  66.  
  67. /* Function:  save the entire screen, mouse field, and clipboard information
  68.    to the user's hard disk */
  69. void rip_saveall(void)
  70. {
  71.     comstr("\1|1\x1b""0000$SAVEALL$\r");
  72. }
  73.  
  74. /* Function: restore the screen, mouse field, and clipboard info to the user's
  75.    screen */
  76. void rip_restoreall(void)
  77. {
  78.     comstr("\1|1\x1b""0000$RESTOREALL$\r ");
  79. }
  80.  
  81. /* Function: paste whatever was captured to the clipboard back in place */
  82. void rip_pcb(void)
  83. {
  84.     comstr("\1|1\x1b""0000$PCB$\r ");
  85. }
  86.  
  87. /* Function: cursor on */
  88. void rip_con(void)
  89. {
  90.     comstr("\1|1\x1b""0000$CON$|\r ");
  91. }
  92.  
  93. #ifdef RIPDRIVE
  94. void rd_coff(void)
  95. {
  96.     if (rd_on()) {
  97.       rip_coff();
  98.       localrip_disablemouse(1);
  99.     }
  100. }
  101.  
  102. void rd_con(void)
  103. {
  104.     if (rd_on()) {
  105.       rip_con();
  106.       localrip_disablemouse(0);
  107.     }
  108. }
  109. #endif
  110.  
  111. /* Function: cursor off */
  112. void rip_coff(void)
  113. {
  114.     comstr("\1|1\x1b""0000$COFF$|\r ");
  115. }
  116.  
  117. /* Function: save the mouse fields */
  118. void rip_smf(void)
  119. {
  120.     comstr("\1|1\x1b""0000$SMF$|\r ");
  121. }
  122.  
  123. /* Function: restore mouse fields */
  124. void rip_rmf(void)
  125. {
  126.     comstr("\1|1\x1b""0000$RMF$|\r ");
  127. }
  128.  
  129. /* Function: restore text window, and then paste clipboard */
  130. void rip_rtwpcb(void)
  131. {
  132.     comstr("\1|1\x1b""0000$RTW$$PCB$|#\r ");
  133. }
  134.  
  135. /* Function:  show a file in the RIP directory. */
  136. void rip_show(char *s)
  137. {
  138.   char f[68];
  139.  
  140.   sprintf(f,"%s%s", sysinfo.ripdir, s);
  141.   ripcode = 1;
  142.   maybeprint(f,2);
  143.   ripcode = 0;
  144. }
  145.  
  146. /* Function:  get a key, but display a [Continue] button on the bottom of the
  147.    screen so the user can click the mouse on it.
  148. */
  149. void getkeymouse(void)
  150. {
  151.   if (menu_on() && rip_popup && (!rip_subset)) {
  152.     outstr("As");
  153.     rip_smf();
  154.     printmenu(332);
  155.   }
  156.  
  157.     /* Do not accept a submenu_code marker as a valid "pause-breaker" */
  158.   while (getkey() == submenu_code && (hangup == 0));
  159.   if (menu_on() && rip_popup && (!rip_subset)) {
  160.     printmenu(333);
  161.     rip_rmf();
  162.     outstr("uB");
  163.   }
  164. }
  165. /* Function: clear the user's screen with a RIP_RESET code.
  166.    Doesn't display locally.
  167.  */
  168. void rip_cls(void)
  169. {
  170.     if (rip_on())
  171.       comstr("\1|*\r ");
  172. }
  173.  
  174. void out_cport(char c)
  175. {
  176.   if (change_color == 1) {
  177.     change_color = 0;
  178.     if ((c >= '0') && (c <= '9'))
  179.       ansic(c - '0');
  180.     return;
  181.   } else if (change_color == 4) {
  182.     // This byte is reserved for RIPscrip 2 font style commands & codes
  183.     if (c == 15)
  184.       change_color = 5;
  185.     else
  186.       change_color = 0;
  187.     return;
  188.   } else if (change_color == 5) {
  189.     // Control or substitution codes
  190.     change_color = 0;
  191.     remstr(interpret(c));
  192.     return;
  193.   }
  194.   if (c == 3) {
  195.     change_color = 1;
  196.     return;
  197.   } else if (c == 15) {
  198.     change_color = 4;
  199.     return;
  200.   }
  201.   if (outcom)
  202.     outcomch(c);
  203. }
  204.  
  205. void remstr(char *s)
  206. {
  207.   int i=0;
  208.  
  209.   checkhangup();
  210.   if (!hangup)
  211.     while (s[i])
  212.       out_cport(s[i++]);
  213. }
  214.  
  215. /* Function: output a string on the com port, but don't display anything
  216.    locally.  Com-port only version of outstr().
  217.  */
  218. void comstr(char *s)
  219. {
  220.   remstr(s);
  221. #ifdef RIPDRIVE
  222.   rd_str(s);
  223. #endif
  224. }
  225.  
  226. /* Output to com port with a CR but no LF. */
  227. void comr(char *s)
  228. {
  229.     comstr(s);
  230.     comstr("\r ");
  231. }
  232.  
  233. /* Output to com port with a CR and LF. */
  234. void comnl(char *s)
  235. {
  236.     comstr(s);
  237.     comstr("\r\n");
  238. }
  239.  
  240. /* Function: Wait tm seconds for a keypress.  Returns 0 if none during the
  241.    allocated time.
  242.  */
  243. char delaykey(int tm)
  244. /* Delay for time, or until key pressed */
  245. {
  246.   time_t t1,t2;
  247.   char c = 0;
  248.  
  249.   time(&t1);                /* Record initial time */
  250.   while (((time(&t2) - t1 <= tm)) && (!hangup)) {
  251.     if ((c = inkey())!=0)
  252.       break;
  253.   }
  254.   return c;
  255. }
  256.  
  257.