home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / sfs / part05 < prev    next >
Encoding:
Text File  |  1991-12-27  |  55.2 KB  |  2,255 lines

  1. Newsgroups: comp.sources.misc
  2. From: tcamp@hercules.acpub.duke.edu (Ted Campbell)
  3. Subject:  v27i005:  sfs - Space Flight Simulator, Part05/21
  4. Message-ID: <1991Dec24.045305.29726@sparky.imd.sterling.com>
  5. X-Md4-Signature: 844e7682c929b5948638c8f26157ee7a
  6. Date: Tue, 24 Dec 1991 04:53:05 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: tcamp@hercules.acpub.duke.edu (Ted Campbell)
  10. Posting-number: Volume 27, Issue 5
  11. Archive-name: sfs/part05
  12. Environment: IBMPC && EGA/VGA, UNIX-PC && MGR, UNIX && X11,
  13.  
  14. #!/bin/sh
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file io/gr/makefile.tam continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 5; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping io/gr/makefile.tam'
  32. else
  33. echo 'x - continuing file io/gr/makefile.tam'
  34. sed 's/^X//' << 'SHAR_EOF' >> '_shar_tmp_.tmp' &&
  35. M0T9,04=3/0D)+4\@+41$14)51PH*3T9)3$53/0D)9W)?=&5S="YO(&=R7W1A
  36. M;2YO(&=R7V1E9BYO"@IG<E]T97-T.@DD*$]&24Q%4RD*"0DD*$-#*2`D*$]&
  37. M24Q%4RD@:V)?-S,P,"YO(%P*"0DM;'1A;2`M;'1E<FUC87`@+6QM("UO(&=R
  38. M7W1E<W0*"F9O;G1T97-T.@EF;VYT=&5S="YO"@D))"A#0RD@9F]N='1E<W0N
  39. M;R`M;'1A;2`M;'1E<FUC87`@+6\@9F]N='1E<W0*"G%R9CH)"0H)"6-A="!G
  40. M<BYH(#YG<BYQ<F8*"0ER;6)O9'D@/&=R7W1A;2YC(#X^9W(N<7)F"@IK8CH*
  41. ="0EC8R`M3R`M8R`N+B]K8B]K8E\W,S`P+F,*"AIC
  42. `
  43. end
  44. SHAR_EOF
  45. echo 'File io/gr/makefile.tam is complete' &&
  46. echo 'uudecoding file io/gr/makefile.tam' &&
  47. uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
  48. chmod 0644 io/gr/makefile.tam ||
  49. echo 'restore of io/gr/makefile.tam failed'
  50. Wc_c="`wc -c < 'io/gr/makefile.tam'`"
  51. test 299 -eq "$Wc_c" ||
  52.     echo 'io/gr/makefile.tam: original size 299, current size' "$Wc_c"
  53. rm -f _shar_wnt_.tmp
  54. fi
  55. # ============= io/kb/kb.h ==============
  56. if test ! -d 'io/kb'; then
  57.     echo 'x - creating directory io/kb'
  58.     mkdir 'io/kb'
  59. fi
  60. if test -f 'io/kb/kb.h' -a X"$1" != X"-c"; then
  61.     echo 'x - skipping io/kb/kb.h (File already exists)'
  62.     rm -f _shar_wnt_.tmp
  63. else
  64. > _shar_wnt_.tmp
  65. echo 'x - extracting io/kb/kb.h (Text)'
  66. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb.h' &&
  67. /*************************************************************************
  68. X
  69. X    kb.h            Header file for keyboard (KB) subroutines
  70. X            for Bywater Software.
  71. X
  72. X            Copyright (c) 1991, Ted A. Campbell
  73. X
  74. X            Bywater Software
  75. X            P. O. Box 4023 
  76. X            Duke Station 
  77. X            Durham, NC  27706
  78. X
  79. X            email: tcamp@hercules.acpub.duke.edu
  80. X
  81. X    Copyright and Permissions Information:
  82. X
  83. X    All U.S. and international copyrights are claimed by the
  84. X    author. The author grants permission to use this code
  85. X    and software based on it under the following conditions:
  86. X    (a) in general, the code and software based upon it may be 
  87. X    used by individuals and by non-profit organizations; (b) it
  88. X    may also be utilized by governmental agencies in any country,
  89. X    with the exception of military agencies; (c) the code and/or
  90. X    software based upon it may not be sold for a profit without
  91. X    an explicit and specific permission from the author, except
  92. X    that a minimal fee may be charged for media on which it is
  93. X    copied, and for copying and handling; (d) the code must be 
  94. X    distributed in the form in which it has been released by the
  95. X    author; and (e) the code and software based upon it may not 
  96. X    be used for illegal activities. 
  97. X
  98. **************************************************************************/
  99. X
  100. #define KB_ALT          0x500
  101. X
  102. #define KB_UP           0x201
  103. #define KB_DOWN         0x202
  104. #define KB_LEFT         0x203
  105. #define KB_RIGHT        0x204
  106. #define KB_P_UP         0x207
  107. #define KB_P_DOWN       0x208
  108. #define KB_HOME         0x209
  109. #define KB_END          0x20a
  110. #define KB_INSERT       0x211
  111. #define KB_DELETE       0x212
  112. X
  113. #define KB_FK0          0x220
  114. #define KB_FK1          0x221
  115. #define KB_FK2          0x222
  116. #define KB_FK3          0x223
  117. #define KB_FK4          0x224
  118. #define KB_FK5          0x225
  119. #define KB_FK6          0x226
  120. #define KB_FK7          0x227
  121. #define KB_FK8          0x228
  122. #define KB_FK9          0x229
  123. X
  124. SHAR_EOF
  125. chmod 0644 io/kb/kb.h ||
  126. echo 'restore of io/kb/kb.h failed'
  127. Wc_c="`wc -c < 'io/kb/kb.h'`"
  128. test 1891 -eq "$Wc_c" ||
  129.     echo 'io/kb/kb.h: original size 1891, current size' "$Wc_c"
  130. rm -f _shar_wnt_.tmp
  131. fi
  132. # ============= io/kb/kb_7300.c ==============
  133. if test -f 'io/kb/kb_7300.c' -a X"$1" != X"-c"; then
  134.     echo 'x - skipping io/kb/kb_7300.c (File already exists)'
  135.     rm -f _shar_wnt_.tmp
  136. else
  137. > _shar_wnt_.tmp
  138. echo 'x - extracting io/kb/kb_7300.c (Text)'
  139. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_7300.c' &&
  140. /*************************************************************************
  141. X
  142. X    kb_7300.c       Keyboard (KB) Subroutines
  143. X            for Bywater Software
  144. X
  145. X            Implementation for AT&T Unix PC (7300)
  146. X
  147. X            Copyright (c) 1991, Ted A. Campbell
  148. X
  149. X            Bywater Software
  150. X            P. O. Box 4023 
  151. X            Duke Station 
  152. X            Durham, NC  27706
  153. X
  154. X            email: tcamp@hercules.acpub.duke.edu
  155. X
  156. X    Copyright and Permissions Information:
  157. X
  158. X    All U.S. and international copyrights are claimed by the
  159. X    author. The author grants permission to use this code
  160. X    and software based on it under the following conditions:
  161. X    (a) in general, the code and software based upon it may be 
  162. X    used by individuals and by non-profit organizations; (b) it
  163. X    may also be utilized by governmental agencies in any country,
  164. X    with the exception of military agencies; (c) the code and/or
  165. X    software based upon it may not be sold for a profit without
  166. X    an explicit and specific permission from the author, except
  167. X    that a minimal fee may be charged for media on which it is
  168. X    copied, and for copying and handling; (d) the code must be 
  169. X    distributed in the form in which it has been released by the
  170. X    author; and (e) the code and software based upon it may not 
  171. X    be used for illegal activities. 
  172. X
  173. **************************************************************************/
  174. X
  175. #define    ATT_TAM        TRUE
  176. #define    ATT_MGR        FALSE
  177. #define    WRITE_OUTPUT    FALSE
  178. X
  179. #include "stdio.h"
  180. #include "fcntl.h"
  181. #include "signal.h"
  182. #include "sys/stat.h"
  183. #include "termio.h"
  184. #include "bw.h"
  185. #include "kb.h"
  186. X
  187. #if    ATT_TAM
  188. #include "tam.h"
  189. #define    NO_KEY    -1
  190. #else
  191. #define    NO_KEY    FALSE
  192. #endif
  193. X
  194. #ifndef    TRUE
  195. #define    TRUE    1
  196. #define    FALSE    0
  197. #endif
  198. X
  199. #ifndef    ESC
  200. #define    ESC    0x1b
  201. #endif
  202. X
  203. #if ATT_TAM
  204. extern int w;            /* window identifier */
  205. extern int tam_mready;        /* is mouse ready with data ? */
  206. extern int tam_mx, tam_my;    /* mouse position x, y */
  207. int tam_mb, tam_mr;        /* button, reason for mouse */
  208. int tam_kready = FALSE;
  209. int kb_hold = 0;
  210. X
  211. #if WRITE_OUTPUT
  212. FILE *outfile;
  213. #endif
  214. X
  215. #else
  216. struct termio old_ttystruct;
  217. int    kb_tty;            /* fd for new terminal file */
  218. #endif
  219. X
  220. X
  221. #ifdef    KB_TEST
  222. main()
  223. X   {
  224. X   register int s;
  225. X   static char tbuf[ 3 ];
  226. X
  227. X   kb_init();
  228. X
  229. X   tbuf[ 0 ] = 0;
  230. X   while ( tbuf[ 0 ] != 0x1b )
  231. X      {
  232. #if ATT_TAM
  233. X      s = wgetc( w );
  234. #else
  235. X      s = read( kb_tty, tbuf, 1 );
  236. #endif
  237. X      printf( "The read() function returned %d \n", s );
  238. X      if ( s > 0 )
  239. X         {
  240. X         printf( "The key is <%c> \n", tbuf[ 0 ] );
  241. X         }
  242. X      }
  243. X
  244. X   kb_deinit();
  245. X   }
  246. #endif
  247. X
  248. /*************************************************************************
  249. X
  250. X   FUNCTION:       kb_init()
  251. X
  252. X   DESCRIPTION:    This function should perform any initialization
  253. X         necessary for the keyboard system.
  254. X
  255. X   INPUT:          none.
  256. X
  257. X   RETURNS:        none.
  258. X
  259. **************************************************************************/
  260. X
  261. kb_init()
  262. X   {
  263. #if  ATT_TAM
  264. X
  265. X   keypad( 0, 1 );
  266. X   wndelay( w, 1 );
  267. X
  268. #if WRITE_OUTPUT
  269. X   if ( ( outfile = fopen( "output", "w" ) ) == NULL )
  270. X      {
  271. X      bw_error( "Failed to open outfile <output> " );
  272. X      }
  273. #endif    
  274. #else
  275. X   struct termio new_ttystruct;
  276. X
  277. X   if ( ioctl( 0, TCGETA, &old_ttystruct ) < 0 )  
  278. X      {
  279. X      bw_error( "Failed to get old tty parameters." );
  280. X      }
  281. X
  282. X   if ( ( kb_tty = open( "/dev/tty", O_NDELAY)) == -1 )
  283. X      {
  284. X      bw_error( "Failed to open /dev/tty" );
  285. X      }
  286. #ifdef   DEBUG
  287. X   else
  288. X      {
  289. X      sprintf( bw_ebuf, "/dev/tty returns %d \n", kb_tty );
  290. X      bw_debug( bw_ebuf );
  291. X      }
  292. #endif
  293. X
  294. X   if ( ioctl( kb_tty, TCGETA, &new_ttystruct ) < 0 )  
  295. X      {
  296. X      bw_error( "Failed to get new tty parameters." );
  297. X      }
  298. X
  299. X   new_ttystruct.c_cc[4] = 0;      /* minimum characters */
  300. X   new_ttystruct.c_cc[5] = 0;      /* maximum time */
  301. X   new_ttystruct.c_iflag = 0;
  302. X   new_ttystruct.c_lflag = ISIG;
  303. X   new_ttystruct.c_cflag &= ~CSIZE;
  304. X   new_ttystruct.c_cflag |= CS8;
  305. X   new_ttystruct.c_cflag &= ~PARENB;
  306. X   if ( ioctl( kb_tty, TCSETA, &new_ttystruct ) < 0 )  
  307. X      {
  308. X      fprintf( stderr, "Failed to set new tty parameters. \n" );
  309. X      }
  310. X
  311. #endif
  312. X
  313. X   }
  314. X
  315. X
  316. X
  317. /*************************************************************************
  318. X
  319. X   FUNCTION:       kb_deinit()
  320. X
  321. X   DESCRIPTION:    This function should perform any necessary
  322. X         deinitialization, that is, return the keyboard
  323. X         to its default state when a Simple Software
  324. X         program is to be exited.
  325. X
  326. X   INPUT:          none.
  327. X
  328. X   RETURNS:        none.
  329. X
  330. **************************************************************************/
  331. X
  332. kb_deinit()
  333. X   {
  334. #if  ATT_TAM
  335. #else
  336. X   if ( ioctl( 0, TCSETA, &old_ttystruct ) < 0 )
  337. X      {
  338. X      fprintf( stderr, "Failed to restore old tty parameters. \n");
  339. X      }
  340. #endif
  341. X   }
  342. X
  343. /*************************************************************************
  344. X
  345. X   FUNCTION:       kb_rxstat()
  346. X
  347. X   DESCRIPTION:    This function determines whether a character is
  348. X           ready from the console.  The function is used
  349. X           especially in telecommunications programs,
  350. X           where it is necessary to poll the keyboard
  351. X           without locking up the program waiting for a
  352. X           response.
  353. X
  354. X   INPUT:          none.
  355. X
  356. X   RETURNS:        The function returns 0 if no character is
  357. X           available and 1 if a character is available.
  358. X
  359. **************************************************************************/
  360. X
  361. kb_rxstat()
  362. X   {
  363. X
  364. #if WRITE_OUTPUT
  365. X   fprintf( outfile, "kb_rxstat(): enter\n" );
  366. X   fflush( outfile );
  367. #endif
  368. X
  369. X   if ( tam_kready == FALSE )
  370. X      {
  371. X      att_rxstat();
  372. X      }
  373. X
  374. #if WRITE_OUTPUT
  375. X   fprintf( outfile, "kb_rxstat(): returns %d\n", tam_kready );
  376. X   fflush( outfile );
  377. #endif
  378. X
  379. X   return tam_kready;
  380. X   }
  381. X
  382. att_rxstat()
  383. X   {
  384. X   int r;
  385. X   register int s;
  386. #if ATT_TAM
  387. #else
  388. X   static char tbuf[3];
  389. #endif
  390. X
  391. #if WRITE_OUTPUT
  392. X   fprintf( outfile, "att_rxstat(): enter\n" );
  393. X   fflush( outfile );
  394. #endif
  395. X
  396. X   /* This should be the only point at which a character
  397. X      is read */
  398. X
  399. #if ATT_TAM
  400. X   s = wgetc( w );
  401. #else
  402. X   s = read( kb_tty, tbuf, 1 );
  403. #endif
  404. X
  405. X   /* if no character is available, return false */
  406. X
  407. X   if ( s == NO_KEY )
  408. X      {
  409. X      return FALSE;
  410. X      }
  411. X
  412. X   /* we have now read a character */
  413. X
  414. #if  ATT_TAM
  415. X   kb_hold = s;
  416. #else
  417. X   kb_hold = tbuf[ 0 ];
  418. #endif
  419. X
  420. #if WRITE_OUTPUT
  421. X   fprintf( outfile, "att_rxstat(): read kb_hold 0x%02x\n", kb_hold );
  422. X   fflush( outfile );
  423. #endif
  424. X
  425. X   /* check to see if the available key indicates
  426. X      an escape sequence of any sort */
  427. X
  428. X   if ( kb_hold == ESC )
  429. X      {
  430. X      r = att_esc();            
  431. X      }
  432. X   else if ( kb_hold > 127 )
  433. X      {
  434. X      r = att_seq( kb_hold );
  435. X      }
  436. X   else
  437. X      {
  438. X      r = kb_hold;
  439. X      }
  440. X
  441. #if WRITE_OUTPUT
  442. X   fprintf( outfile, "att_rxstat(): read r 0x%02x\n", r );
  443. X   fflush( outfile );
  444. #endif
  445. X
  446. X   /* now check to see if there is a key or mouse input
  447. X      available */
  448. X
  449. X   if ( r == 0 )
  450. X      {
  451. X      if ( ( tam_kready == TRUE ) || ( tam_mready == TRUE ))
  452. X         {
  453. X         return TRUE;
  454. X         }
  455. X      else
  456. X         {
  457. X         return FALSE;
  458. X         }
  459. X      }
  460. X
  461. X   /* the available key is not 0; thus a character is available
  462. X      as "r" */
  463. X
  464. X   kb_hold = r;
  465. X   tam_kready = TRUE;
  466. X   return TRUE;
  467. X   }
  468. X
  469. /*************************************************************************
  470. X
  471. X   FUNCTION:       kb_rx()
  472. X
  473. X   DESCRIPTION:    This function returns a single character from
  474. X           the keyboard.  If a character is not available
  475. X           it waits.  The function should be able to
  476. X           recognize any special keys, and return the
  477. X           appropriate Simple Software KB conventions
  478. X           designated for them.
  479. X
  480. X   INPUT:          none.
  481. X
  482. X   RETURNS:        The function returns the ASCII code for the
  483. X           key pressed, or the Simple Software KB convention
  484. X           (see kb.h) for a function or other special key.
  485. X
  486. **************************************************************************/
  487. X
  488. kb_rx()
  489. X   {
  490. #if WRITE_OUTPUT
  491. X   int r;
  492. X   
  493. X   r = att_rx();
  494. X   fprintf( outfile, "kb_rx(): 0x%02x\n", r );
  495. X   fflush( outfile );
  496. X   return r;
  497. #else
  498. X   return att_rx();
  499. #endif
  500. X   }
  501. X
  502. att_rx()
  503. X   {
  504. X
  505. X   while( tam_kready == FALSE )
  506. X      {
  507. X      att_rxstat();
  508. X      }
  509. X
  510. X   tam_kready = FALSE;
  511. X   return kb_hold;
  512. X   }
  513. X
  514. att_esc()
  515. X   {
  516. X   register int c;
  517. X   static char sequence[ 3 ];
  518. X
  519. #if WRITE_OUTPUT
  520. X   fprintf( outfile, "att_esc(): \n" );
  521. X   fflush( outfile );
  522. #endif
  523. X
  524. X   if ( kb_rxstat() == TRUE )
  525. X      {
  526. X      sequence[ 0 ] = kb_hold;
  527. X      sequence[ 1 ] = 0;
  528. X      tam_kready = 0;
  529. X      }
  530. X   else
  531. X      {
  532. X      return ESC;
  533. X      }
  534. X
  535. X   if ( kb_rxstat() == TRUE )
  536. X      {
  537. X      sequence[ 1 ] = kb_hold;
  538. X      sequence[ 2 ] = 0;
  539. X      tam_kready = FALSE;
  540. X      }
  541. X
  542. X   if ( strcmp( sequence, "[A" ) == 0 )
  543. X      {
  544. X      return KB_UP;
  545. X      }
  546. X   else if ( strcmp( sequence, "[B" ) == 0 )
  547. X      {
  548. X      return KB_DOWN;
  549. X      }
  550. X   else if ( strcmp( sequence, "[D" ) == 0 )
  551. X      {
  552. X      return KB_LEFT;
  553. X      }
  554. X   else if ( strcmp( sequence, "[C" ) == 0 )
  555. X      {
  556. X      return KB_RIGHT;
  557. X      }
  558. X   else if ( strcmp( sequence, "[?" ) == 0 )
  559. X      {
  560. X      tam_mready = TRUE;
  561. X      wreadmouse( w, &tam_mx, &tam_my, &tam_mb, &tam_mr );
  562. X      return 0;
  563. X      }
  564. X   else if ( strcmp( sequence, "Nh" ) == 0 )
  565. X      {
  566. X      return KB_P_DOWN;
  567. X      }
  568. X   else if ( strcmp( sequence, "Ng" ) == 0 )
  569. X      {
  570. X      return KB_P_UP;
  571. X      }
  572. X   else if ( strcmp( sequence, "Nf" ) == 0 )
  573. X      {
  574. X      return KB_DELETE;
  575. X      }
  576. X   else if ( strcmp( sequence, "Nj" ) == 0 )
  577. X      {
  578. X      return KB_INSERT;
  579. X      }
  580. /*
  581. X   else if ( strcmp( sequence, "Oc" ) == 0 )
  582. X      {
  583. X      return KB_HELP;
  584. X      }
  585. X   else if ( strcmp( sequence, "NK" ) == 0 )
  586. X      {
  587. X      return KB_W_LEFT;
  588. X      }
  589. X   else if ( strcmp( sequence, "NL" ) == 0 )
  590. X      {
  591. X      return KB_W_RIGHT;
  592. X      }
  593. */
  594. X   else if ( strcmp( sequence, "[H" ) == 0 )
  595. X      {
  596. X      return KB_HOME;
  597. X      }
  598. X   else if ( strcmp( sequence, "NM" ) == 0 )
  599. X      {
  600. X      return KB_HOME;
  601. X      }
  602. X   else if ( strcmp( sequence, "NN" ) == 0 )
  603. X      {
  604. X      return KB_END;
  605. X      }
  606. X   else if ( strcmp( sequence, "O" ) == 0 )
  607. X      {
  608. X      return KB_END;
  609. X      }
  610. /*
  611. X   else if ( strcmp( sequence, "Ne" ) == 0 )
  612. X      {
  613. X      return KB_D_WORD;
  614. X      }
  615. X   else if ( strcmp( sequence, "NE" ) == 0 )
  616. X      {
  617. X      return KB_D_LINE;
  618. X      }
  619. X   else if ( strcmp( sequence, "Ox" ) == 0 )
  620. X      {
  621. X      return KB_FIND;
  622. X      }
  623. X   else if ( strcmp( sequence, "Oy" ) == 0 )
  624. X      {
  625. X      return KB_REPLACE;
  626. X      }
  627. X   else if ( strcmp( sequence, "Ow" ) == 0 )
  628. X      {
  629. X      return KB_ABANDON;
  630. X      }
  631. X   else if ( strcmp( sequence, "Oo" ) == 0 )
  632. X      {
  633. X      return KB_SAVE;
  634. X      }
  635. X   else if ( strcmp( sequence, "Ok" ) == 0 )
  636. X      {
  637. X      return KB_QUIT;
  638. X      }
  639. */
  640. X   else
  641. X      {
  642. X      return 0;
  643. X      }
  644. X   }
  645. X
  646. att_seq( k )
  647. X   int k;
  648. X   {
  649. X   char *map;
  650. X
  651. X   map = kcodemap( k );
  652. X
  653. #if WRITE_OUTPUT
  654. X   fprintf( outfile, "att_seq(): char 0x%02x, map <%s>\n", k, map + 1 );
  655. X   fflush( outfile );
  656. #endif
  657. X
  658. X   if ( strncmp( map + 1, "[A", 2 ) == 0 )
  659. X      {
  660. X      return KB_UP;
  661. X      }
  662. X   else if ( strncmp( map + 1, "[B", 2 ) == 0 )
  663. X      {
  664. X      return KB_DOWN;
  665. X      }
  666. X   else if ( strncmp( map + 1, "[D", 2 ) == 0 )
  667. X      {
  668. X      return KB_LEFT;
  669. X      }
  670. X   else if ( strncmp( map + 1, "[C", 2 ) == 0 )
  671. X      {
  672. X      return KB_RIGHT;
  673. X      }
  674. X   else if ( strncmp( map + 1, "[?", 2 ) == 0 )
  675. X      {
  676. X      tam_mready = TRUE;
  677. X      wreadmouse( w, &tam_mx, &tam_my, &tam_mb, &tam_mr );
  678. X      return 0;
  679. X      }
  680. X   else if ( strncmp( map + 1, "Nh", 2 ) == 0 )
  681. X      {
  682. X      return KB_P_DOWN;
  683. X      }
  684. X   else if ( strncmp( map + 1, "Ng", 2 ) == 0 )
  685. X      {
  686. X      return KB_P_UP;
  687. X      }
  688. X   else if ( strncmp( map + 1, "Nf", 2 ) == 0 )
  689. X      {
  690. X      return KB_DELETE;
  691. X      }
  692. X   else if ( strncmp( map + 1, "Nj", 2 ) == 0 )
  693. X      {
  694. X      return KB_INSERT;
  695. X      }
  696. /*
  697. X   else if ( strncmp( map + 1, "Oc", 2 ) == 0 )
  698. X      {
  699. X      return KB_HELP;
  700. X      }
  701. X   else if ( strncmp( map + 1, "NK", 2 ) == 0 )
  702. X      {
  703. X      return KB_W_LEFT;
  704. X      }
  705. X   else if ( strncmp( map + 1, "NL", 2 ) == 0 )
  706. X      {
  707. X      return KB_W_RIGHT;
  708. X      }
  709. */
  710. X   else if ( strncmp( map + 1, "[H", 2 ) == 0 )
  711. X      {
  712. X      return KB_HOME;
  713. X      }
  714. X   else if ( strncmp( map + 1, "NM", 2 ) == 0 )
  715. X      {
  716. X      return KB_HOME;
  717. X      }
  718. X   else if ( strncmp( map + 1, "NN", 2 ) == 0 )
  719. X      {
  720. X      return KB_END;
  721. X      }
  722. X   else if ( strncmp( map + 1, "O", 2 ) == 0 )
  723. X      {
  724. X      return KB_END;
  725. X      }
  726. /*
  727. X   else if ( strncmp( map + 1, "Ne", 2 ) == 0 )
  728. X      {
  729. X      return KB_D_WORD;
  730. X      }
  731. X   else if ( strncmp( map + 1, "NE", 2 ) == 0 )
  732. X      {
  733. X      return KB_D_LINE;
  734. X      }
  735. X   else if ( strncmp( map + 1, "Ox", 2 ) == 0 )
  736. X      {
  737. X      return KB_FIND;
  738. X      }
  739. X   else if ( strncmp( map + 1, "Oy", 2 ) == 0 )
  740. X      {
  741. X      return KB_REPLACE;
  742. X      }
  743. X   else if ( strncmp( map + 1, "Ow", 2 ) == 0 )
  744. X      {
  745. X      return KB_ABANDON;
  746. X      }
  747. X   else if ( strncmp( map + 1, "Oo", 2 ) == 0 )
  748. X      {
  749. X      return KB_SAVE;
  750. X      }
  751. X   else if ( strncmp( map + 1, "Ok", 2 ) == 0 )        
  752. X      {
  753. X      return KB_QUIT;
  754. X      }
  755. */
  756. X   else
  757. X      {
  758. X      return 0;
  759. X      }
  760. X   }
  761. SHAR_EOF
  762. chmod 0644 io/kb/kb_7300.c ||
  763. echo 'restore of io/kb/kb_7300.c failed'
  764. Wc_c="`wc -c < 'io/kb/kb_7300.c'`"
  765. test 12842 -eq "$Wc_c" ||
  766.     echo 'io/kb/kb_7300.c: original size 12842, current size' "$Wc_c"
  767. rm -f _shar_wnt_.tmp
  768. fi
  769. # ============= io/kb/kb_cpm.c ==============
  770. if test -f 'io/kb/kb_cpm.c' -a X"$1" != X"-c"; then
  771.     echo 'x - skipping io/kb/kb_cpm.c (File already exists)'
  772.     rm -f _shar_wnt_.tmp
  773. else
  774. > _shar_wnt_.tmp
  775. echo 'x - extracting io/kb/kb_cpm.c (Text)'
  776. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_cpm.c' &&
  777. /*************************************************************************
  778. X
  779. X    kb_cpm.c    Keyboard (KB) Subroutines
  780. X               for Bywater Software
  781. X
  782. X            Implementation for CP/M computers
  783. X            (should work on all CP/M 2.2 machines).
  784. X            utilizing the Eco-C (tm) compiler 
  785. X
  786. X            Copyright (c) 1991, Ted A. Campbell
  787. X
  788. X            Bywater Software
  789. X            P. O. Box 4023 
  790. X            Duke Station 
  791. X            Durham, NC  27706
  792. X
  793. X            email: tcamp@hercules.acpub.duke.edu
  794. X
  795. X    WARNING:        THIS IS AN OUTMODED FILE, unused in most
  796. X            recent versions of this software, or not
  797. X            yet updated and verified to latest revision
  798. X            levels. Use at your own risk. It should not
  799. X            be distributed publicly.
  800. X
  801. X    Copyright and Permissions Information:
  802. X
  803. X    All U.S. and international copyrights are claimed by the
  804. X    author. The author grants permission to use this code
  805. X    and software based on it under the following conditions:
  806. X    (a) in general, the code and software based upon it may be 
  807. X    used by individuals and by non-profit organizations; (b) it
  808. X    may also be utilized by governmental agencies in any country,
  809. X    with the exception of military agencies; (c) the code and/or
  810. X    software based upon it may not be sold for a profit without
  811. X    an explicit and specific permission from the author, except
  812. X    that a minimal fee may be charged for media on which it is
  813. X    copied, and for copying and handling; (d) the code must be 
  814. X    distributed in the form in which it has been released by the
  815. X    author; and (e) the code and software based upon it may not 
  816. X    be used for illegal activities. 
  817. X
  818. **************************************************************************/
  819. X
  820. #include "kb.h"
  821. X
  822. #ifndef CR
  823. #define    CR    0x0d
  824. #define LF    0x0a
  825. #define    ESC    0x1b
  826. #endif
  827. X
  828. #define    DELBACK    0x08
  829. X
  830. int cpm_hold = 0;
  831. X
  832. /*************************************************************************
  833. X
  834. X    FUNCTION:       kb_init()
  835. X
  836. X    DESCRIPTION:    This function should perform any initialization
  837. X            necessary for the keyboard system.
  838. X
  839. X    INPUT:          none.
  840. X
  841. X    RETURNS:        none.
  842. X
  843. **************************************************************************/
  844. X
  845. kb_init()
  846. X    {
  847. X    }
  848. X
  849. /*************************************************************************
  850. X
  851. X    FUNCTION:       kb_deinit()
  852. X
  853. X    DESCRIPTION:    This function should perform any necessary
  854. X            deinitialization, that is, return the keyboard
  855. X            to its default state when a Simple Software
  856. X            program is to be exited.
  857. X
  858. X    INPUT:          none.
  859. X
  860. X    RETURNS:        none.
  861. X
  862. **************************************************************************/
  863. X
  864. kb_deinit()
  865. X    {
  866. X    }
  867. X
  868. /*************************************************************************
  869. X
  870. X    FUNCTION:       kb_cis()
  871. X
  872. X    DESCRIPTION:    This function determines whether a character is
  873. X            ready from the console.  The function is used
  874. X            especially in telecommunications programs,
  875. X            where it is necessary to poll the keyboard
  876. X            without locking up the program waiting for a
  877. X            response.
  878. X
  879. X    INPUT:          none.
  880. X
  881. X    RETURNS:        The function returns 0 if no character is
  882. X            available and 1 if a character is available.
  883. X
  884. **************************************************************************/
  885. X
  886. kb_cis()
  887. X    {
  888. X    register int c;
  889. X    if ( ( c = _bdos( 0x06, 0xff ) ) == 0 )
  890. X        {
  891. X        cpm_hold = 0;
  892. X        return 0;
  893. X        }
  894. X    else
  895. X        {
  896. X        cpm_hold = c;
  897. X        return 1;
  898. X        }
  899. X    }
  900. X
  901. /*************************************************************************
  902. X
  903. X    FUNCTION:       kb_ci()
  904. X
  905. X    DESCRIPTION:    This function returns a single character from
  906. X            the keyboard.  If a character is not available
  907. X            it waits.  The function should be able to
  908. X            recognize any special keys, and return the
  909. X            appropriate Simple Software KB conventions
  910. X            designated for them.
  911. X
  912. X    INPUT:          none.
  913. X
  914. X    RETURNS:        The function returns the ASCII code for the
  915. X            key pressed, or the Simple Software KB convention
  916. X            (see kb.h) for a function or other special key.
  917. X
  918. **************************************************************************/
  919. X
  920. kb_ci()
  921. X    {
  922. X    int c;
  923. X    if ( cpm_hold != 0 )
  924. X        {
  925. X        c = cpm_hold;
  926. X        cpm_hold = 0;
  927. X        return c;
  928. X        }
  929. X    while ( ( c = _bdos( 0x06, 0xff )) == 0 )
  930. X        ;
  931. X    if ( ( c >= 0x20 ) && ( c < 0x7f ) )
  932. X        {
  933. X        return c;
  934. X        }
  935. X    else
  936. X        {
  937. X        switch ( c )
  938. X            {
  939. X            case 0x05:
  940. X                return KB_UP;
  941. X                break;
  942. X            case 0x18:
  943. X                return KB_DOWN;
  944. X                break;
  945. X            case 0x13:
  946. X                return KB_LEFT;
  947. X                break;
  948. X            case 0x04:
  949. X                return KB_RIGHT;
  950. X                break;
  951. X            case 0x12:
  952. X                return KB_P_UP;
  953. X                break;
  954. X            case 0x03:
  955. X                return KB_P_DOWN;
  956. X                break;
  957. X            case 0x16:
  958. X                return KB_INSERT;
  959. X                break;
  960. X            case 0x07:
  961. X                return KB_DELETE;
  962. X                break;
  963. X            case 0x01:
  964. X                return KB_FK3;
  965. X                break;
  966. X            case 0x06:
  967. X                return KB_FK4;
  968. X                break;
  969. X            case 0x19:
  970. X                return KB_FK5;
  971. X                break;
  972. X            case 0x14:
  973. X                return KB_FK6;
  974. X                break;
  975. X            case 0x0b:
  976. X            case ESC:
  977. X                return cpm_esc();
  978. X                break;
  979. X            case CR:
  980. X            case LF:
  981. X            case DELBACK:
  982. X                return c;
  983. X                break;
  984. X            default:
  985. X                return 0;
  986. X                break;
  987. X            }
  988. X        }
  989. X    }
  990. X
  991. /*************************************************************************
  992. X
  993. X    FUNCTION:       cpm_esc()
  994. X
  995. X    DESCRIPTION:    This function handles escape sequences from the
  996. X            keyboard.  It calls the kb_emenu() function
  997. X            (defined by the application program), accepts
  998. X            a new command letter, then replace the menu
  999. X            with kb_dmenu (the default menu defined by
  1000. X            the application program).
  1001. X
  1002. X    INPUT:          none.
  1003. X
  1004. X    RETURNS:        The function returns the Simple Software
  1005. X            convention for a special key sequence (see
  1006. X            kb.h), or 0.
  1007. X
  1008. **************************************************************************/
  1009. X
  1010. cpm_esc()
  1011. X    {
  1012. X    register int c;
  1013. X    while ( ( c = _bdos( 0x06, 0xff ) ) == 0 )
  1014. X        ;
  1015. X    switch ( c )
  1016. X        {
  1017. X        case '1':
  1018. X            return KB_FK1;
  1019. X            break;
  1020. X        case '2':
  1021. X            return KB_FK2;
  1022. X            break;
  1023. X        case '3':
  1024. X            return KB_FK3;
  1025. X            break;
  1026. X        case '4':
  1027. X            return KB_FK4;
  1028. X            break;
  1029. X        case '5':
  1030. X            return KB_FK5;
  1031. X            break;
  1032. X        case '6':
  1033. X            return KB_FK6;
  1034. X            break;
  1035. X        case '7':
  1036. X            return KB_FK7;
  1037. X            break;
  1038. X        case '8':
  1039. X        case 'Q':
  1040. X        case 'q':
  1041. X            return KB_FK8;
  1042. X            break;
  1043. X        case '9':
  1044. X        case 'S':
  1045. X        case 's':
  1046. X            return KB_FK9;
  1047. X            break;
  1048. X        case '0':
  1049. X        case 'D':
  1050. X        case 'd':
  1051. X            return KB_FK10;
  1052. X            break;
  1053. X        default:
  1054. X            return 0;
  1055. X            break;
  1056. X        }
  1057. X    }
  1058. X
  1059. SHAR_EOF
  1060. chmod 0644 io/kb/kb_cpm.c ||
  1061. echo 'restore of io/kb/kb_cpm.c failed'
  1062. Wc_c="`wc -c < 'io/kb/kb_cpm.c'`"
  1063. test 6035 -eq "$Wc_c" ||
  1064.     echo 'io/kb/kb_cpm.c: original size 6035, current size' "$Wc_c"
  1065. rm -f _shar_wnt_.tmp
  1066. fi
  1067. # ============= io/kb/kb_ibmpc.c ==============
  1068. if test -f 'io/kb/kb_ibmpc.c' -a X"$1" != X"-c"; then
  1069.     echo 'x - skipping io/kb/kb_ibmpc.c (File already exists)'
  1070.     rm -f _shar_wnt_.tmp
  1071. else
  1072. > _shar_wnt_.tmp
  1073. echo 'x - extracting io/kb/kb_ibmpc.c (Text)'
  1074. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_ibmpc.c' &&
  1075. /*************************************************************************
  1076. X
  1077. X    kb_ibmpc.c    Keyboard (KB) Subroutines
  1078. X            for Bywater Software
  1079. X
  1080. X            Implementation for the IBM PC and Compatibles
  1081. X            utilizing BIOS keyboard routines.
  1082. X
  1083. X            This implementation contains code specific
  1084. X            to the Microsoft Quick C (tm) compiler.
  1085. X
  1086. X            Copyright (c) 1991, Ted A. Campbell
  1087. X
  1088. X            Bywater Software
  1089. X            P. O. Box 4023 
  1090. X            Duke Station 
  1091. X            Durham, NC  27706
  1092. X
  1093. X            email: tcamp@hercules.acpub.duke.edu
  1094. X
  1095. X    Copyright and Permissions Information:
  1096. X
  1097. X    All U.S. and international copyrights are claimed by the
  1098. X    author. The author grants permission to use this code
  1099. X    and software based on it under the following conditions:
  1100. X    (a) in general, the code and software based upon it may be 
  1101. X    used by individuals and by non-profit organizations; (b) it
  1102. X    may also be utilized by governmental agencies in any country,
  1103. X    with the exception of military agencies; (c) the code and/or
  1104. X    software based upon it may not be sold for a profit without
  1105. X    an explicit and specific permission from the author, except
  1106. X    that a minimal fee may be charged for media on which it is
  1107. X    copied, and for copying and handling; (d) the code must be 
  1108. X    distributed in the form in which it has been released by the
  1109. X    author; and (e) the code and software based upon it may not 
  1110. X    be used for illegal activities. 
  1111. X
  1112. **************************************************************************/
  1113. X
  1114. #include "stdio.h"
  1115. #include "kb.h"
  1116. #include "bios.h"
  1117. X
  1118. #ifndef TRUE
  1119. #define TRUE    1
  1120. #define FALSE   0
  1121. #endif
  1122. X
  1123. #ifndef CR
  1124. #define CR      0x0d
  1125. #endif
  1126. X
  1127. /*************************************************************************
  1128. X
  1129. X    FUNCTION:       kb_init()
  1130. X
  1131. X    DESCRIPTION:    This function should perform any initialization
  1132. X            necessary for the keyboard system.
  1133. X
  1134. X    INPUT:          none.
  1135. X
  1136. X    RETURNS:        none.
  1137. X
  1138. **************************************************************************/
  1139. X
  1140. kb_init()
  1141. X    {
  1142. X    }
  1143. X
  1144. /*************************************************************************
  1145. X
  1146. X    FUNCTION:       kb_deinit()
  1147. X
  1148. X    DESCRIPTION:    This function should perform any necessary
  1149. X            deinitialization, that is, return the keyboard
  1150. X            to its default state when a Simple Software
  1151. X            program is to be exited.
  1152. X
  1153. X    INPUT:          none.
  1154. X
  1155. X    RETURNS:        none.
  1156. X
  1157. **************************************************************************/
  1158. X
  1159. kb_deinit()
  1160. X    {
  1161. X    }
  1162. X
  1163. /*************************************************************************
  1164. X
  1165. X    FUNCTION:       kb_rxstat()
  1166. X
  1167. X    DESCRIPTION:    This function determines whether a character is
  1168. X            ready from the console.  The function is used
  1169. X            especially in telecommunications programs,
  1170. X            where it is necessary to poll the keyboard
  1171. X            without locking up the program waiting for a
  1172. X            response.
  1173. X
  1174. X    INPUT:          none.
  1175. X
  1176. X    RETURNS:        The function returns 0 if no character is
  1177. X            available and 1 if a character is available.
  1178. X
  1179. **************************************************************************/
  1180. X
  1181. kb_rxstat()
  1182. X    {
  1183. X    if ( _bios_keybrd( _KEYBRD_READY ) == 0 )
  1184. X        {
  1185. X        return FALSE;
  1186. X        }
  1187. X    else
  1188. X        {
  1189. X        return TRUE;
  1190. X        }
  1191. X    }
  1192. X
  1193. /*************************************************************************
  1194. X
  1195. X    FUNCTION:       kb_rx()
  1196. X
  1197. X    DESCRIPTION:    This function returns a single character from
  1198. X            the keyboard.  If a character is not available
  1199. X            it waits.  The function should be able to
  1200. X            recognize any special keys, and return the
  1201. X            appropriate Simple Software KB conventions
  1202. X            designated for them.
  1203. X
  1204. X    INPUT:          none.
  1205. X
  1206. X    RETURNS:        The function returns the ASCII code for the
  1207. X            key pressed, or the Simple Software KB convention
  1208. X            (see kb.h) for a function or other special key.
  1209. X
  1210. **************************************************************************/
  1211. X
  1212. kb_rx()
  1213. X     {
  1214. X     unsigned int ax;
  1215. X     unsigned char ah, al;
  1216. X
  1217. X     while( kb_rxstat() == 0 )
  1218. X      {
  1219. X      }
  1220. X
  1221. X     ax = _bios_keybrd( _KEYBRD_READ );
  1222. X     ah = ax / 256;
  1223. X     al = ax % 256;
  1224. X
  1225. X     if ( al != 0 )
  1226. X      {
  1227. X      return al;
  1228. X      }
  1229. X
  1230. X     else
  1231. X      {
  1232. X      switch( ah )
  1233. X        {
  1234. X        case 0x50:
  1235. X            return KB_DOWN;
  1236. X            break;
  1237. X        case 0x48:
  1238. X            return KB_UP;
  1239. X            break;
  1240. X        case 0x4b:
  1241. X            return KB_LEFT;
  1242. X            break;
  1243. X        case 0x4d:
  1244. X            return KB_RIGHT;
  1245. X            break;
  1246. X        case 0x49:
  1247. X            return KB_P_UP;
  1248. X            break;
  1249. X        case 0x51:
  1250. X            return KB_P_DOWN;
  1251. X            break;
  1252. X        case 0x53:
  1253. X            return KB_DELETE;
  1254. X            break;
  1255. X        case 0x52:
  1256. X            return KB_INSERT;
  1257. X            break;
  1258. X        case 0x4f:
  1259. X            return KB_END;
  1260. X            break;
  1261. X        case 0x47:
  1262. X            return KB_HOME;
  1263. X            break;
  1264. X        case 0x3b:                      /* FK 1         */
  1265. X        case 0x54:
  1266. X            return KB_FK1;
  1267. X            break;
  1268. X        case 0x3c:                      /* FK 2         */
  1269. X        case 0x55:
  1270. X            return KB_FK2;
  1271. X            break;
  1272. X        case 0x3d:                      /* FK 3         */
  1273. X        case 0x56:
  1274. X            return KB_FK3;
  1275. X            break;
  1276. X        case 0x3e:                      /* FK 4         */
  1277. X        case 0x57:
  1278. X            return KB_FK4;
  1279. X            break;
  1280. X        case 0x3f:                      /* FK 5         */
  1281. X        case 0x58:
  1282. X            return KB_FK5;
  1283. X            break;
  1284. X        case 0x40:                      /* FK 6         */
  1285. X        case 0x59:
  1286. X            return KB_FK6;
  1287. X            break;
  1288. X        case 0x41:                      /* FK 7         */
  1289. X        case 0x5a:
  1290. X            return KB_FK7;
  1291. X            break;
  1292. X        case 0x42:                      /* FK 8         */
  1293. X        case 0x5b:
  1294. X            return KB_FK8;
  1295. X            break;
  1296. X        case 0x43:                      /* FK 9         */
  1297. X        case 0x5c:
  1298. X            return KB_FK9;
  1299. X            break;
  1300. X        case 0x44:                      /* FK 10        */
  1301. X        case 0x5d:
  1302. X            return KB_FK0;
  1303. X            break;
  1304. X        case 0x10:
  1305. X            return KB_ALT + 'Q';
  1306. X            break;
  1307. X        case 0x11:
  1308. X            return KB_ALT + 'W';
  1309. X            break;
  1310. X        case 0x12:
  1311. X            return KB_ALT + 'E';
  1312. X            break;
  1313. X        case 0x13:
  1314. X            return KB_ALT + 'R';
  1315. X            break;
  1316. X        case 0x14:
  1317. X            return KB_ALT + 'T';
  1318. X            break;
  1319. X        case 0x15:
  1320. X            return KB_ALT + 'Y';
  1321. X            break;
  1322. X        case 0x16:
  1323. X            return KB_ALT + 'U';
  1324. X            break;
  1325. X        case 0x17:
  1326. X            return KB_ALT + 'I';
  1327. X            break;
  1328. X        case 0x18:
  1329. X            return KB_ALT + 'O';
  1330. X            break;
  1331. X        case 0x19:
  1332. X            return KB_ALT + 'P';
  1333. X            break;
  1334. X        case 0x1E:
  1335. X            return KB_ALT + 'A';
  1336. X            break;
  1337. X        case 0x1F:
  1338. X            return KB_ALT + 'S';
  1339. X            break;
  1340. X        case 0x20:
  1341. X            return KB_ALT + 'D';
  1342. X            break;
  1343. X        case 0x21:
  1344. X            return KB_ALT + 'F';
  1345. X            break;
  1346. X        case 0x22:
  1347. X            return KB_ALT + 'G';
  1348. X            break;
  1349. X        case 0x23:
  1350. X            return KB_ALT + 'H';
  1351. X            break;
  1352. X        case 0x24:
  1353. X            return KB_ALT + 'J';
  1354. X            break;
  1355. X        case 0x25:
  1356. X            return KB_ALT + 'K';
  1357. X            break;
  1358. X        case 0x26:
  1359. X            return KB_ALT + 'L';
  1360. X            break;
  1361. X        case 0x2C:
  1362. X            return KB_ALT + 'Z';
  1363. X            break;
  1364. X        case 0x2D:
  1365. X            return KB_ALT + 'X';
  1366. X            break;
  1367. X        case 0x2E:
  1368. X            return KB_ALT + 'C';
  1369. X            break;
  1370. X        case 0x2F:
  1371. X            return KB_ALT + 'V';
  1372. X            break;
  1373. X        case 0x30:
  1374. X            return KB_ALT + 'B';
  1375. X            break;
  1376. X        case 0x31:
  1377. X            return KB_ALT + 'N';
  1378. X            break;
  1379. X        case 0x32:
  1380. X            return KB_ALT + 'M';
  1381. X            break;
  1382. X        default:
  1383. X            return 0;
  1384. X            break;
  1385. X        }
  1386. X      }
  1387. X     }
  1388. X
  1389. SHAR_EOF
  1390. chmod 0644 io/kb/kb_ibmpc.c ||
  1391. echo 'restore of io/kb/kb_ibmpc.c failed'
  1392. Wc_c="`wc -c < 'io/kb/kb_ibmpc.c'`"
  1393. test 6597 -eq "$Wc_c" ||
  1394.     echo 'io/kb/kb_ibmpc.c: original size 6597, current size' "$Wc_c"
  1395. rm -f _shar_wnt_.tmp
  1396. fi
  1397. # ============= io/kb/kb_spec.c ==============
  1398. if test -f 'io/kb/kb_spec.c' -a X"$1" != X"-c"; then
  1399.     echo 'x - skipping io/kb/kb_spec.c (File already exists)'
  1400.     rm -f _shar_wnt_.tmp
  1401. else
  1402. > _shar_wnt_.tmp
  1403. echo 'x - extracting io/kb/kb_spec.c (Text)'
  1404. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_spec.c' &&
  1405. /*************************************************************************
  1406. X
  1407. X    kb_spec.c    Keyboard (KB) Subroutines
  1408. X            for Bywater Software
  1409. X
  1410. X            Specification for developing new implementations.
  1411. X
  1412. X            Copyright (c) 1991, Ted A. Campbell
  1413. X
  1414. X            Bywater Software
  1415. X            P. O. Box 4023 
  1416. X            Duke Station 
  1417. X            Durham, NC  27706
  1418. X
  1419. X            email: tcamp@hercules.acpub.duke.edu
  1420. X
  1421. X    Copyright and Permissions Information:
  1422. X
  1423. X    All U.S. and international copyrights are claimed by the
  1424. X    author. The author grants permission to use this code
  1425. X    and software based on it under the following conditions:
  1426. X    (a) in general, the code and software based upon it may be 
  1427. X    used by individuals and by non-profit organizations; (b) it
  1428. X    may also be utilized by governmental agencies in any country,
  1429. X    with the exception of military agencies; (c) the code and/or
  1430. X    software based upon it may not be sold for a profit without
  1431. X    an explicit and specific permission from the author, except
  1432. X    that a minimal fee may be charged for media on which it is
  1433. X    copied, and for copying and handling; (d) the code must be 
  1434. X    distributed in the form in which it has been released by the
  1435. X    author; and (e) the code and software based upon it may not 
  1436. X    be used for illegal activities. 
  1437. X
  1438. **************************************************************************/
  1439. X
  1440. #include "kb.h"
  1441. X
  1442. /*************************************************************************
  1443. X
  1444. X    FUNCTION:       kb_init()
  1445. X
  1446. X    DESCRIPTION:    This function should perform any initialization
  1447. X            necessary for the keyboard system.
  1448. X
  1449. X    INPUT:          none.
  1450. X
  1451. X    RETURNS:        none.
  1452. X
  1453. **************************************************************************/
  1454. X
  1455. kb_init()
  1456. X    {
  1457. X    }
  1458. X
  1459. /*************************************************************************
  1460. X
  1461. X    FUNCTION:       kb_deinit()
  1462. X
  1463. X    DESCRIPTION:    This function should perform any necessary
  1464. X            deinitialization, that is, return the keyboard
  1465. X            to its default state when a Simple Software
  1466. X            program is to be exited.
  1467. X
  1468. X    INPUT:          none.
  1469. X
  1470. X    RETURNS:        none.
  1471. X
  1472. **************************************************************************/
  1473. X
  1474. kb_deinit()
  1475. X    {
  1476. X    }
  1477. X
  1478. /*************************************************************************
  1479. X
  1480. X    FUNCTION:       kb_rxstat()
  1481. X
  1482. X    DESCRIPTION:    This function determines whether a character is
  1483. X            ready from the console.  The function is used
  1484. X            especially in telecommunications programs,
  1485. X            where it is necessary to poll the keyboard
  1486. X            without locking up the program waiting for a
  1487. X            response.
  1488. X
  1489. X    INPUT:          none.
  1490. X
  1491. X    RETURNS:        The function returns FALSE if no character is
  1492. X            available and TRUE if a character is available.
  1493. X
  1494. **************************************************************************/
  1495. X
  1496. kb_rxstat()
  1497. X     {
  1498. X     }
  1499. X
  1500. /*************************************************************************
  1501. X
  1502. X    FUNCTION:       kb_rx()
  1503. X
  1504. X    DESCRIPTION:    This function returns a single character from
  1505. X            the keyboard.  If a character is not available
  1506. X            it waits.  The function should be able to
  1507. X            recognize any special keys, and return the
  1508. X            appropriate KB conventions designated for
  1509. X            them in "kb.h".
  1510. X
  1511. X    INPUT:          none.
  1512. X
  1513. X    RETURNS:        The function returns the ASCII code for the
  1514. X            key pressed, or the Simple Software KB convention
  1515. X            (see kb.h) for a function or other special key.
  1516. X
  1517. **************************************************************************/
  1518. X
  1519. kb_rx()
  1520. X     {
  1521. X     }
  1522. X
  1523. SHAR_EOF
  1524. chmod 0644 io/kb/kb_spec.c ||
  1525. echo 'restore of io/kb/kb_spec.c failed'
  1526. Wc_c="`wc -c < 'io/kb/kb_spec.c'`"
  1527. test 3370 -eq "$Wc_c" ||
  1528.     echo 'io/kb/kb_spec.c: original size 3370, current size' "$Wc_c"
  1529. rm -f _shar_wnt_.tmp
  1530. fi
  1531. # ============= io/kb/kb_sysv.c ==============
  1532. if test -f 'io/kb/kb_sysv.c' -a X"$1" != X"-c"; then
  1533.     echo 'x - skipping io/kb/kb_sysv.c (File already exists)'
  1534.     rm -f _shar_wnt_.tmp
  1535. else
  1536. > _shar_wnt_.tmp
  1537. echo 'x - extracting io/kb/kb_sysv.c (Text)'
  1538. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_sysv.c' &&
  1539. /*************************************************************************
  1540. X
  1541. X    kb_sysv.c    Keyboard (KB) Subroutines
  1542. X            for Bywater Software
  1543. X
  1544. X            Implementation for Unix SYSTEM V
  1545. X
  1546. X            Copyright (c) 1991, Ted A. Campbell
  1547. X
  1548. X            Bywater Software
  1549. X            P. O. Box 4023 
  1550. X            Duke Station 
  1551. X            Durham, NC  27706
  1552. X
  1553. X            email: tcamp@hercules.acpub.duke.edu
  1554. X
  1555. X    Copyright and Permissions Information:
  1556. X
  1557. X    All U.S. and international copyrights are claimed by the
  1558. X    author. The author grants permission to use this code
  1559. X    and software based on it under the following conditions:
  1560. X    (a) in general, the code and software based upon it may be 
  1561. X    used by individuals and by non-profit organizations; (b) it
  1562. X    may also be utilized by governmental agencies in any country,
  1563. X    with the exception of military agencies; (c) the code and/or
  1564. X    software based upon it may not be sold for a profit without
  1565. X    an explicit and specific permission from the author, except
  1566. X    that a minimal fee may be charged for media on which it is
  1567. X    copied, and for copying and handling; (d) the code must be 
  1568. X    distributed in the form in which it has been released by the
  1569. X    author; and (e) the code and software based upon it may not 
  1570. X    be used for illegal activities. 
  1571. X
  1572. **************************************************************************/
  1573. X
  1574. #include "stdio.h"
  1575. #include "fcntl.h"
  1576. #include "signal.h"
  1577. #include "sys/stat.h"
  1578. #include "termio.h"
  1579. X
  1580. #ifndef    TRUE
  1581. #define    TRUE    1
  1582. #define    FALSE    0
  1583. #endif
  1584. X
  1585. struct termio old_ttystruct;
  1586. int    kb_tty;            /* fd for new terminal file */
  1587. X
  1588. #ifdef    KB_TEST
  1589. main()
  1590. X    {
  1591. X    register int s;
  1592. X    static char tbuf[ 3 ];
  1593. X
  1594. X    kb_init();
  1595. X
  1596. X    tbuf[ 0 ] = 0;
  1597. X    while ( tbuf[ 0 ] != 0x1b )
  1598. X        {
  1599. X        s = read( kb_tty, tbuf, 1 );
  1600. X        printf( "The read() function returned %d \n", s );
  1601. X        if ( s > 0 )
  1602. X            {
  1603. X            printf( "The key is <%c> \n", tbuf[ 0 ] );
  1604. X            }
  1605. X        }
  1606. X
  1607. X    kb_deinit();
  1608. X    }
  1609. #endif
  1610. X
  1611. /*************************************************************************
  1612. X
  1613. X    FUNCTION:       kb_init()
  1614. X
  1615. X    DESCRIPTION:    This function should perform any initialization
  1616. X            necessary for the keyboard system.
  1617. X
  1618. X    INPUT:          none.
  1619. X
  1620. X    RETURNS:        none.
  1621. X
  1622. **************************************************************************/
  1623. X
  1624. kb_init()
  1625. X    {
  1626. X    struct termio new_ttystruct;
  1627. X
  1628. X    if ( ioctl( 0, TCGETA, &old_ttystruct ) < 0 )  
  1629. X        {
  1630. X        fprintf( stderr, "Failed to get old tty parameters. \n" );
  1631. X        }
  1632. X
  1633. X    if ( ( kb_tty = open( "/dev/tty", O_NDELAY)) == -1 )
  1634. X        {
  1635. X        fprintf( stderr, "Failed to open /dev/tty \n" );
  1636. X        }
  1637. #ifdef    DEBUG
  1638. X    else
  1639. X        {
  1640. X        fprintf( stderr, "/dev/tty returns %d \n", kb_tty );
  1641. X        }
  1642. #endif
  1643. X
  1644. X    if ( ioctl( kb_tty, TCGETA, &new_ttystruct ) < 0 )  
  1645. X        {
  1646. X        fprintf( stderr, "Failed to get new tty parameters. \n" );
  1647. X        }
  1648. X
  1649. X    new_ttystruct.c_cc[4] = 0;        /* minimum characters */
  1650. X    new_ttystruct.c_cc[5] = 0;        /* maximum time */
  1651. X    new_ttystruct.c_iflag = 0;
  1652. X    new_ttystruct.c_lflag = ISIG;
  1653. X    new_ttystruct.c_cflag &= ~CSIZE;
  1654. X    new_ttystruct.c_cflag |= CS8;
  1655. X    new_ttystruct.c_cflag &= ~PARENB;
  1656. X    if ( ioctl( kb_tty, TCSETA, &new_ttystruct ) < 0 )  
  1657. X        {
  1658. X        fprintf( stderr, "Failed to set new tty parameters. \n" );
  1659. X        }
  1660. X
  1661. X    }
  1662. X
  1663. X
  1664. X
  1665. /*************************************************************************
  1666. X
  1667. X    FUNCTION:       kb_deinit()
  1668. X
  1669. X    DESCRIPTION:    This function should perform any necessary
  1670. X            deinitialization, that is, return the keyboard
  1671. X            to its default state when a Simple Software
  1672. X            program is to be exited.
  1673. X
  1674. X    INPUT:          none.
  1675. X
  1676. X    RETURNS:        none.
  1677. X
  1678. **************************************************************************/
  1679. X
  1680. kb_deinit()
  1681. X    {
  1682. X    if ( ioctl( 0, TCSETA, &old_ttystruct ) < 0 )
  1683. X        {
  1684. X        fprintf( stderr, "Failed to restore old tty parameters. \n");
  1685. X        }
  1686. X    }
  1687. X
  1688. /*************************************************************************
  1689. X
  1690. X    FUNCTION:       kb_rxstat()
  1691. X
  1692. X    DESCRIPTION:    This function determines whether a character is
  1693. X            ready from the console.  The function is used
  1694. X            especially in telecommunications programs,
  1695. X            where it is necessary to poll the keyboard
  1696. X            without locking up the program waiting for a
  1697. X            response.
  1698. X
  1699. X    INPUT:          none.
  1700. X
  1701. X    RETURNS:        The function returns 0 if no character is
  1702. X            available and 1 if a character is available.
  1703. X
  1704. **************************************************************************/
  1705. X
  1706. int kb_available = 0;
  1707. int kb_hold = 0;
  1708. X
  1709. kb_rxstat()
  1710. X    {
  1711. X    register int s;
  1712. X    static char tbuf[3];
  1713. X
  1714. X    if ( kb_available == TRUE )
  1715. X        {
  1716. X        return TRUE;
  1717. X        }
  1718. X    else
  1719. X        {
  1720. X        s = read( kb_tty, tbuf, 1 );
  1721. X        if ( s == FALSE )
  1722. X            {
  1723. X            kb_available = FALSE;
  1724. X            return FALSE;
  1725. X            }
  1726. X        else
  1727. X            {
  1728. X            kb_hold = tbuf[ 0 ];
  1729. X            kb_available = TRUE;
  1730. X            return TRUE;
  1731. X            }
  1732. X        }
  1733. X    }
  1734. X
  1735. /*************************************************************************
  1736. X
  1737. X    FUNCTION:       kb_rx()
  1738. X
  1739. X    DESCRIPTION:    This function returns a single character from
  1740. X            the keyboard.  If a character is not available
  1741. X            it waits.  The function should be able to
  1742. X            recognize any special keys, and return the
  1743. X            appropriate Simple Software KB conventions
  1744. X            designated for them.
  1745. X
  1746. X    INPUT:          none.
  1747. X
  1748. X    RETURNS:        The function returns the ASCII code for the
  1749. X            key pressed, or the Simple Software KB convention
  1750. X            (see kb.h) for a function or other special key.
  1751. X
  1752. **************************************************************************/
  1753. X
  1754. kb_rx()
  1755. X    {
  1756. X
  1757. X    while( kb_rxstat() == FALSE )
  1758. X        {
  1759. X        ;
  1760. X        }
  1761. X
  1762. X    kb_available = FALSE;
  1763. X    return kb_hold;
  1764. X    }
  1765. X
  1766. X
  1767. SHAR_EOF
  1768. chmod 0644 io/kb/kb_sysv.c ||
  1769. echo 'restore of io/kb/kb_sysv.c failed'
  1770. Wc_c="`wc -c < 'io/kb/kb_sysv.c'`"
  1771. test 5260 -eq "$Wc_c" ||
  1772.     echo 'io/kb/kb_sysv.c: original size 5260, current size' "$Wc_c"
  1773. rm -f _shar_wnt_.tmp
  1774. fi
  1775. # ============= io/kb/kb_test.c ==============
  1776. if test -f 'io/kb/kb_test.c' -a X"$1" != X"-c"; then
  1777.     echo 'x - skipping io/kb/kb_test.c (File already exists)'
  1778.     rm -f _shar_wnt_.tmp
  1779. else
  1780. > _shar_wnt_.tmp
  1781. echo 'x - extracting io/kb/kb_test.c (Text)'
  1782. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_test.c' &&
  1783. /*************************************************************************
  1784. X
  1785. X    kb_test.c    Test Keyboard (KB) Subroutines
  1786. X            for Bywater Software
  1787. X
  1788. X            Copyright (c) 1991, Ted A. Campbell
  1789. X
  1790. X            Bywater Software
  1791. X            P. O. Box 4023 
  1792. X            Duke Station 
  1793. X            Durham, NC  27706
  1794. X
  1795. X            email: tcamp@hercules.acpub.duke.edu
  1796. X
  1797. X    Copyright and Permissions Information:
  1798. X
  1799. X    All U.S. and international copyrights are claimed by the
  1800. X    author. The author grants permission to use this code
  1801. X    and software based on it under the following conditions:
  1802. X    (a) in general, the code and software based upon it may be 
  1803. X    used by individuals and by non-profit organizations; (b) it
  1804. X    may also be utilized by governmental agencies in any country,
  1805. X    with the exception of military agencies; (c) the code and/or
  1806. X    software based upon it may not be sold for a profit without
  1807. X    an explicit and specific permission from the author, except
  1808. X    that a minimal fee may be charged for media on which it is
  1809. X    copied, and for copying and handling; (d) the code must be 
  1810. X    distributed in the form in which it has been released by the
  1811. X    author; and (e) the code and software based upon it may not 
  1812. X    be used for illegal activities. 
  1813. X
  1814. **************************************************************************/
  1815. X
  1816. #include "stdio.h"
  1817. #include "kb.h"
  1818. X
  1819. #define ESC     0x1b
  1820. X
  1821. main()
  1822. X    {
  1823. X    unsigned c;
  1824. X    kb_init();
  1825. X
  1826. X    printf( "Test of KB functions. \n" );
  1827. X    printf( "Press ESCAPE to exit. \n" );
  1828. X
  1829. X    c = 0;
  1830. X    while( c != ESC )
  1831. X        {
  1832. X        c = kb_rx();
  1833. X        switch ( c )
  1834. X            {
  1835. X            case KB_LEFT:
  1836. X                printf( "Key:\tLEFT \n" );
  1837. X                break;
  1838. X            case KB_RIGHT:
  1839. X                printf( "Key:\tRIGHT \n" );
  1840. X                break;
  1841. X            case KB_UP:
  1842. X                printf( "Key:\tUP \n" );
  1843. X                break;
  1844. X            case KB_DOWN:
  1845. X                printf( "Key:\tDOWN \n" );
  1846. X                break;
  1847. X            case KB_HOME:
  1848. X                printf( "Key:\tHOME \n" );
  1849. X                break;
  1850. X            case KB_END:
  1851. X                printf( "Key:\tEND \n" );
  1852. X                break;
  1853. X            case KB_P_UP:
  1854. X                printf( "Key:\tPAGE UP \n" );
  1855. X                break;
  1856. X            case KB_P_DOWN:
  1857. X                printf( "Key:\tPAGE DOWN \n" );
  1858. X                break;
  1859. X            case KB_INSERT:
  1860. X                printf( "Key:\tINSERT \n" );
  1861. X                break;
  1862. X            case KB_DELETE:
  1863. X                printf( "Key:\tDELETE \n" );
  1864. X                break;
  1865. X            case KB_FK0:
  1866. X                printf( "Key:\tFK 10 \n" );
  1867. X                break;
  1868. X            case KB_FK1:
  1869. X                printf( "Key:\tFK 1 \n" );
  1870. X                break;
  1871. X            case KB_FK2:
  1872. X                printf( "Key:\tFK 2 \n" );
  1873. X                break;
  1874. X            case KB_FK3:
  1875. X                printf( "Key:\tFK 3 \n" );
  1876. X                break;
  1877. X            case KB_FK4:
  1878. X                printf( "Key:\tFK 4 \n" );
  1879. X                break;
  1880. X            case KB_FK5:
  1881. X                printf( "Key:\tFK 5 \n" );
  1882. X                break;
  1883. X            case KB_FK6:
  1884. X                printf( "Key:\tFK 6 \n" );
  1885. X                break;
  1886. X            case KB_FK7:
  1887. X                printf( "Key:\tFK 7 \n" );
  1888. X                break;
  1889. X            case KB_FK8:
  1890. X                printf( "Key:\tFK 8 \n" );
  1891. X                break;
  1892. X            case KB_FK9:
  1893. X                printf( "Key:\tFK 9 \n" );
  1894. X                break;
  1895. X            default:
  1896. X                if ( ( c & KB_ALT ) == 0 )
  1897. X                    {
  1898. X                    printf( "Key:\t%c \n", c );
  1899. X                    }
  1900. X                else
  1901. X                    {
  1902. X                    printf( "Key:\tALT-%c \n", ( c & 127 ));
  1903. X                    }
  1904. X                break;
  1905. X            }
  1906. X        }
  1907. X    kb_deinit();
  1908. X    }
  1909. X
  1910. SHAR_EOF
  1911. chmod 0644 io/kb/kb_test.c ||
  1912. echo 'restore of io/kb/kb_test.c failed'
  1913. Wc_c="`wc -c < 'io/kb/kb_test.c'`"
  1914. test 2861 -eq "$Wc_c" ||
  1915.     echo 'io/kb/kb_test.c: original size 2861, current size' "$Wc_c"
  1916. rm -f _shar_wnt_.tmp
  1917. fi
  1918. # ============= io/kb/kb_x.c ==============
  1919. if test -f 'io/kb/kb_x.c' -a X"$1" != X"-c"; then
  1920.     echo 'x - skipping io/kb/kb_x.c (File already exists)'
  1921.     rm -f _shar_wnt_.tmp
  1922. else
  1923. > _shar_wnt_.tmp
  1924. echo 'x - extracting io/kb/kb_x.c (Text)'
  1925. sed 's/^X//' << 'SHAR_EOF' > 'io/kb/kb_x.c' &&
  1926. /*************************************************************************
  1927. X
  1928. X    kb_x.c          Keyboard (KB) Subroutines
  1929. X            for Bywater Software.
  1930. X
  1931. X            Implementation for X Windows System
  1932. X            Depends on gr_x.c
  1933. X
  1934. X            Copyright (c) 1991, Ted A. Campbell
  1935. X
  1936. X            Bywater Software
  1937. X            P. O. Box 4023 
  1938. X            Duke Station 
  1939. X            Durham, NC  27706
  1940. X
  1941. X            email: tcamp@hercules.acpub.duke.edu
  1942. X
  1943. X    Copyright and Permissions Information:
  1944. X
  1945. X    All U.S. and international copyrights are claimed by the
  1946. X    author. The author grants permission to use this code
  1947. X    and software based on it under the following conditions:
  1948. X    (a) in general, the code and software based upon it may be 
  1949. X    used by individuals and by non-profit organizations; (b) it
  1950. X    may also be utilized by governmental agencies in any country,
  1951. X    with the exception of military agencies; (c) the code and/or
  1952. X    software based upon it may not be sold for a profit without
  1953. X    an explicit and specific permission from the author, except
  1954. X    that a minimal fee may be charged for media on which it is
  1955. X    copied, and for copying and handling; (d) the code must be 
  1956. X    distributed in the form in which it has been released by the
  1957. X    author; and (e) the code and software based upon it may not 
  1958. X    be used for illegal activities. 
  1959. X
  1960. **************************************************************************/
  1961. X
  1962. #include "stdio.h"
  1963. #include "kb.h"
  1964. X
  1965. #ifndef   TRUE
  1966. #define   TRUE   1
  1967. #define   FALSE   0
  1968. #endif
  1969. X
  1970. #ifndef   ESC
  1971. #define   ESC   0x1b
  1972. #endif
  1973. X
  1974. extern int x_keybevent;
  1975. extern int x_keypending;
  1976. X
  1977. /*************************************************************************
  1978. X
  1979. X   FUNCTION:       kb_init()
  1980. X
  1981. X   DESCRIPTION:    This function should perform any initialization
  1982. X         necessary for the keyboard system.
  1983. X
  1984. X   INPUT:          none.
  1985. X
  1986. X   RETURNS:        none.
  1987. X
  1988. **************************************************************************/
  1989. X
  1990. kb_init()
  1991. X   {
  1992. X   }
  1993. X
  1994. X
  1995. /*************************************************************************
  1996. X
  1997. X   FUNCTION:       kb_deinit()
  1998. X
  1999. X   DESCRIPTION:    This function should perform any necessary
  2000. X         deinitialization, that is, return the keyboard
  2001. X         to its default state when a Simple Software
  2002. X         program is to be exited.
  2003. X
  2004. X   INPUT:          none.
  2005. X
  2006. X   RETURNS:        none.
  2007. X
  2008. **************************************************************************/
  2009. X
  2010. kb_deinit()
  2011. X   {
  2012. X   }
  2013. X
  2014. /*************************************************************************
  2015. X
  2016. X   FUNCTION:       kb_rxstat()
  2017. X
  2018. X   DESCRIPTION:    This function determines whether a character is
  2019. X         ready from the console.  The function is used
  2020. X         especially in telecommunications programs,
  2021. X         where it is necessary to poll the keyboard
  2022. X         without locking up the program waiting for a
  2023. X         response.
  2024. X
  2025. X   INPUT:          none.
  2026. X
  2027. X   RETURNS:        The function returns 0 if no character is
  2028. X         available and 1 if a character is available.
  2029. X
  2030. **************************************************************************/
  2031. X
  2032. kb_rxstat()
  2033. X   {
  2034. X   if ( x_keybevent == TRUE )
  2035. X      {
  2036. X      return TRUE;
  2037. X      }
  2038. X   x_pollevent();
  2039. X   if ( x_keybevent == TRUE )
  2040. X      {
  2041. X      return TRUE;
  2042. X      }
  2043. X   return FALSE;
  2044. X   }
  2045. X
  2046. /*************************************************************************
  2047. X
  2048. X   FUNCTION:       kb_rx()
  2049. X
  2050. X   DESCRIPTION:    This function returns a single character from
  2051. X         the keyboard.  If a character is not available
  2052. X         it waits.  The function should be able to
  2053. X         recognize any special keys, and return the
  2054. X         appropriate Simple Software KB conventions
  2055. X         designated for them.
  2056. X
  2057. X   INPUT:          none.
  2058. X
  2059. X   RETURNS:        The function returns the ASCII code for the
  2060. X         key pressed, or the Simple Software KB convention
  2061. X         (see kb.h) for a function or other special key.
  2062. X
  2063. **************************************************************************/
  2064. X
  2065. kb_rx()
  2066. X   {
  2067. X
  2068. X   while( x_keybevent == FALSE )
  2069. X      {
  2070. X      x_pollevent();
  2071. X      }
  2072. X   x_keybevent = FALSE;
  2073. X   return ( x_keypending );
  2074. X
  2075. X   }
  2076. X
  2077. SHAR_EOF
  2078. chmod 0644 io/kb/kb_x.c ||
  2079. echo 'restore of io/kb/kb_x.c failed'
  2080. Wc_c="`wc -c < 'io/kb/kb_x.c'`"
  2081. test 3981 -eq "$Wc_c" ||
  2082.     echo 'io/kb/kb_x.c: original size 3981, current size' "$Wc_c"
  2083. rm -f _shar_wnt_.tmp
  2084. fi
  2085. # ============= io/tw/tw.h ==============
  2086. if test ! -d 'io/tw'; then
  2087.     echo 'x - creating directory io/tw'
  2088.     mkdir 'io/tw'
  2089. fi
  2090. if test -f 'io/tw/tw.h' -a X"$1" != X"-c"; then
  2091.     echo 'x - skipping io/tw/tw.h (File already exists)'
  2092.     rm -f _shar_wnt_.tmp
  2093. else
  2094. > _shar_wnt_.tmp
  2095. echo 'x - extracting io/tw/tw.h (Text)'
  2096. sed 's/^X//' << 'SHAR_EOF' > 'io/tw/tw.h' &&
  2097. /****************************************************************
  2098. X
  2099. X    tw.h            Header for Graphics Text Window
  2100. X
  2101. X            Copyright (c) 1991, Ted A. Campbell
  2102. X
  2103. X            Bywater Software
  2104. X            P. O. Box 4023
  2105. X            Duke Station
  2106. X            Durham, NC  27706
  2107. X
  2108. X            email: tcamp@teer3.acpub.duke.edu
  2109. X
  2110. X    Copyright and Permissions Information:
  2111. X
  2112. X    All U.S. and international copyrights are claimed by the
  2113. X    author. The author grants permission to use this code
  2114. X    and software based on it under the following conditions:
  2115. X    (a) in general, the code and software based upon it may be
  2116. X    used by individuals and by non-profit organizations; (b) it
  2117. X    may also be utilized by governmental agencies in any country,
  2118. X    with the exception of military agencies; (c) the code and/or
  2119. X    software based upon it may not be sold for a profit without
  2120. X    an explicit and specific permission from the author, except
  2121. X    that a minimal fee may be charged for media on which it is
  2122. X    copied, and for copying and handling; (d) the code must be
  2123. X    distributed in the form in which it has been released by the
  2124. X    author; and (e) the code and software based upon it may not
  2125. X    be used for illegal activities.
  2126. X
  2127. ****************************************************************/
  2128. X
  2129. struct tw_struct
  2130. X   {
  2131. X   int          x1;                     /* left side in graphics coords */
  2132. X   int          y1;                     /* bottom in graphics coords */
  2133. X   int          x2;                     /* right side in graphics coords */
  2134. X   int          y2;                     /* top in graphics coords */
  2135. X   int          fxsize;                 /* font size graphics coords */
  2136. X   int          fysize;                 /* font size graphics coords */
  2137. X   int          lines;                  /* number of text lines */
  2138. X   int          columns;                /* number of text columns */
  2139. X   }
  2140. X
  2141. X
  2142. extern struct tw_struct *tw_init();
  2143. SHAR_EOF
  2144. chmod 0644 io/tw/tw.h ||
  2145. echo 'restore of io/tw/tw.h failed'
  2146. Wc_c="`wc -c < 'io/tw/tw.h'`"
  2147. test 1832 -eq "$Wc_c" ||
  2148.     echo 'io/tw/tw.h: original size 1832, current size' "$Wc_c"
  2149. rm -f _shar_wnt_.tmp
  2150. fi
  2151. # ============= io/tw/tw_ibmpc.c ==============
  2152. if test -f 'io/tw/tw_ibmpc.c' -a X"$1" != X"-c"; then
  2153.     echo 'x - skipping io/tw/tw_ibmpc.c (File already exists)'
  2154.     rm -f _shar_wnt_.tmp
  2155. else
  2156. > _shar_wnt_.tmp
  2157. echo 'x - extracting io/tw/tw_ibmpc.c (Text)'
  2158. sed 's/^X//' << 'SHAR_EOF' > 'io/tw/tw_ibmpc.c' &&
  2159. /****************************************************************
  2160. X
  2161. X    tw_ibmpc.c      Graphics Text Window
  2162. X            for IBM PC (tm) and compatibles
  2163. X            utilizing Microsoft QuickC (tm)
  2164. X
  2165. X            Copyright (c) 1991, Ted A. Campbell
  2166. X
  2167. X            Bywater Software
  2168. X            P. O. Box 4023
  2169. X            Duke Station
  2170. X            Durham, NC  27706
  2171. X
  2172. X            email: tcamp@teer3.acpub.duke.edu
  2173. X
  2174. X    Copyright and Permissions Information:
  2175. X
  2176. X    All U.S. and international copyrights are claimed by the
  2177. X    author. The author grants permission to use this code
  2178. X    and software based on it under the following conditions:
  2179. X    (a) in general, the code and software based upon it may be
  2180. X    used by individuals and by non-profit organizations; (b) it
  2181. X    may also be utilized by governmental agencies in any country,
  2182. X    with the exception of military agencies; (c) the code and/or
  2183. X    software based upon it may not be sold for a profit without
  2184. X    an explicit and specific permission from the author, except
  2185. X    that a minimal fee may be charged for media on which it is
  2186. X    copied, and for copying and handling; (d) the code must be
  2187. X    distributed in the form in which it has been released by the
  2188. X    author; and (e) the code and software based upon it may not
  2189. X    be used for illegal activities.
  2190. X
  2191. ****************************************************************/
  2192. X
  2193. #include "stdio.h"
  2194. X
  2195. #include "graph.h"
  2196. X
  2197. #ifdef __STDC__
  2198. #include "malloc.h"
  2199. #else
  2200. extern char * malloc();
  2201. #endif
  2202. X
  2203. #include "bw.h"
  2204. #include "gr.h"
  2205. #include "tw.h"
  2206. X
  2207. #define DEF_LINES       25
  2208. #define DEF_COLUMNS     80
  2209. X
  2210. static struct tw_struct * cur_twstruct = NULL;
  2211. X
  2212. struct tw_struct *
  2213. tw_init( rq_x1, rq_y2, rq_lines, rq_cols, min_x1, min_y1, max_x2, max_y2 )
  2214. X   int rq_x1;                   /* requested x1 (left, graphics) position */
  2215. X   int rq_y2;                   /* requested y2 (top,  graphics) position */
  2216. X   int rq_lines;                /* requested text lines */
  2217. X   int rq_cols;                 /* requested text columns */
  2218. X   int min_x1;                  /* leftmost   allowable position */
  2219. X   int min_y1;                  /* bottommost allowable position */
  2220. X   int max_x2;                  /* rightmost  allowable position */
  2221. X   int max_y2;                  /* topmost    allowable position */
  2222. X   {
  2223. X   static struct videoconfig ibm_vc;
  2224. X   struct tw_struct *tw;
  2225. X   int x, y;
  2226. X
  2227. X   /* get memory for tw_struct structure */
  2228. X
  2229. X   if ( ( tw = (struct tw_struct *) malloc( sizeof( struct tw_struct ))) == NULL )
  2230. X      {
  2231. X      bw_error( "Failed to find memory for window." );
  2232. X      return NULL;
  2233. X      }
  2234. X
  2235. X   /* determine current size of screen and then text fonts */
  2236. X
  2237. X   _getvideoconfig( &ibm_vc );
  2238. X   tw->fxsize = ibm_vc.numxpixels / DEF_COLUMNS;
  2239. X   if ( ibm_vc.mode == _HERCMONO )
  2240. X      {
  2241. X      tw->fysize = ( ibm_vc.numypixels + 2 ) / DEF_LINES;
  2242. SHAR_EOF
  2243. true || echo 'restore of io/tw/tw_ibmpc.c failed'
  2244. fi
  2245. echo 'End of  part 5'
  2246. echo 'File io/tw/tw_ibmpc.c is continued in part 6'
  2247. echo 6 > _shar_seq_.tmp
  2248. exit 0
  2249. exit 0 # Just in case...
  2250. -- 
  2251. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2252. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2253. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2254. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2255.