home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap14 / drawchar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-07  |  2.4 KB  |  68 lines

  1. /* drawchar.c -- drawing module for grafdraw.c         */
  2. /* translates keystrokes to graphic characters,        */
  3. /* manages cursor control and function keys            */
  4.  
  5. #include <conio.h>
  6. #include "keys.h"
  7. #include "scrn.h"
  8. #include "grafchar.h"
  9. extern unsigned char Grchr[];  /* defined in grafchar.c */
  10.  
  11. void Draw_chars()
  12. {
  13.     int ch, chout;
  14.     unsigned char attrib = NORMAL;
  15.     unsigned char draw = TRUE;
  16.  
  17.     chout = Grchr[0];  /* default graphics character */
  18.     while ((ch = getch()) != ESC)
  19.         {
  20.         if (ch >= '0' && ch <= '_')
  21.             chout = Grchr[ch - '0'];
  22.             /* this maps the 0 key to the first */
  23.             /* graphics character, etc.         */
  24.         else if (ch == SPACE)
  25.             chout = SPACE;
  26.         else if (ch == 0) /* process cursor keys */
  27.             {             /* and function keys   */
  28.             ch = getch();
  29.             switch (ch)
  30.                 {
  31.                 case PU : draw = FALSE;
  32.                           break;
  33.                 case PD : draw = TRUE;
  34.                           break;
  35.                 case UP : if (draw)
  36.                               Write_ch_atr(chout, attrib,
  37.                                            PAGE, 1);
  38.                           if (!Cursup())
  39.                               putch(BEEP);
  40.                           break;
  41.                 case DN : if (draw)
  42.                               Write_ch_atr(chout, attrib,
  43.                                            PAGE, 1);
  44.                           if (!Cursdn_lim(BOTLINE))
  45.                               putch(BEEP);
  46.                           break;
  47.                 case LT : if (draw)
  48.                               Write_ch_atr(chout, attrib,
  49.                                            PAGE, 1);
  50.                           if (!Curslt())
  51.                               putch(BEEP);
  52.                           break;
  53.                 case RT : if (draw)
  54.                               Write_ch_atr(chout, attrib,
  55.                                            PAGE, 1);
  56.                           if (!Cursrt())
  57.                               putch(BEEP);
  58.                           break;
  59.                 case F1 : attrib = NORMAL; break;
  60.                 case F2 : attrib = VIDREV; break;
  61.                 case F3 : attrib ^= BLINK; break;
  62.                 case F4 : attrib ^= INTENSE; break;
  63.                 default : putch(BEEP);
  64.                 }
  65.             }
  66.         }
  67. }
  68.