home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d952 / machv.lha / MachV / programmer.lha / docs / pgm.doc < prev   
Text File  |  1993-09-20  |  3KB  |  89 lines

  1.  
  2. MachIV opens mach.library, reads in the configuration settings and fills
  3. in mach.library variables. These may then be accessed and modified by 
  4. other programs. In particular, the macro list may be walked and macros may
  5. be changed.
  6.  
  7. There are several library functions (detailed in mach.doc) for finding, 
  8. creating, and changing macros. There is also a function for putting up 
  9. a list of macro names, window and screen names, and configuration titles.
  10.  
  11. In the library base is a semaphore structure that should be 'Obtained' 
  12. before examining or modifying any macro. There are two example programs
  13. in the autodoc file mach.doc, and the programs 'PrintMacros' and 'Vars' 
  14. also show how to access the library.
  15.  
  16. In brief, the library has the List struct ml_ConfigHead which is a list
  17. of MachCfg structs, one for each configuration that the user may have.
  18. In the MachCfg struct are the settings that the users has selected and
  19. an array of 128 List structs each of which contains a list of macros. All 
  20. hotkeys for a specific keycode are contained in one list. The keycode of
  21. the hotkey is used as the index into the array. 
  22.  
  23. For example: 
  24.  
  25.   MachBase->ml_ConfigHead.lh_Head->mc_Hotkeys[0x45].lh_Head->mo_Macro
  26.  
  27. points to the first macro attached to the ESC key (0x45). This actually
  28. would need extensive casting or assignments to variables:
  29.  
  30.     mac = ((struct MacroObject*)(((struct MachCfg*)(MachBase->ml_ConfigHead.lh_Head))->mc_Hotkeys[0x45].lh_Head))->mo_Macro;
  31.  
  32. or
  33.  
  34.     struct MachCfg *cfg;
  35.     struct MacroObject *mo;
  36.  
  37.     cfg = (struct MachCfg *)MachBase->ml_ConfigHead.lh_Head;
  38.     mo = (struct MacroObject *)cfg->mc_Hotkeys[0x45].lh_Head;
  39.     mac = mo->mo_Macro;
  40.     
  41. Of course it is easier to use a library funtion like:
  42.  
  43.     char string[] = "macro text";
  44.     UWORD key = 0x45;
  45.     UWORD qualifiers = IEQUALIFIER_CONTROL;
  46.  
  47.     if (mo = NewMacroObject(cfg,string,key,qualifiers)) {
  48.         printf("%s\n",mo->mo_Macro );
  49.     }
  50.  
  51. Some events may be simply set in ml_GeneralEvent or ml_MouseEvent and then
  52. signal MachV. The events for loading, saving, adding and deleting of
  53. configurations and GE_DO_VAR must use PutMsg().
  54.  
  55. Signal like this:
  56.  
  57.     MachBase->ml_GeneralEvent |= GE_BEEP;
  58.     Signal(MachBase->ml_MachV_Task.Task, MachBase->ml_MachV_Task.Sig);
  59.  
  60. Sending a message to MachV is done in a method similar to this:
  61.  
  62. void putmsg_machv(long ev)
  63. {
  64.   struct MsgPort *rp;
  65.  
  66.   rp = CreatePort(NULL,0L);
  67.   if (rp) {
  68.     machmsg.mm_Msg.mn_ReplyPort = rp;
  69.     machmsg.mm_Msg.mn_Node.ln_Name = "MACHV";
  70.     machmsg.mm_Command = MACHV_GENERAL_EVENT;
  71.     machmsg.mm_SubCommand = ev; /* may be GE_LOADCONFIG, GE_ADDCONFIG etc. */
  72.     PutMsg(MachBase->ml_MsgPort,(struct Message*)&machmsg); /* tell MachV */
  73.     WaitPort(rp);   /* wait for reply */
  74.     GetMsg(rp);     /* get reply */
  75.     DeletePort(rp);
  76.   }
  77. }
  78.  
  79. The autodoc examples, PrintMacros.c and vars.c should give a sufficient 
  80. start for anyone wishing to write their own interface to MachIV. More
  81. information will be made available in the future. 
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.