home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / Editors / mjovesrc.zoo / bgetkey.c < prev    next >
C/C++ Source or Header  |  1992-04-04  |  1KB  |  73 lines

  1. /****************************************************************************
  2. code to handle special keys (i.e. function keys, arrow keys, help, undo, ...).
  3. returns either ascii value of normal key or scan code value of special key.
  4. flag speckey is true if key is special, false otherwise.
  5. ******************************************************************************/
  6. #ifdef MiNT
  7. #include <osbind.h>
  8. #include <stdio.h>
  9.  
  10. #ifndef FALSE
  11. #define FALSE 0
  12. #define TRUE !FALSE
  13. #endif
  14.  
  15. bgetkey(int *speckey)
  16. {
  17.     union scancode {
  18.         long    scan;
  19.         short    scarray[2];
  20.     } sc;
  21.  
  22.     sc.scan = Bconin(2);
  23.     if (sc.scarray[1]) {
  24.         *speckey = FALSE;
  25.         return (sc.scarray[1]);
  26.     }
  27.     else {
  28.         *speckey = TRUE;
  29.         return (sc.scarray[0]);
  30.     }
  31. }
  32.  
  33. #define keynotready !Bconstat(2)
  34.  
  35. jgetkey()
  36. {
  37.     int keycode, spec_key;
  38. #define SPEC_START    (0x80 - 0x3b)
  39.  
  40.     while (keynotready)
  41.         waitfun();
  42.  
  43.     keycode = bgetkey(&spec_key);
  44.     if (spec_key) {
  45.         if ((keycode > 0x77) || (keycode < 0x3b))   /* no alt keys */
  46.             return (0x45);      /* undefined, so unbound */
  47.         return (keycode + SPEC_START);
  48.     }
  49.     return (keycode);
  50. }
  51.  
  52. int last_min = 0;
  53.  
  54. waitfun()
  55. {
  56.     if (UpdModLine) {
  57.         redisplay();
  58.         return;
  59.     }
  60.     {
  61.         const struct tm *t_buf;
  62.         time_t num_secs;
  63.  
  64.         time(&num_secs);
  65.         t_buf = localtime(&num_secs);
  66.         if (t_buf->tm_min != last_min) {
  67.             UpdModLine = YES;
  68.             last_min = t_buf->tm_min;
  69.         }
  70.     }
  71. }
  72. #endif /* MiNT */
  73.