home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / backgmmn.zip / KEYDEFS.C < prev    next >
Text File  |  1987-12-24  |  3KB  |  89 lines

  1.  
  2. /* KeyDefs.C
  3. ** December 7, 1986, David C. Oshel
  4. **
  5. ** Displays a popout window with the ten Fn keys drawn down the middle
  6. ** The function names are listed in 21 character fields to left and right
  7. ** Sample arrays of menu strings are shown below, all 10 must be defined
  8. ** even if the string is null.
  9. ** Waits for response from the user, if ESC is typed, returns F1
  10. */
  11.  
  12. #include "ciao.h"
  13. #define ESC 27
  14. #define F1 187
  15. #define keycatcher() signal(SIGINT,SIG_IGN); while (kbhit()) getkey();
  16.  
  17. /* strings may be up to 21 chars, preferably no more than 18
  18. */
  19.                    /* ....v....1....v....2. */
  20.  
  21. /* note: example arrays show how to duplicate strings in the menus! 
  22. ** "phi" is a glyph meaning "undefined function" in one application
  23. **
  24.  
  25. static char nyi[] = "φ",
  26.             sco[] = "Screen Colors",
  27.             klk[] = "Key Click";
  28.  
  29. char *MainMenu[] = { "Quit Program",             "Help", 
  30.                      "Chart of Accounts",        "General Journal", 
  31.                      "User Information",         "Trial Balance",
  32.                       sco,                       "Close the Books",
  33.                       klk,                       "Financial Reports"
  34.                    };
  35.  
  36. char *JnlMenu[] =  { "Quit Program",             "List Fn Keys",
  37.                      "List Chart of Accts",      "Review Journal Docs",
  38.                       nyi,                        nyi,
  39.                       sco,                        nyi,
  40.                       klk,                        nyi
  41.                    };
  42. **
  43. */
  44.  
  45. int KeyDefs( name, menutitle, msg ) 
  46. char **name, *menutitle, *msg;
  47. {
  48.      char far *p; union REGS x;  
  49.      register int i,n;
  50.      char *blks,*dots;
  51.  
  52.      blks = "                     ",
  53.      dots = ".....................";
  54.  
  55.      p = savescreen( &x );  /* save caller's original screen */
  56.      windowbox ( 13, 3, 53 + 13, 20 + 3 );
  57.  
  58.      gotoxy( ((53 - strlen( menutitle )) / 2), 1 ); 
  59.      wprintf("%s\n\n", menutitle );
  60.  
  61.      /* draw key boxes */ 
  62.      for (n = 1, i = 0; i < 5; n += 2, i++)
  63.      {
  64.         wink(' '); wputs(blks); wputs("╔═══╗╔═══╗\n"); 
  65.         wink(' '); wputs(dots); wprintf("║F%-2d║║F%-2d║", n, n + 1); 
  66.                    wputs(dots); wink('\n');
  67.         wink(' '); wputs(blks); wputs("╚═══╝╚═══╝\n");
  68.      }
  69.  
  70.      /* fill in key names */
  71.      for ( n = 4, i = 0; i < 5; n += 3, i++)
  72.      {
  73.           gotoxy( 1, n );                   wputs( *name++ ); /* left  */
  74.           gotoxy((53 - strlen(*name)), n ); wputs( *name++ ); /* right */
  75.      }
  76.  
  77.      gotoxy( ((53 - strlen( msg )) / 2), 19 ); wputs( msg );
  78.      defcursor();
  79.      keycatcher();
  80.      n = getkey();
  81.      if (n == ESC) n = F1;
  82.      restorescreen( p, &x );
  83.      gotoxy( x.h.dl, x.h.dh );  /* "bug" fix, if that's what it is */
  84.      return (n);
  85. }
  86.  
  87.  
  88. 
  89.