home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / mac-emacs-src / traps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-23  |  1.4 KB  |  74 lines  |  [TEXT/EMAC]

  1. /*
  2.  * Copyright (C) 1993, 1994 Marc Parmet.
  3.  * This file is part of the Macintosh port of GNU Emacs.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #if defined(THINK_C)
  12. #include <MacHeaders>
  13. #else
  14. #include <Types.h>
  15. #include <Memory.h>
  16. #include <Quickdraw.h>
  17. #include <Windows.h>
  18. #include <Dialogs.h>
  19. #include <SegLoad.h>
  20. #include <ToolUtils.h>
  21. #endif
  22.  
  23. #include <GestaltEqu.h>
  24.  
  25. static void
  26. blink(DialogPtr d,int i)
  27. {
  28.     short type;
  29.     ControlHandle h;
  30.     Rect box;
  31.     long now;
  32.  
  33.     GetDItem(d,i,&type,(Handle *)&h,&box);
  34.     HiliteControl(h,inButton);
  35.     now = TickCount();
  36.     while (TickCount() < now+10)
  37.         ;
  38.     HiliteControl(h,0);
  39. }
  40.  
  41. static pascal Boolean
  42. need_sys7_filter(DialogPtr d,EventRecord *e,short *i)
  43. {
  44.     char c;
  45.     
  46.     switch (e->what) {
  47.     case keyDown:
  48.         c = e->message & charCodeMask;
  49.         *i = (c == '\015' || c == '\012' || c == 3);
  50.         blink(d,1);
  51.         return 1;
  52.     default:
  53.         return 0;
  54.     }
  55. }
  56.  
  57. void
  58. check_traps(void)
  59. {
  60.     short err;
  61.     long response;
  62.     static ModalFilterUPP need_sys7_filter_upp;
  63.     
  64.     if (need_sys7_filter_upp == 0L)
  65.         need_sys7_filter_upp = NewModalFilterProc(need_sys7_filter);
  66.  
  67.     err = Gestalt(gestaltSystemVersion,&response);
  68.     if (err || LoWord(response) < 0x0700) {
  69.         InitCursor();
  70.         Alert(132,need_sys7_filter_upp);
  71.         ExitToShell();
  72.     }
  73. }
  74.