home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.2 / AppShell / include / libraries / appshell.h
Encoding:
C/C++ Source or Header  |  1992-08-26  |  35.2 KB  |  866 lines

  1. /* appshell.h
  2.  * Copyright (C) 1990 Commodore-Amiga, Inc.
  3.  * written by David N. Junod
  4.  *
  5.  * header file for the Amiga AppShell
  6.  *
  7.  */
  8.  
  9. #include <exec/types.h>
  10. #include <exec/memory.h>
  11. #include <workbench/startup.h>
  12. #include <libraries/dos.h>
  13.  
  14. #include <clib/macros.h>
  15. #include <clib/alib_protos.h>
  16. #include <clib/dos_protos.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/gadtools_protos.h>
  19. #include <clib/graphics_protos.h>
  20. #include <clib/icon_protos.h>
  21. #include <clib/intuition_protos.h>
  22. #include <clib/layers_protos.h>
  23. #include <clib/wb_protos.h>
  24. #include <clib/utility_protos.h>
  25.  
  26. #include <intuition/classes.h>
  27. #include <intuition/classusr.h>
  28. #include <intuition/sghooks.h>
  29. #include <string.h>
  30.  
  31. /* Usually allocate one large block of memory for a group of items and then
  32.  * divy out to the appropriate pointers.  Use with caution---must be
  33.  * consistent with field types! */
  34. #define MEMORY_FOLLOWING(ptr) ((void *)((ptr)+1))
  35. #define MEMORY_N_FOLLOWING(ptr,n)  ((void *)( ((ULONG)ptr) + n ))
  36.  
  37. /* Used to cast an pointer to a void pointer */
  38. #define V(x) ((void *)x)
  39.  
  40. /* BPTR compatibility */
  41. #define TO_BPTR(x) ((BPTR)(((ULONG)(x)) >> 2))
  42.  
  43. /* Maximum number of arguments in a command string.  Don't bother changing. */
  44. #define    MAXARG 64
  45.  
  46. /* The Funcs structure contains base information for a command.  This
  47.  * information gets translated into a Function Table entry and gets appended
  48.  * to the Function Table list. */
  49. struct Funcs
  50. {
  51.     UBYTE *fe_Name;        /* Name of function */
  52.     VOID (*fe_Func)(struct AppInfo *, STRPTR, struct TagItem *);
  53.     ULONG fe_ID;        /* ID of function */
  54.     ULONG fe_Key;        /* HotKey assigned to function */
  55.     ULONG fe_HelpID;        /* index into the the text catalogue for help */
  56.     ULONG fe_Flags;        /* Status of function */
  57.     STRPTR fe_Params;        /* optional parameters for function */
  58.     ULONG *fe_GroupID;        /* ~0 terminated array of group ID's */
  59. };
  60.  
  61. /* no internal function defined for event */
  62. #define    NO_FUNCTION    NULL
  63.  
  64. /* function table entry flags */
  65. #define    APSH_FF_DISABLED (1L<<1)/* function is disabled */
  66. #define    APSH_FF_PRIVATE (1L<<2)    /* function can't be called from command line */
  67. #define    APSH_FF_ALIAS (1L<<3)    /* function is an alias */
  68.  
  69. /* The BasePrefs structure contains preference information that all AppShell
  70.  * applications honor.  Envision a preference editor and a global preference
  71.  * file to contain this information. */
  72. struct BasePrefs
  73. {
  74.     ULONG bp_Flags;        /* misc. preference flags */
  75. };
  76.  
  77. /* Set this flag to enable saving of icons with files. This feature is
  78.  * not implemented. */
  79. #define    APSHF_USEICONS (1L<<1)
  80.  
  81. /* The AppShell defaults to using a console window for the Command Shell.
  82.  * By setting the following flag, the AppShell will use a Scrolling List
  83.  * gadget to show history and use a Text gadget for command entry.
  84.  * This feature is not implemented. */
  85. #define APSHF_LISTVIEW (1L<<2)    /* use listview & text gadget */
  86.  
  87.  
  88. /* The Project structure is used to maintain information on a project set.
  89.  * Project sets are not limited to the main project list, but also include
  90.  * such things as lists of components for a project. */
  91. struct Project
  92. {
  93.     struct List p_ProjList;    /* Project list */
  94.     struct ProjNode *p_CurProj;    /* Current project */
  95.     LONG p_NumProjs;        /* Number of projects */
  96.     LONG p_MaxID;        /* Next available ID */
  97.     LONG p_State;        /* Listview state */
  98.     LONG p_TopView;        /* Listview top line */
  99.     LONG p_CurLine;        /* Listview current line */
  100.     ULONG p_Flags;        /* Project flags */
  101.     APTR p_UserData;        /* User data extension */
  102.     APTR p_SysData;        /* System data extension */
  103. };
  104.  
  105. /* When this flag is set, the project information is being displayed by
  106.  * the Project List data entry requester. */
  107. #define    APSHF_PROJVIEW (1L<<1)
  108.  
  109.  
  110. /* Within the Project structure is an Exec list called p_ProjList.  This
  111.  * is a list of ProjNode structures.  This structure contains information
  112.  * on projects or project components.  This information can be obtained at
  113.  * startup time, from AppWindow/AppIcon messages, ASL file requester or
  114.  * through application constructs. */
  115. struct ProjNode
  116. {
  117.     struct Node pn_Node;    /* embedded Exec node */
  118.  
  119.     /* AppShell information.  Read only for application */
  120.     struct DateStamp pn_Added;    /* date stamp when added to list */
  121.     BPTR pn_ProjDir;        /* lock on project directory */
  122.     STRPTR pn_ProjPath;        /* pointer to the projects' complete name */
  123.     STRPTR pn_ProjName;        /* pointer to the projects' name */
  124.     STRPTR pn_ProjComment;    /* pointer to the projects' comment */
  125.     struct DiskObject *pn_DObj;    /* pointer to the projects' icon */
  126.     LONG pn_ID;            /* user selected order */
  127.     APTR pn_SysData;        /* System data extension */
  128.  
  129.     /* Application information */
  130.     ULONG pn_Status;        /* status of project */
  131.     ULONG pn_ProjID;        /* project ID */
  132.     UBYTE pn_Name[32];        /* project name */
  133.     APTR pn_UserData;        /* UserData for project */
  134.     BOOL pn_Changed;        /* has project been modified? */
  135. };
  136.  
  137. /* AppInfo structure that contains an AppShell application's global
  138.  * variables.  This structure is variable length, so NEVER embedd this
  139.  * within your own structures.  If you must, then reference it by a
  140.  * pointer. */
  141. struct AppInfo
  142. {
  143.     /* control information */
  144.     UBYTE *ai_TextRtn;        /* Text return string */
  145.     LONG ai_Pri_Ret;        /* Primary error (severity) */
  146.     LONG ai_Sec_Ret;        /* Secondary error (actual) */
  147.     BOOL ai_Done;        /* Done with main loop? */
  148.  
  149.     /* base application information */
  150.     struct BasePrefs *ai_BasePrefs;/* base user preferences */
  151.     ULONG ai_PrefSize;        /* sizeof (struct BasePrefs) */
  152.     BPTR ai_ProgDir;        /* base directory for application */
  153.     BPTR ai_ConfigDir;        /* configuration file directory */
  154.     struct DiskObject *ai_ProgDO;/* application tool icon */
  155.     STRPTR ai_ProgName;        /* pointer to application base name */
  156.     STRPTR ai_AppName;        /* pointer to application name */
  157.     STRPTR ai_AppVersion;    /* pointer to version string */
  158.     STRPTR ai_AppCopyright;    /* pointer to copyright notice */
  159.     STRPTR ai_AppAuthor;    /* pointer to author */
  160.     STRPTR ai_AppMsgTitle;    /* pointer to title for messages */
  161.  
  162.     /* project information */
  163.     struct Project ai_Project;    /* embedded Project structure */
  164.  
  165.     /* application information */
  166.     APTR ai_UserData;        /* UserData */
  167.  
  168.     /* READ ONLY Intuition-specific information */
  169.     struct TextFont *ai_Font;    /* Font for screen */
  170.     struct Screen *ai_Screen;    /* Active screen */
  171.     struct Window *ai_Window;    /* Active window */
  172.     struct Gadget *ai_Gadget;    /* Active gadget */
  173.     struct MHObject *ai_CurObj;    /* Active object (gadget) */
  174.     struct DrawInfo *ai_DI;    /* Intuition DrawInfo */
  175.     VOID *ai_VI;        /* GadTools VisualInfo */
  176.     WORD ai_MouseX;        /* Position at last IDCMP message */
  177.     WORD ai_MouseY;        /* Position at last IDCMP message */
  178.     UWORD ai_TopLine;        /* top line */
  179. };
  180.  
  181. /*--------------------------------------------------------------------------*/
  182. /* Following is information used by the main portion of the AppShell        */
  183. /*--------------------------------------------------------------------------*/
  184.  
  185. /* Each message handler gets a base ID from which all of their commands are
  186.  * offset.  The main functions are offset from zero. */
  187. #define APSH_MAIN_ID 0L
  188.  
  189. /* Following are ID's for the functions that are implemented by the AppShell
  190.  * whether there are any message handlers or not. */
  191. #define MAIN_Dummy    APSH_MAIN_ID
  192. #define AliasID        (MAIN_Dummy+1L) /* set up function w/parameters     */
  193. #define DebugID        (MAIN_Dummy+2L) /* general debugging                */
  194. #define DisableID    (MAIN_Dummy+3L) /* Disable a function               */
  195. #define EditID        (MAIN_Dummy+4L) /* Edit an object                   */
  196. #define EnableID    (MAIN_Dummy+5L) /* Enable a function                */
  197. #define ExecMacroID    (MAIN_Dummy+6L) /* Execute the internal macro       */
  198. #define FaultID        (MAIN_Dummy+7L) /* Return error text                */
  199. #define GetID        (MAIN_Dummy+8L) /* Get object attribute             */
  200. #define GroupID        (MAIN_Dummy+9L) /* Maintain object groups           */
  201. #define HelpID        (MAIN_Dummy+10L)/* Help                             */
  202. #define LearnID        (MAIN_Dummy+11L)/* Learn macro function             */
  203. #define StopLearnID    (MAIN_Dummy+12L)/* Stop learn macro function        */
  204. #define LoadMacroID    (MAIN_Dummy+13L)/* Load a macro into the internal memory */
  205. #define PriorityID    (MAIN_Dummy+14L)/* Set an objects priority (process) */
  206. #define    RemoveID    (MAIN_Dummy+15L)/* remove an object (project)       */
  207. #define SaveMacroID    (MAIN_Dummy+16L)/* Save the internal macro to disk  */
  208. #define SelectID    (MAIN_Dummy+17L)/* select an object (project)       */
  209. #define SelectTopID    (MAIN_Dummy+18L)/* select first object (project)    */
  210. #define SelectNextID    (MAIN_Dummy+19L)/* select next object (project)     */
  211. #define SelectPrevID    (MAIN_Dummy+20L)/* select previous object (project) */
  212. #define SelectBottomID    (MAIN_Dummy+21L)/* select last object (project)     */
  213. #define SetID        (MAIN_Dummy+22L)/* Set object attributes            */
  214. #define StatusID    (MAIN_Dummy+23L)/* Give status of an object         */
  215. #define StopID        (MAIN_Dummy+24L)/* Stop an operation                */
  216. #define StubID        (MAIN_Dummy+25L)/* NOP function                     */
  217. #define    VersionID    (MAIN_Dummy+26L)/* Version                          */
  218.  
  219. /* data transmission function ID's via OpenSIPC, SIPCPrintf, CloseSIPC */
  220. #define    LoginID        (MAIN_Dummy+100L)/* request data transmission session */
  221. #define    DataStreamID    (MAIN_Dummy+101L)/* data transmission */
  222. #define    SuspendID    (MAIN_Dummy+102L)/* temporarily suspend session */
  223. #define    ResumeID    (MAIN_Dummy+103L)/* resume data session */
  224. #define    LogoutID    (MAIN_Dummy+104L)/* signal end of session */
  225.  
  226. /* Following are ID's for functions that should be implemented by the
  227.  * application to help promote a consistent set of functions for the
  228.  * end user. */
  229.  
  230. /* standard project functions */
  231. #define    NewID        (MAIN_Dummy+500L)/* new project/process */
  232. #define    ClearID        (MAIN_Dummy+501L)/* clear current project */
  233. #define    OpenID        (MAIN_Dummy+502L)/* open an existing project */
  234. #define    SaveID        (MAIN_Dummy+503L)/* save project to existing name */
  235. #define    SaveAsID    (MAIN_Dummy+504L)/* save project to a new name */
  236. #define    RevertID    (MAIN_Dummy+505L)/* revert project to last saved */
  237. #define    PrintID        (MAIN_Dummy+506L)/* print the current project */
  238. #define    PrintAsID    (MAIN_Dummy+507L)/* define print configuration */
  239. #define    AboutID        (MAIN_Dummy+508L)/* display application information */
  240. #define    InfoID        (MAIN_Dummy+509L)/* display project information */
  241. #define    QuitID        (MAIN_Dummy+510L)/* exit from the application */
  242.  
  243. /* application standard edit functions */
  244. #define    MarkID        (MAIN_Dummy+520L)
  245. #define    CutID        (MAIN_Dummy+521L)
  246. #define    CopyID        (MAIN_Dummy+522L)
  247. #define    PasteID        (MAIN_Dummy+523L)
  248. #define    EraseID        (MAIN_Dummy+524L)
  249. #define    UndoID        (MAIN_Dummy+525L)
  250. #define    OpenClipID    (MAIN_Dummy+526L)
  251. #define    SaveClipID    (MAIN_Dummy+527L)
  252. #define    PrintClipID    (MAIN_Dummy+528L)
  253.  
  254. /* application standard search functions */
  255. #define    GotoID        (MAIN_Dummy+540L)
  256. #define    FindID        (MAIN_Dummy+541L)
  257. #define    NextID        (MAIN_Dummy+542L)
  258. #define    ReplaceID    (MAIN_Dummy+543L)
  259.  
  260.  
  261. /*--------------------------------------------------------------------------*/
  262. /* Following is information used by the ARexx message handler               */
  263. /*--------------------------------------------------------------------------*/
  264.  
  265. /* ID assigned to the ARexx message handler */
  266. #define APSH_AREXX_ID 5000L
  267.  
  268. /* Following are ID's for the functions that are implemented by the ARexx
  269.  * message handler. */
  270. #define    AREXX_Dummy    APSH_AREXX_ID
  271. #define    RXID        (AREXX_Dummy+1L)/* Execute an ARexx command */
  272. #define    WhyID        (AREXX_Dummy+2L)/* Return information on the last error */
  273.  
  274. /* ID for an ARexx low-level message handler function */
  275. #define    AH_SENDCMD 4
  276.  
  277. /*--------------------------------------------------------------------------*/
  278. /* Following is information used by the Command Shell message handler       */
  279. /*--------------------------------------------------------------------------*/
  280.  
  281. #define    APSH_DOS_ID 6000L
  282.  
  283. enum
  284. {
  285.     DOS_Dummy = APSH_DOS_ID,
  286.     CMDShellID,            /* Command shell control */
  287. };
  288.  
  289. /*--------------------------------------------------------------------------*/
  290. /* Following is information used by the Intuition message handler           */
  291. /*--------------------------------------------------------------------------*/
  292.  
  293. #define APSH_IDCMP_ID 7000L
  294.  
  295. enum
  296. {
  297.     IDCMP_Dummy = APSH_IDCMP_ID,
  298.     ActivateID,            /* Make window available */
  299.     ButtonID,            /* Edit gadget */
  300.     HotKeyID,            /* Edit HotKey */
  301.     MenuID,            /* Edit menu */
  302.     ToFrontID,            /* bring current window to front */
  303.     ToBackID,            /* send current window to back */
  304.     WindowID,            /* open/close window */
  305. };
  306.  
  307. /* extended MenuItem structure */
  308. struct EMenuItem
  309. {
  310.     struct MenuItem emi_Item;    /* embedded MenuItem structure */
  311.     ULONG emi_MenuID;        /* ID used for function number to perform */
  312.     APTR emi_UserData;        /* UserData (like other Intuition structs) */
  313. };
  314.  
  315. /* extended Gadget structure */
  316. struct EGadget
  317. {
  318.     struct Gadget eg_Gadget;        /* embedded Gadget structure */
  319.     ULONG eg_Funcs[10];            /* Function ID array */
  320. };
  321.  
  322.  
  323. /* Extended Gadget function array pointers */
  324. #define    EG_DOWNPRESS    0
  325. #define    EG_HOLD        1
  326. #define    EG_RELEASE    2
  327. #define    EG_DBLCLICK    3
  328. #define    EG_ABORT    4
  329. #define    EG_ALTHIT    5
  330. #define    EG_SHIFTHIT    6
  331.  
  332. /* Intuition object types */
  333. enum
  334. {
  335.     OBJ_Dummy = 0L,
  336.  
  337.     /* GadTools gadgets */
  338.     OBJ_Generic,
  339.     OBJ_Button,
  340.     OBJ_Checkbox,
  341.     OBJ_Integer,
  342.     OBJ_Listview,
  343.     OBJ_MX,
  344.     OBJ_Number,
  345.     OBJ_Cycle,
  346.     OBJ_Palette,
  347.     OBJ_Scroller,
  348.     OBJ_reserved,        /* reserved for system use */
  349.     OBJ_Slider,
  350.     OBJ_String,
  351.     OBJ_Text,
  352.  
  353.     /* other gadgets */
  354.     OBJ_Display,
  355.     OBJ_Select,
  356.     OBJ_Dropbox,
  357.     OBJ_GImage,
  358.  
  359.     /* images */
  360.     OBJ_Image,
  361.  
  362.     /* borders */
  363.     OBJ_Plain,
  364.     OBJ_BevelIn,
  365.     OBJ_BevelOut,
  366.     OBJ_DblBevelIn,
  367.     OBJ_DblBevelOut,
  368.  
  369.     /* other object types */
  370.     OBJ_Screen,            /* screen information */
  371.     OBJ_Window,            /* window information */
  372.     OBJ_Group,            /* group information */
  373.     OBJ_VFill,            /* Vertical fill */
  374.     OBJ_HFill,            /* Horizontal fill */
  375.  
  376.     OBJ_LAST
  377. };
  378.  
  379. /* Intuition user-interface object (gadget, border, text, etc... Currently
  380.  * the AppShell has stolen the UserData fields of both gadgets and windows.
  381.  * Hopefully the next release of AppShell will give these fields back,
  382.  * or provide a way to use them. */
  383. struct Object
  384. {
  385.     struct Object *o_NextObject;/* next object in array */
  386.     ULONG o_Group;        /* group that object belongs in */
  387.     ULONG o_Type;        /* type */
  388.     ULONG o_ObjectID;        /* ID */
  389.     ULONG o_Flags;        /* see defines below */
  390.     UBYTE o_Key;        /* hotkey */
  391.     UBYTE *o_Name;        /* name */
  392.     ULONG o_LabelID;        /* label index into text catalogue */
  393.     struct Rectangle o_Outer;    /* size w/label */
  394.     struct TagItem *o_Tags;    /* tags for object */
  395.     APTR o_UserData;        /* user data for object */
  396. };
  397.  
  398. /* To indicate that a gadget is used to close a window, set the following
  399.  * flag.  The window is closed after any functions for the gadget have
  400.  * completed. */
  401. #define    APSH_OBJF_CLOSEWINDOW    (1L<<1)
  402.  
  403. /* The following flags are for layout purposes and are currently
  404.  * unimplemented. */
  405. #define    APSH_OBJF_NOSCALE    (1L<<2)    /* Adjust top-left, don't scale */
  406. #define    APSH_OBJF_CENTER    (1L<<3)    /* Center, don't scale */
  407. #define    APSH_OBJF_RELRIGHT    (1L<<4)    /* object is relative to right */
  408. #define    APSH_OBJF_RELBOTTOM    (1L<<5)    /* object is relative to bottom */
  409. #define    APSH_OBJF_RELWIDTH    (1L<<6)    /* object width is relative */
  410. #define    APSH_OBJF_RELHEIGHT    (1L<<7)    /* object height is relative */
  411.  
  412. /*--- KEYBOARD RELATED ITEMS ---*/
  413. #define    SPECIAL 255
  414.  
  415. /* some useful defines */
  416. #define    TAB      9
  417. #define    RETURN  13
  418. #define    ESC    27
  419. #define    DELETE    127
  420. #define    HELP    (SPECIAL+'?')
  421. #define    FUNC1    (SPECIAL+'0')
  422. #define    FUNC2    (SPECIAL+'1')
  423. #define    FUNC3    (SPECIAL+'2')
  424. #define    FUNC4    (SPECIAL+'3')
  425. #define    FUNC5    (SPECIAL+'4')
  426. #define    FUNC6    (SPECIAL+'5')
  427. #define    FUNC7    (SPECIAL+'6')
  428. #define    FUNC8    (SPECIAL+'7')
  429. #define    FUNC9    (SPECIAL+'8')
  430. #define    FUNC10    (SPECIAL+'9')
  431. #define    UP    (SPECIAL+'A')
  432. #define    DOWN    (SPECIAL+'B')
  433. #define    RIGHT    (SPECIAL+'C')
  434. #define    LEFT    (SPECIAL+'D')
  435.  
  436. /* component for our keyboard command array */
  437. struct KeyboardCMD
  438. {
  439.     ULONG kbc_Key;        /* key */
  440.     ULONG kbc_FuncID;        /* function ID */
  441. };
  442.  
  443. /*--------------------------------------------------------------------------*/
  444. /* Following is information used by the Simple IPC message handler          */
  445. /*--------------------------------------------------------------------------*/
  446.  
  447. #define    APSH_SIPC_ID 10000L
  448.  
  449. /* This structure is used by the AppShell to communicate with tools and
  450.  * other AppShell applications.
  451.  *
  452.  * If sipc_DType equal NULL, then the function ID in sipc_Type is performed
  453.  * with no arguments.
  454.  *
  455.  *    PerfFunc (ai, sipc_Type, NULL, NULL);
  456.  *
  457.  * If sipc_DType equal APSH_SDT_TagList, then the function ID in sipc_Type is
  458.  * performed with sipc_Data as the tag list arguments.
  459.  *
  460.  *    PerfFunc (ai, sipc_Type, NULL, sipc_Data);
  461.  *
  462.  * If sipc_DType equal APSH_SDT_Data, then the function ID in sipc_Type is
  463.  * performed with with the following tags as arguments:
  464.  *
  465.  *    APSH_SIPCData,       sipc_Data
  466.  *    APSH_SIPCDataLength, sipc_DSize
  467.  *
  468.  * If sipc_DType equal APSH_SDT_Command, then the string command line
  469.  * passed in the sipc_Data field is performed:
  470.  *
  471.  *    PerfFunc (ai, NULL, sipc_Data, NULL);
  472.  *
  473.  */
  474. struct SIPCMessage
  475. {
  476.     struct Message sipc_Msg;    /* Embedded Exec message structure */
  477.     ULONG sipc_Type;        /* Type of message */
  478.     APTR sipc_Data;        /* Pointer to message data */
  479.     ULONG sipc_DSize;        /* Size of message data */
  480.     ULONG sipc_DType;        /* Type of message data */
  481.     ULONG sipc_Pri_Ret;        /* Primary return value */
  482.     ULONG sipc_Sec_Ret;        /* Secondary return value */
  483.     APTR sipc_Extens1;        /* *** PRIVATE *** SYSTEM USE ONLY! */
  484.     APTR sipc_Extens2;        /* *** PRIVATE *** SYSTEM USE ONLY! */
  485. };
  486.  
  487. /* These flags are used in the sipc_DType field to indicate what type of
  488.  * information is in the sipc_Data field. */
  489. #define    APSH_SDT_Command (1L<<1)/* Data is a STRPTR */
  490. #define    APSH_SDT_TagList (1L<<2)/* Data is a list of TagItem's */
  491. #define    APSH_SDT_Data    (1L<<3)/* Data is a pointer to a data block */
  492. #define    APSH_SDT_Text    (1L<<4)/* text transmissions via sprintf */
  493.  
  494. /* Public SIPC port name given to the AppShell remote debugger.  Accessed
  495.  * using OpenSIPC, SIPCPrintf and CloseSIPC. */
  496. #define    DEBUGGER "AppShell_Debugger"
  497.  
  498. /*--------------------------------------------------------------------------*/
  499. /* Following is information used by the Tool message handler                */
  500. /*--------------------------------------------------------------------------*/
  501.  
  502. #define    APSH_TOOL_ID 11000L
  503.  
  504. typedef VOID (*F_PTR)(APTR, struct MsgPort *);
  505.  
  506. #define    TOOL_ACTIVATE (1L<<1)
  507. #define    TOOL_LIB_PORT "public_tool_librarian"
  508.  
  509. /* structure for tool table entry */
  510. struct Tools
  511. {
  512.     struct Node te_Node;    /* Node for tool entry */
  513.     VOID (*te_Func)(VOID *);    /* Address of function */
  514.     ULONG te_ID;        /* ID of function */
  515.     ULONG te_Flags;        /* Status of function */
  516.     ULONG te_HitCnt;        /* Access count */
  517.     ULONG te_Stack;        /* Stack requirements for function */
  518.     ULONG te_Pri;        /* Default priority for function */
  519.     ULONG te_UseCnt;        /* Current use count of function */
  520.     ULONG te_MaxCnt;        /* Maximum instances of function */
  521.     UBYTE *te_Port;        /* Port name of owner */
  522. };
  523.  
  524. /* tool functions */
  525. enum
  526. {
  527.     TOOL_Dummy = APSH_TOOL_ID,
  528.     LIB_AddEntry,        /* add an entry */
  529.     LIB_EditEntry,        /* edit an entry */
  530.     LIB_DelEntry,        /* delete an entry */
  531.     LIB_InqEntry,        /* inquire entry */
  532.     LIB_IncEntry,        /* increment use count of entry */
  533.     LIB_DecEntry,        /* decrement use count of entry */
  534.     LIB_RunEntry,        /* start a process */
  535.     LIB_DispTable,        /* DEBUG: display table via kprintf */
  536.  
  537.     StartupMsgID,        /* Startup message */
  538.     ActivateToolID,        /* Activate tool */
  539.     ShutdownToolID,        /* Shutdown tool */
  540.     ShutdownMsgID,        /* Shutdown message */
  541. };
  542.  
  543. /*--------------------------------------------------------------------------*/
  544. /* Following is information used by the Workbench message handler           */
  545. /*--------------------------------------------------------------------------*/
  546.  
  547. #define    APSH_WB_ID 12000L
  548.  
  549. /* APSH_CmdFlags */
  550. #define    APSH_WBF_DISPLAY (1L<<1)    /* maintain display box for icon */
  551. #define    APSH_WBF_PROJLIST (1L<<2)    /* add the WBArgs to the project list */
  552. #define    APSH_WBF_NOLIST (1L<<3)        /* don't add the WBArgs to a list */
  553.  
  554. /*--------------------------------------------------------------------------*/
  555. /* Following is information for use by the Application                      */
  556. /*--------------------------------------------------------------------------*/
  557.  
  558. /* base tag for application functions */
  559. #define    APSH_USER_ID 100000L
  560.  
  561.  
  562. /*--------------------------------------------------------------------------*/
  563. /* Following is low-level message handler information                       */
  564. /*--------------------------------------------------------------------------*/
  565.  
  566. /* message handler object node */
  567. struct MHObject
  568. {
  569.     struct Node mho_Node;    /* embedded Exec node */
  570.     struct List mho_ObjList;    /* embedded List of children objects */
  571.     struct MHObject *mho_Parent;/* pointer to parent object */
  572.     struct MHObject *mho_CurNode;/* pointer to current child object */
  573.     ULONG mho_ID;        /* numeric ID of object */
  574.     ULONG mho_Status;        /* status of object */
  575.     APTR mho_SysData;        /* message handler data */
  576.     APTR mho_UserData;        /* application data */
  577.     APTR mho_Extens1;        /* *** PRIVATE *** */
  578.     UBYTE mho_Name[1];        /* name of object */
  579. };
  580.  
  581. /* message handler node */
  582. struct MsgHandler
  583. {
  584.     struct MHObject mh_Header;    /* embedded MHObject structure */
  585.  
  586.     struct MsgPort *mh_Port;    /* message port for handler */
  587.     STRPTR mh_PortName;        /* port name, if public */
  588.     ULONG mh_SigBits;        /* signal bits to watch for */
  589.  
  590.     /* handler functions */
  591.     WORD mh_NumFuncs;        /* number of functions in handler */
  592.     BOOL (**mh_Func)(struct AppInfo *,struct MsgHandler *,struct TagItem *);
  593.  
  594.     STRPTR *mh_DefText;        /* Default text catalogue */
  595.     APTR mh_Catalogue;        /* *** PRIVATE *** */
  596.  
  597.     APTR mh_Extens1;        /* *** PRIVATE *** */
  598.     APTR mh_Extens2;        /* *** PRIVATE *** */
  599. };
  600.  
  601. /*--- interface function array pointers ---*/
  602. /* make a message handler active */
  603. #define    MH_OPEN        0
  604. /* handle messages */
  605. #define    MH_HANDLE    1
  606. /* make a message handler inactive */
  607. #define    MH_CLOSE    2
  608. /* free resources and delete message handler */
  609. #define    MH_SHUTDOWN    3
  610.  
  611. /*--- node types ---*/
  612. /* message handler node */
  613. #define    MH_HANDLER_T    100
  614. /* data node */
  615. #define    MH_DATA_T    101
  616.  
  617. /*--- message handler object types */
  618. #define    MHO_WINDOW    110        /* Intuition window */
  619. #define    MHO_INTOBJ    111        /* AppShell Intuition object */
  620. #define    MHO_TOOL    120        /* Tool */
  621.  
  622. /*--- node priorities ---*/
  623. /* message handler node default priority */
  624. #define    MH_HANDLER_P    10
  625. /* data node default priority */
  626. #define    MH_DATA_P    -10
  627.  
  628. /*--- message handler status ---*/
  629. #define    MHS_OPEN    0x0001
  630. #define    MHS_CLOSE    0x0002
  631. #define    MHS_ENABLED    0x0004
  632. #define    MHS_DISABLED    0x0008
  633.  
  634. /*--- overall status ---*/
  635. #define    P_ACTIVE    0x0001
  636. #define    P_INACTIVE    0x0002
  637. #define    P_SINGLE    0x0010
  638. #define    P_MULTIPLE    0x0020
  639. #define    REQUIRED TRUE
  640. #define OPTIONAL FALSE
  641.  
  642. /*--------------------------------------------------------------------------*/
  643. /* The AppShell uses the following tags.  Reserved TAG_USER+24000L - 25999L */
  644. /*--------------------------------------------------------------------------*/
  645.  
  646. /* Tags */
  647. #define    APSH_Dummy        TAG_USER+24000L
  648.  
  649. /* library management */
  650. #define    APSH_OpenLibraries    (APSH_Dummy+1L)        /* open libraries */
  651. #define    APSH_LibNameTag        (APSH_Dummy+2L)        /* library name tag */
  652. #define    APSH_LibName        (APSH_Dummy+3L)        /* library name */
  653. #define    APSH_LibVersion        (APSH_Dummy+4L)        /* library version */
  654. #define    APSH_LibStatus        (APSH_Dummy+5L)        /* required/optional */
  655. #define    APSH_LibReserved5    (APSH_Dummy+10L)    /* RESERVED FOR SYSTEM USE */
  656. #define    APSH_LibBase        (APSH_Dummy+11L)    /* library base */
  657. #define    APSH_ARexxSys        (APSH_Dummy+12L)    /* rexxsyslib.library */
  658. #define    APSH_ARexxSup        (APSH_Dummy+13L)    /* rexxsupport.library */
  659. #define    APSH_ASL        (APSH_Dummy+14L)    /* asl.library */
  660. #define    APSH_Commodities    (APSH_Dummy+15L)    /* commodities.library */
  661. #define    APSH_DiskFont        (APSH_Dummy+16L)    /* diskfont.library */
  662. #define    APSH_DOS        (APSH_Dummy+17L)    /* dos.library */
  663. #define    APSH_GadTools        (APSH_Dummy+18L)    /* gadtools.library */
  664. #define    APSH_Gfx        (APSH_Dummy+19L)    /* graphics.library */
  665. #define    APSH_Icon        (APSH_Dummy+20L)    /* icon.library */
  666. #define    APSH_Intuition        (APSH_Dummy+21L)    /* intuition.library */
  667. #define    APSH_Layers        (APSH_Dummy+22L)    /* layers.library */
  668. #define    APSH_IFF        (APSH_Dummy+23L)    /* iffparse.library */
  669. #define    APSH_Translate        (APSH_Dummy+24L)    /* translator.library */
  670. #define    APSH_Utility        (APSH_Dummy+25L)    /* utility.library */
  671. #define    APSH_Workbench        (APSH_Dummy+26L)    /* workbench.library */
  672.  
  673. /* main AppShell tags */
  674. #define    APSH_NumArgs        (APSH_Dummy+40L)    /* Number of Shell arguments */
  675. #define    APSH_ArgList        (APSH_Dummy+41L)    /* Shell arguments */
  676. #define    APSH_WBStartup        (APSH_Dummy+42L)    /* Workbench arguments */
  677. #define    APSH_ControlPort    (APSH_Dummy+43L)    /* SIPC Control port for a cloned AppShell */
  678. #define    APSH_AppName        (APSH_Dummy+44L)    /* pointer to the application's name */
  679. #define    APSH_AppVersion        (APSH_Dummy+45L)    /* pointer to the application's version */
  680. #define    APSH_AppCopyright    (APSH_Dummy+46L)    /* pointer to the application's (c) notice */
  681. #define    APSH_AppAuthor        (APSH_Dummy+47L)    /* pointer to the application's author */
  682. #define    APSH_AppMsgTitle    (APSH_Dummy+48L)    /* pointer to message title */
  683. #define    APSH_FuncTable        (APSH_Dummy+55L)    /* function table for application */
  684. #define    APSH_DefText        (APSH_Dummy+56L)    /* Default text catalogue */
  685. #define    APSH_AppInit        (APSH_Dummy+57L)    /* Custom application init function ID */
  686. #define    APSH_AppExit        (APSH_Dummy+58L)    /* Custom application shutdown function ID */
  687. #define    APSH_SIG_C        (APSH_Dummy+59L)    /* SIG_BREAK_C function ID */
  688. #define    APSH_SIG_D        (APSH_Dummy+60L)    /* SIG_BREAK_D function ID */
  689. #define    APSH_SIG_E        (APSH_Dummy+61L)    /* SIG_BREAK_E function ID */
  690. #define    APSH_SIG_F        (APSH_Dummy+62L)    /* SIG_BREAK_F function ID */
  691. #define    APSH_ProjInfo        (APSH_Dummy+63L)    /* pointer to a Project structure */
  692.  
  693. /* message handler routines */
  694. #define    APSH_AddHandler        (APSH_Dummy+80L)    /* add a message handler to application */
  695. #define    APSH_Setup        (APSH_Dummy+81L)    /* setup function */
  696. #define    APSH_Status        (APSH_Dummy+82L)    /* active, inactive, multiple, etc... */
  697. #define    APSH_Rating        (APSH_Dummy+83L)    /* optional/required, etc... */
  698. #define    APSH_Port        (APSH_Dummy+84L)    /* name of the message port */
  699. #define    APSH_Handler        (APSH_Dummy+85L)    /* Handler ID */
  700. #define    APSH_CmdData        (APSH_Dummy+86L)    /* Command data */
  701. #define    APSH_CmdDataLength    (APSH_Dummy+87L)    /* Length of command data */
  702. #define    APSH_CmdID        (APSH_Dummy+88L)    /* Command ID (function) */
  703. #define    APSH_CmdString        (APSH_Dummy+89L)    /* Command string */
  704. #define    APSH_CmdTagList        (APSH_Dummy+90L)    /* Command tag list */
  705. #define    APSH_Command        (APSH_Dummy+91L)    /* Handler command */
  706. #define    APSH_NameTag        (APSH_Dummy+92L)    /* Name Tag for object */
  707. #define    APSH_CmdFlags        (APSH_Dummy+93L)    /* Command Flags */
  708. #define    APSH_TextID        (APSH_Dummy+94L)    /* Text ID */
  709. #define    APSH_BaseID        (APSH_Dummy+95L)    /* Base ID */
  710.  
  711. /* ARexx information */
  712. #define    APSH_Extens        (APSH_Dummy+120L)    /* ARexx macro name extension */
  713. #define    APSH_ARexxError        (APSH_Dummy+121L)    /* ARexx command ERROR function ID */
  714. #define    APSH_ARexxOK        (APSH_Dummy+122L)    /* ARexx command OK function ID */
  715.  
  716. /* command shell */
  717. #define    APSH_CloseMsg        (APSH_Dummy+140L)    /* Closing message */
  718. #define    APSH_CMDWindow        (APSH_Dummy+141L)    /* Command window spec */
  719. #define    APSH_Prompt        (APSH_Dummy+142L)    /* Command window prompt */
  720.  
  721. /* window information */
  722. #define    APSH_WindowEnv        (APSH_Dummy+160L)    /* Window Environment */
  723. #define    APSH_TextAttr        (APSH_Dummy+161L)    /* Text Attributes */
  724. #define    APSH_NewScreen        (APSH_Dummy+162L)    /* NewScreen structure */
  725. #define    APSH_NewScreenTags    (APSH_Dummy+163L)    /* Tags for new screen */
  726. #define    APSH_Palette        (APSH_Dummy+164L)    /* Color Palette */
  727. #define    APSH_NewWindow        (APSH_Dummy+165L)    /* NewWindow structure */
  728. #define    APSH_NewWindowTags    (APSH_Dummy+166L)    /* Tags for new window */
  729. #define    APSH_HotKeys        (APSH_Dummy+167L)    /* HotKey command array */
  730. #define    APSH_Menu        (APSH_Dummy+168L)    /* Intuition-style Menu array */
  731. #define    APSH_Gadgets        (APSH_Dummy+169L)    /* Intuition-style Gadget array */
  732. #define    APSH_GTMenu        (APSH_Dummy+170L)    /* GadTools-style Menu array */
  733. #define    APSH_GTGadgets        (APSH_Dummy+171L)    /* GadTools-style NewGadget array */
  734. #define    APSH_GTFlags        (APSH_Dummy+172L)    /* flags for GadTools objects */
  735. #define    APSH_Objects        (APSH_Dummy+173L)    /* Object array */
  736. #define    APSH_ObjDown        (APSH_Dummy+174L)    /* Gadget downpress function ID */
  737. #define    APSH_ObjHold        (APSH_Dummy+175L)    /* Gadget hold function ID */
  738. #define    APSH_ObjRelease        (APSH_Dummy+176L)    /* Gadget release function ID */
  739. #define    APSH_ObjDblClick    (APSH_Dummy+177L)    /* Gadget double-click function ID */
  740. #define    APSH_ObjAbort        (APSH_Dummy+178L)    /* Gadget abort function ID */
  741. #define    APSH_ObjAltHit        (APSH_Dummy+179L)    /* Gadget ALT hit function ID */
  742. #define    APSH_ObjShiftHit    (APSH_Dummy+180L)    /* Gadget SHIFT hit function ID */
  743. #define    APSH_ObjData        (APSH_Dummy+181L)    /* Gadget image or data */
  744. #define    APSH_ObjInner        (APSH_Dummy+182L)    /* Inner rectangle */
  745. #define    APSH_ObjPointer        (APSH_Dummy+183L)    /* pointer name prefix */
  746. #define    APSH_DefWinFlags    (APSH_Dummy+184L)    /* Default window flags */
  747. #define    APSH_ObjName        (APSH_Dummy+185L)    /* Object name */
  748. #define    APSH_WinName        (APSH_Dummy+186L)    /* Window name */
  749. #define    APSH_WinPointer        (APSH_Dummy+188L)    /* pointer to window */
  750.  
  751. /* IDCMP messages */
  752. #define    APSH_SizeVerify        (APSH_Dummy+220L)    /* SIZEVERIFY function ID */
  753. #define    APSH_NewSize        (APSH_Dummy+221L)    /* NEWSIZE function ID */
  754. #define    APSH_RefreshWindow    (APSH_Dummy+222L)    /* REFRESHWINDOW function ID */
  755. #define    APSH_MouseButtons    (APSH_Dummy+223L)    /* MOUSEBUTTONS function ID */
  756. #define    APSH_ReqSet        (APSH_Dummy+224L)    /* REQSET function ID */
  757. #define    APSH_CloseWindow    (APSH_Dummy+225L)    /* CLOSEWINDOW  function ID */
  758. #define    APSH_ReqVerify        (APSH_Dummy+226L)    /* REQVERIFY function ID */
  759. #define    APSH_ReqClear        (APSH_Dummy+227L)    /* REQCLEAR function ID */
  760. #define    APSH_MenuVerify        (APSH_Dummy+228L)    /* MENUVERIFY function ID */
  761. #define    APSH_DiskInserted    (APSH_Dummy+229L)    /* DISKINSERTED function ID */
  762. #define    APSH_DiskRemoved    (APSH_Dummy+230L)    /* DISKREMOVED function ID */
  763. #define    APSH_ActiveWindow    (APSH_Dummy+231L)    /* ACTIVEWINDOW function ID */
  764. #define    APSH_InactiveWindow    (APSH_Dummy+232L)    /* INACTIVEWINDOW function ID */
  765.  
  766. /* real or simulated IntuiMessage fields */
  767. #define    APSH_MsgClass        (APSH_Dummy+260L)    /* message class */
  768. #define    APSH_MsgCode        (APSH_Dummy+261L)    /* message code */
  769. #define    APSH_MsgQualifier    (APSH_Dummy+262L)    /* message qualifier */
  770. #define    APSH_MsgIAddress    (APSH_Dummy+263L)    /* item address */
  771. #define    APSH_MsgMouseX        (APSH_Dummy+264L)    /* mouse X coordinate */
  772. #define    APSH_MsgMouseY        (APSH_Dummy+265L)    /* mouse Y coordinate */
  773. #define    APSH_MsgSeconds        (APSH_Dummy+266L)    /* seconds */
  774. #define    APSH_MsgMicros        (APSH_Dummy+267L)    /* micros */
  775. #define    APSH_MsgWindow        (APSH_Dummy+268L)    /* window for event */
  776.  
  777. /* SIPC message */
  778. #define    APSH_SIPCData        (APSH_Dummy+300L)    /* Pointer the data passed by a SIPC message */
  779. #define    APSH_SIPCDataLength    (APSH_Dummy+301L)    /* Length of the SIPC data */
  780.  
  781. /* standard tool information */
  782. #define    APSH_Tool        (APSH_Dummy+320L)    /* Name of tool */
  783. #define    APSH_ToolAddr        (APSH_Dummy+321L)    /* Address of tool */
  784. #define    APSH_ToolData        (APSH_Dummy+322L)    /* Data for tool */
  785. #define    APSH_ToolStack        (APSH_Dummy+323L)    /* Stack requirements of tool */
  786. #define    APSH_ToolPri        (APSH_Dummy+324L)    /* Priority of tool */
  787.  
  788. /* Workbench tags */
  789. #define    APSH_AppWindowEnv    (APSH_Dummy+400L)    /* AppWindow information */
  790. #define    APSH_AppIconEnv        (APSH_Dummy+401L)    /* AppIcon information */
  791. #define    APSH_AppMenuEnv        (APSH_Dummy+402L)    /* AppMenuItem information */
  792. #define    APSH_WBArg        (APSH_Dummy+420L)    /* pointer to WBArg */
  793.  
  794. /* Workbench tags for function ID's */
  795. #define    APSH_AppOpen        (APSH_Dummy+403L)    /* After App... is added */
  796. #define    APSH_AppBDrop        (APSH_Dummy+404L)    /* Before icons are processed */
  797. #define    APSH_AppDDrop        (APSH_Dummy+405L)    /* For each icon in the list */
  798. #define    APSH_AppADrop        (APSH_Dummy+406L)    /* After icons added to project list */
  799. #define    APSH_AppClose        (APSH_Dummy+407L)    /* Before App... closed */
  800. #define    APSH_AppRemove        (APSH_Dummy+408L)    /* Before App... deleted */
  801. #define    APSH_AppDblClick    (APSH_Dummy+409L)    /* When icon double-clicked */
  802.  
  803. #define    APSH_NEXT_TAG        (APSH_Dummy+500L)    /* remember... */
  804.  
  805. /*--------------------------------------------------------------------------*/
  806. /* Following are ID's to use to access the AppShell text table              */
  807. /*--------------------------------------------------------------------------*/
  808. enum
  809. {
  810.     APSH_PAD = 0,
  811.     APSH_NOT_AN_ICON,        /* %s is not an icon. */
  812.     APSH_NOT_AVAILABLE,        /* %s is not available */
  813.     APSH_PORT_ACTIVE,        /* %s port already active */
  814.     APSH_PORT_X_ACTIVE,        /* port, %s, already active */
  815.     APSH_NOT_AN_IFF,        /* %s is not an IFF file */
  816.     APSH_NOT_AN_IFF_X,        /* %1$s is not an IFF %2$s file */
  817.     APSH_CLOSE_ALL_WINDOWS,    /* Close all windows */
  818.     APSH_CMDSHELL_PROMPT,    /* Cmd> */
  819.     APSH_CLDNT_CREATE_X,    /* Could not create %s */
  820.     APSH_CLDNT_CREATE_PORT,    /* Could not create port, %s */
  821.     APSH_CLDNT_CREATE_OBJ,    /* Could not create object */
  822.     APSH_CLDNT_CREATE_OBJ_X,    /* Could not create object, %s */
  823.     APSH_CLDNT_CREATE_FILE,    /* Could not create file */
  824.     APSH_CLDNT_CREATE_FILE_X,    /* Could not create file, %s */
  825.     APSH_CLDNT_INIT_X,        /* Could not initialize %s */
  826.     APSH_CLDNT_INIT_MSGH,    /* Could not initialize %s message handler */
  827.     APSH_CLDNT_LOCK,        /* Could not lock %s */
  828.     APSH_CLDNT_LOCK_DIR,    /* Could not lock directory */
  829.     APSH_CLDNT_LOCK_DIR_X,    /* Could not lock directory, %s */
  830.     APSH_CLDNT_LOCK_PUB,    /* Could not lock public screen */
  831.     APSH_CLDNT_LOCK_PUB_X,    /* Could not lock public screen, %s */
  832.     APSH_CLDNT_OBTAIN,        /* Could not obtain %s */
  833.     APSH_CLDNT_OPEN,        /* Could not open %s */
  834.     APSH_CLDNT_OPEN_FILE,    /* Could not open file */
  835.     APSH_CLDNT_OPEN_FILE_X,    /* Could not open file, %s */
  836.     APSH_CLDNT_OPEN_FONT_X,    /* Could not open font, %s */
  837.     APSH_CLDNT_OPEN_MACRO,    /* Could not open macro file, %s */
  838.     APSH_CLDNT_OPEN_PREF,    /* Could not open preference file, %s */
  839.     APSH_CLDNT_OPEN_SCREEN,    /* Could not open screen */
  840.     APSH_CLDNT_OPEN_WINDOW,    /* Could not open window */
  841.     APSH_SETUP_TIMER,        /* Could not set up timer event */
  842.     APSH_SETUP_HOTKEYS,        /* Could not set up HotKeys */
  843.     APSH_START_PROCESS,        /* Could not start process */
  844.     APSH_START_TOOL,        /* Could not start tool */
  845.     APSH_START_TOOL_X,        /* Could not start tool, %s */
  846.     APSH_WRITE_FILE,        /* Could not write to file */
  847.     APSH_WRITE_FILE_X,        /* Could not write to file, %s */
  848.     APSH_WRITE_MACRO,        /* Could not write to macro file */
  849.     APSH_CMDSHELL_WIN,        /* CON:0/150/600/50/Command Shell/CLOSE */
  850.     APSH_NO_NAMETAG_WIN,    /* No name given for window */
  851.     APSH_NO_PORT,        /* No port name specified */
  852.     APSH_NOT_ENOUGH_MEMORY,    /* Not enough memory */
  853.     APSH_WAITING_FOR_MACRO,    /* Waiting for macro return */
  854.     APSH_DISABLED,        /* %s is disabled */
  855.     APSH_IOERR,            /* IoErr #%ld */
  856.     APSH_INVALID_NAMETAG,    /* Invalid name tag. */
  857.     APSH_OKAY_TXT,        /* Okay */
  858.     APSH_CANCEL_TXT,        /* Cancel */
  859.     APSH_CONTINUE_TXT,        /* Continue */
  860.     APSH_DONE_TXT,        /* Done */
  861.     APSH_ABORT_TXT,        /* Abort */
  862.     APSH_QUIT_TXT,        /* Quit */
  863.     APSH_UNNAMED,        /* Unnamed */
  864.     APSH_LAST_MESSAGE
  865. };
  866.