home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / IDEHOOK.PAK / IDEHOOK.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  34KB  |  920 lines

  1. //----------------------------------------------------------------------------
  2. // IdeHook - (C) Copyright 1994 by Borland International
  3. //----------------------------------------------------------------------------
  4.  
  5. ///////////////////////////////////////////////////////////////////////
  6. //  IdeHook can be used to customize and enhance the functionality
  7. //  of the Borland C++ Integrated Development Environment.
  8. ///////////////////////////////////////////////////////////////////////
  9.  
  10. ///////////////////////////////////////////////////////////////////////
  11. //  FEATURE OVERVIEW:
  12. ///////////////////////////////////////////////////////////////////////
  13. //
  14. //  With IdeHook.h (and the accompanying .obj file) users can
  15. //  incorporate many powerful features seamlessly into the IDE.
  16. //  For example:
  17. //      1) Install tools onto the 'Tools' menu
  18. //      2) Install tools onto the SpeedMenu of specific node types
  19. //      3) Provide an implementation of tools through call-backs into a .DLL
  20. //      4) Monitor IDE events (such as Project Open and Close) and
  21. //          perform customized actions on these events
  22. //
  23. //  IdeHook gives users access to the following areas of the IDE:
  24. //
  25. //  1)  Tool Server      Lets you install, query and invoke
  26. //                          any tool in the IDE.
  27. //  2)  Project Manager  Gives you full access to the dependency tree
  28. //                          of the currently open project, including the
  29. //                          ability to add new nodes, query the tree, and
  30. //                          get and set persistent properties in the project.
  31. //  3)  TargetExpert     Allows callers to create and query targets
  32. //                          on any platform.
  33. //  4)  StyleSheets      Gives access to the setting and getting of
  34. //                          options on any node in the project tree.
  35. //  5)  Make             Gives access to the make engine, including
  36. //                          make notifications.
  37. //
  38. ///////////////////////////////////////////////////////////////////////
  39. //  HOW TO USE IDEHOOK:
  40. ///////////////////////////////////////////////////////////////////////
  41. //
  42. //  IdeHook is easy to use:
  43. //
  44. //      1)  Create one or more .CPP modules that include a customized
  45. //             version IDEHOOK.H to perform your specific functionality.
  46. //      2)  Create a .DLL module using you own modules and the IDEHOOK.OBJ
  47. //             file provided with IDEHOOK.
  48. //      3)  In the end-users Windows directory, modify BCW.INI to
  49. //             add the following section and key-value(s):
  50. //                [AddOns]
  51. //                addon000=<yourdll.dll>
  52. //          In this section, <yourdll.dll> is the name of the .DLL you
  53. //          created in Step 2 of this procedure.
  54. //
  55. //  There are a few examples included to help you get on your way.
  56. //
  57. ///////////////////////////////////////////////////////////////////////
  58. //  TIPS AND CAVEATS
  59. ///////////////////////////////////////////////////////////////////////
  60. //
  61. //  It is important to remember some things when using IdeHook:
  62. //
  63. //  1)  You can use the IDE to make your addon (the examples were
  64. //      done that way). However, you must modify your BCW.INI whenever
  65. //      you test the addon. Because of this, you must remember to
  66. //      *remove* the addon item when you are not testing.
  67. //
  68. //  2)  To debug your addon, you must use the standalone debugger (TDW.EXE)
  69. //      on BCW.EXE, then load your addon into the debugger using the 'name'
  70. //      field in the Load Modules dialog box (press F3 in TDW).
  71. //
  72. //  3)  Link order is *very* important when making the .DLL. Always
  73. //      use the following order:
  74. //          <yourLibMainModule>
  75. //          idehook.obj
  76. //          <your modules...>
  77. //
  78. //  4)  If you GP the IDE, the IDE will *not* unload your .DLL. You
  79. //      must either use a .DLL unloader program or restart Windows.
  80. //
  81. //  5)  The IDE expects the key/value pairs of the [addons] section of
  82. //      BCW.INI to be in numeric sequential order. It important that you
  83. //      respect other addon vendors in this regard. For example, by the
  84. //      time your addon is installed at an end-user sight, there might be
  85. //      several addons already installed; BCW.INI might have the following:
  86. //          [AddOns]
  87. //          addon000=somedll.dll
  88. //          addon001=another.dll
  89. //          addon002=evenmore.dll
  90. //      It is *your* responsibility to install your addon at the end of
  91. //      this list (as 'addon003'). It is even more important to keep the
  92. //      addons sequential when you uninstall your addon. If there have
  93. //      been other addons installed after yours, you must decrement the
  94. //      numbers back to maintain a non-interrupted numeric sequence.
  95. //
  96. ///////////////////////////////////////////////////////////////////////
  97. #ifndef __IDEHOOK_H
  98. #define __IDEHOOK_H
  99.  
  100. #ifndef __IDEHOOKT_H
  101. #  include "idehookt.h"
  102. #endif
  103.  
  104. ///////////////////////////////////////////////////////////////////////
  105. //  CLIENTS AND SERVERS
  106. ///////////////////////////////////////////////////////////////////////
  107. //
  108. //  The IDE is built on an API exchange architecture. The APIs are
  109. //  well defined and understood by all parties; the implementors
  110. //  of these APIs are responsible for registering themselves as
  111. //  such and servicing requests for the given API.
  112. //
  113. //  IdeHook exposes serveral IDE servers:
  114. //
  115. //      ToolServer
  116. //      ProjectServer
  117. //      TargetExpert
  118. //      OptionSetServer
  119. //      MakeServer
  120. //
  121. //  In order to gain access to these servers, each one comes with a
  122. //  'requestor' that implements the proper request and release sequence:
  123. //
  124. //      Server                  Requestor
  125. //      ----------------        ------------------
  126. //      ToolServer              ToolReq
  127. //      ProjectServer           ProjectReq
  128. //      TargetExpert            TargetExpertReq
  129. //      OptionSetServer         OptionSetReq
  130. //      MakeServer              MakeReq
  131. //
  132. //  To get a service, just instantiate its requestor:
  133. //
  134. //      {
  135. //          ToolReq     toolServer;         // This gets a ToolServer
  136. //
  137. //          toolServer->ToolInvoke( ... );  // Call the server
  138. //
  139. //      }                                   // Release the tool server
  140. //
  141. //
  142. //  NOTE: Some servers provide a 'client' class which you must implement
  143. //  and register with the server in order to get call backs for event
  144. //  notifications, tool invocations, or query responders.
  145. //
  146. ////////////////////////////////////////////////////////////////////////////
  147.  
  148.  
  149. //////////////////////////////////////////////////////////////////
  150. //                                                              //
  151. //      TOOL CLIENT/SERVER                                      //
  152. //                                                              //
  153. //////////////////////////////////////////////////////////////////
  154.  
  155. //
  156. //  ToolClient
  157. //
  158. //    Use this class as a shell for your implementation of tool call-backs.
  159. //
  160. class _HOOKCLASS ToolClient
  161. {
  162.  
  163. };
  164.  
  165. //
  166. //  ToolServer
  167. //
  168. //      This is the IDE's tool server, use it to query, add, remove,
  169. //      and invoke any tool in the IDE.
  170. //
  171. //      There are two types of tool installing:
  172. //
  173. //          1)  'Installing' a tool into the user's project. Tools
  174. //              installed in this manner appear on either the IDE Tool
  175. //              menu or on the SpeedMenu of a specific node type. These
  176. //              tools are implemented as either standalone .EXEs or as
  177. //              call-backs into your addon .DLLs. Tools installed like
  178. //              this are done on a project-by-project basis.
  179. //
  180. //          2)  'Registering' the implementor of a call-back style tool that
  181. //              was installed in Step 1). This only needs to be done
  182. //              once per instance of BCW.EXE.
  183. //
  184. class _HOOKCLASS ToolServer
  185. {
  186. public:
  187.  
  188.     //
  189.     //  Register one or many tool call-back implementors
  190.     //
  191.     virtual void     _HOOKEP    ToolRegisterImplementor
  192.                                 (
  193.                                     ToolClient *,
  194.                                     ToolRegisterPack *
  195.                                 ) = 0;
  196.  
  197.     //
  198.     //  Install a tool into the user's project
  199.     //
  200.     virtual ToolObj    _HOOKEP    ToolAdd
  201.                                 (
  202.                                     ToolInfo *
  203.                                 ) = 0;
  204.  
  205.     //
  206.     //  Query the existance of a tool in the current project
  207.     //
  208.     virtual ToolObj    _HOOKEP    ToolFind
  209.                                 (
  210.                                     const char * name 
  211.                                 ) = 0;
  212.  
  213.     //
  214.     //  Remove a tool from the current project
  215.     //
  216.     virtual void    _HOOKEP    ToolRemove
  217.                                 (
  218.                                     const char * name
  219.                                 ) = 0;
  220.  
  221.     //
  222.     //  Query the detailed information of a tool
  223.     //
  224.     virtual void    _HOOKEP    QueryToolInfo
  225.                                 ( 
  226.                                     ToolObj,
  227.                                     ToolInfo &
  228.                                  ) = 0;
  229.  
  230.     //                                                              //
  231.     //  Invoke any tool in the IDE. If 'ProjectNode' is zero, the   //
  232.     //  tool is invoked on the 'currently selected object' in the   //
  233.     //  IDE, as determined by the IDE.                              //
  234.     //                                                              //
  235.      virtual ToolReturn _HOOKEP    ToolInvoke
  236.                                 (
  237.                                     ToolObj,
  238.                                     ProjectNode = 0,
  239.                                     const char * cmdLineOverride = 0
  240.                                 ) = 0;
  241.  
  242.     virtual ToolReturn _HOOKEP    ToolInvoke
  243.                                 (
  244.                                     ToolObj,
  245.                                     const char * edName,
  246.                                     const char * cmdLineOverride = 0
  247.                                 ) = 0;
  248.  
  249. };
  250.  
  251.  
  252. //////////////////////////////////////////////////////////////////
  253. //                                                              //
  254. //      PROJECT SERVER/CLIENT                                   //
  255. //                                                              //
  256. //////////////////////////////////////////////////////////////////
  257.  
  258. //
  259. //  ProjectClient
  260. //
  261. //      Client class for notification of project events and
  262. //      query call-backs.
  263. //
  264. //      For example, if you wish to get notified of every
  265. //      Project Open event, derive and implement this class,
  266. //      then register by calling the method
  267. //      ProjectServer::RegisterProjectClient.
  268. //
  269.  
  270. class _HOOKCLASS ProjectClient
  271. {
  272. public:
  273.  
  274.     //
  275.     //  Project Open notify event: This is called every time
  276.     //  a user successfully opens a project.
  277.     //
  278.     virtual void _HOOKEP   OpenNotify
  279.                                     (
  280.                                         const char * name 
  281.                                     ) = 0;
  282.     
  283.     //
  284.     //  Project Close notify event: This is called every time
  285.     //  a user closes a project (either explicitly using
  286.     //  Project|Close Project, or by opening another project).
  287.     //
  288.     virtual void _HOOKEP   CloseNotify() = 0;
  289.  
  290.     //
  291.     //  Node delete event: This is called every time the
  292.     //  user explicitly deletes a node.
  293.     //
  294.     virtual void _HOOKEP   NodeDeleteNotify
  295.                                     (
  296.                                         ProjectNode
  297.                                     ) = 0;
  298.  
  299.     //
  300.     //  This is used as a call back to the method
  301.     //  ProjectServer::QueryDependencies.
  302.     //
  303.     virtual void _HOOKEP   DependencyQueryResponder
  304.                                     (
  305.                                         ProjectNode ,
  306.                                         const char * outputName
  307.                                     ) = 0;
  308. };
  309.  
  310.  
  311. //
  312. //  ProjectServer
  313. //
  314. //      Provides access to the current project's dependency tree.
  315. //
  316. //      The 'ProjectNode' cookie passed around in this (and others)
  317. //      is a persistent 32-bit entity across sessions. You can safely
  318. //      store this value in your own supplemental files, then refer to
  319. //      the value during later sessions.
  320. //
  321. class _HOOKCLASS ProjectServer
  322. {
  323. public:
  324.  
  325.     //
  326.     //  Register your implementation of a project client
  327.     //
  328.     virtual void            _HOOKEP    RegisterProjectClient
  329.                             (
  330.                                 ProjectClient *
  331.                             ) = 0;
  332.  
  333.     //
  334.     //  Release your implementation of a project client
  335.     //
  336.     virtual void             _HOOKEP    UnregisterProjectClient
  337.                             (
  338.                                 ProjectClient *
  339.                             ) = 0;
  340.       
  341.     //
  342.     //  Add a node to the project tree. If 'parent' is 0, then the node
  343.     //  is added as a second level node (as a dependent of the [.ide]
  344.     //  node). If 'type' is 0, then 'name' is assumed to be a file name,
  345.     //  and the extension is used as the node type. For example:
  346.     //
  347.     //      To add a file:
  348.     //          NodeAdd( parent, "foo.cpp" );   // OR:
  349.     //          NodeAdd( parent, "foo", ".cpp" );
  350.     //
  351.     //      To add a SourcePool:
  352.     //          NodeAdd( parent, "The Shared Sources", "SourcePool" );
  353.     //
  354.     virtual ProjectNode     _HOOKEP    NodeAdd
  355.                             (
  356.                                 ProjectNode  parent,
  357.                                 const char * name, 
  358.                                 const char * type = 0
  359.                             ) = 0;
  360.  
  361.     //
  362.     //  Find any instance of a node in the tree
  363.     //
  364.     virtual ProjectNode    _HOOKEP    NodeFind
  365.                             (
  366.                                 const char * name 
  367.                             ) = 0;
  368.  
  369.     //
  370.     //  Remove a node and all its dependencies from the tree
  371.     //
  372.     virtual ProjectNode    _HOOKEP    NodeRemove
  373.                             (
  374.                                 ProjectNode 
  375.                             ) = 0;
  376.  
  377.     //
  378.     //  Return the top level [.ide] node from the tree
  379.     //
  380.     virtual ProjectNode    _HOOKEP    QueryTopNode() = 0;
  381.     
  382.     //
  383.     //  Query detailed information about a given node in the tree
  384.     //
  385.     virtual void            _HOOKEP    QueryNodeInfo
  386.                             (
  387.                                 ProjectNode,
  388.                                 ProjectNodeInfo &
  389.                             ) = 0;
  390.  
  391.     //
  392.     //  Query the dependencies of a given node in the tree. (This
  393.     //  method 'collapses' SourcePool nodes by recursing into
  394.     //  them as if they were not there.) This function calls every
  395.     //  dependency found with the ProjectClient::DependencyQueryResponder()
  396.     //  method when it's called with both the 'ProjectNode' and output
  397.     //  location for that node.
  398.     //
  399.     virtual void            _HOOKEP    QueryDependencies
  400.                             (
  401.                                 ProjectNode,
  402.                                 ProjectClient *
  403.                             ) = 0;
  404.  
  405.  
  406.     //
  407.     //  NodePropertySet/Get/Remove lets you create and maintain
  408.     //  persistent named properties on any node in any project. The
  409.     //  'propertyName' field must be unique to every property on a
  410.     //  given node. Because of this, it's recommended you use some
  411.     //  kind of trademark (such as a name or initials) so as to not
  412.     //  conflict with other addon vendors.
  413.     //
  414.     virtual void            _HOOKEP    NodePropertySet
  415.                             (
  416.                                 ProjectNode     node,
  417.                                 const char *    propertyName,
  418.                                 void *          data,
  419.                                 size_t          dataSize
  420.                             ) = 0;
  421.  
  422.     virtual size_t            _HOOKEP    NodePropertyFind
  423.                             (
  424.                                 ProjectNode     node,
  425.                                 const char *    propertyName,
  426.                                 const void * &  data
  427.                             ) = 0;
  428.  
  429.     virtual void            _HOOKEP    NodePropertyRemove
  430.                             (
  431.                                 ProjectNode     node,
  432.                                 const char *    propertyName
  433.                             ) = 0;
  434.  
  435.  
  436.     //
  437.     //  Return the user's currently selected nodes in the project
  438.     //
  439.     virtual int             _HOOKEP    QuerySelectedNodes
  440.                             (
  441.                                 ProjectNode * & nodeArray,
  442.                                 int &           numNodes
  443.                             ) = 0;
  444.  
  445. };
  446.  
  447.  
  448. //////////////////////////////////////////////////////////////////
  449. //                                                              //
  450. //      OPTIONSET SERVER                                        //
  451. //                                                              //
  452. //////////////////////////////////////////////////////////////////
  453.  
  454. //
  455. //  OptionSetServer
  456. //
  457. //      Access certain local overrides on node's project options.
  458. //      The options available are given in an enum in IDEHOOKT.H
  459. //      called OptionsStringIds.
  460. //
  461. class _HOOKCLASS OptionSetServer
  462. {
  463. public:
  464.  
  465.     //
  466.     //  Set the node's local override for the given option
  467.     //
  468.     virtual void   _HOOKEP    OptionApply
  469.                                         ( 
  470.                                             ProjectNode         node,
  471.                                             OptionsStringIds    oid,
  472.                                             const char *        value
  473.                                         ) = 0;
  474.  
  475.     //
  476.     //  Get the node's local override for the given option
  477.     //
  478.     virtual size_t _HOOKEP    OptionGet
  479.                                         ( 
  480.                                             ProjectNode         node,
  481.                                             OptionsStringIds    oid,
  482.                                             const char * &      value
  483.                                         ) = 0;
  484.  
  485.     //
  486.     //  Remove the node's local override for the given option. This
  487.     //  removes *all* local overrides if oid == OID_RemoveAll.
  488.     //
  489.     virtual void   _HOOKEP    OptionRemove
  490.                                         (
  491.                                             ProjectNode         node,
  492.                                             OptionsStringIds    oid
  493.                                         ) = 0;
  494. };
  495.  
  496. //////////////////////////////////////////////////////////////////
  497. //                                                              //
  498. //      TARGET EXPERT                                           //
  499. //                                                              //
  500. //////////////////////////////////////////////////////////////////
  501.  
  502. //
  503. //  TargetExpert
  504. //
  505. //      Allows for adding and querying target nodes in the
  506. //      dependency tree. The TargetExpert expert automatically
  507. //      creates the proper library skeleton and sets the proper
  508. //      options for the given platform, memory model, and so on.
  509. //
  510. class _HOOKCLASS TargetExpert
  511. {
  512. public:
  513.  
  514.     //
  515.     //  Add a target into the project dependency tree
  516.     //
  517.     virtual ProjectNode _HOOKEP    TargetAdd
  518.                                         (
  519.                                             const char *    name,
  520.                                             TargetPlatforms platform,
  521.                                             TargetStdLibs   libs,
  522.                                             TargetModel     image,
  523.                                             ProjectNode     parent = 0,
  524.                                             const char *    type = 0
  525.                                         ) = 0;
  526.  
  527.     //
  528.     //  Query if a ProjectNode is actually a target
  529.     //
  530.     virtual int         _HOOKEP    NodeIsTarget
  531.                                         (
  532.                                             ProjectNode
  533.                                         ) = 0;
  534.  
  535.     //
  536.     //  Climb 'up' the dependency tree and return the node's target
  537.     //
  538.     virtual ProjectNode _HOOKEP    FindNodesTarget
  539.                                         (
  540.                                             ProjectNode
  541.                                         ) = 0;
  542.  
  543.     //
  544.     //  Query whether a given node (target or not) supports the
  545.     //  given platform, libraries and/or image. If any of the
  546.     //  query parameters are 0, then that attribute is not part
  547.     //  of the query. For example:
  548.     //
  549.     //      To see if a node is a Win32 compile:
  550.     //          QuerySupports( node, Win32, 0, 0 );
  551.     //
  552.     //      To see if a node is an OWL node:
  553.     //          QuerySupports( node, 0, OWL, 0 );
  554.     //
  555.     //      To see if a node is a large model Dos overly with BGI:
  556.     //          QuerySupports( node, DosOverlay, BGI, Large );
  557.     //
  558.     virtual int         _HOOKEP    QuerySupports
  559.                                         (
  560.                                             ProjectNode     node,
  561.                                             TargetPlatforms platform,
  562.                                             TargetStdLibs   libs,
  563.                                             TargetModel     image
  564.                                         ) = 0;
  565.     
  566. };
  567.  
  568.  
  569. //////////////////////////////////////////////////////////////////
  570. //                                                              //
  571. //      MAKE                                                    //
  572. //                                                              //
  573. //////////////////////////////////////////////////////////////////
  574.  
  575. class _HOOKCLASS MakeClient
  576. {
  577. public:
  578.     virtual void MakeBeginNotify() = 0;
  579.     virtual void MakeEndNotify()   = 0;
  580. };
  581.  
  582. class _HOOKCLASS MakeServer
  583. {
  584. public:
  585.     virtual void        _HOOKEP    RegisterMakeClient
  586.                                 (
  587.                                     MakeClient *
  588.                                 ) = 0;
  589.  
  590.     virtual void        _HOOKEP    UnRegisterMakeClient
  591.                                 (
  592.                                     MakeClient *
  593.                                 ) = 0;
  594.  
  595.     virtual void        _HOOKEP    MakeNodes
  596.                                 (
  597.                                     MakeMode,
  598.                                     ProjectNode *, 
  599.                                     int numNodes = 1 
  600.                                  ) = 0;
  601.  
  602.     virtual long        _HOOKEP     NodeInputAge
  603.                                 (
  604.                                     ProjectNode
  605.                                 ) = 0;
  606.  
  607.     virtual long        _HOOKEP     NodeOutputAge
  608.                                 (
  609.                                     ProjectNode
  610.                                 ) = 0;
  611.  
  612. };
  613.  
  614.  
  615. //////////////////////////////////////////////////////////////////
  616. //                                                              //
  617. //      EDITOR                                                  //
  618. //                                                              //
  619. //////////////////////////////////////////////////////////////////
  620.  
  621. class _HOOKCLASS EditorServer
  622. {
  623. public:
  624.  
  625.     //
  626.     //  This first section is taken from the BRIEF macro language guide,
  627.     //  where these routines are documented. The few differences from
  628.     //  those semantics are listed here. String manipulation routines
  629.     //  are not listed because the caller may use RTL functions.
  630.     //
  631.  
  632.   virtual int _HOOKEP       beginning_of_line() = 0;
  633.  
  634.   virtual int _HOOKEP       backspace() = 0;
  635.  
  636.   //
  637.   //  This version ignores buffer_name and system
  638.   //
  639.   virtual BufferId _HOOKEP  create_buffer
  640.                                 (
  641.                                     char  * buffer_name,
  642.                                     char  * file_name,
  643.                                     int        system = 0
  644.                                 ) = 0;
  645.  
  646.   virtual int _HOOKEP       delete_block() = 0;
  647.  
  648.     //
  649.     //  Delete a buffer from memory if there are no windows containing
  650.     //  views on the buffer
  651.     //
  652.   virtual int _HOOKEP       delete_buffer
  653.                                 (
  654.                                     BufferId buffer_id
  655.                                 ) = 0;
  656.  
  657.   virtual int _HOOKEP       delete_char
  658.                                 (
  659.                                     int num_to_delete = 1
  660.                                 ) = 0;
  661.  
  662.   virtual void _HOOKEP      delete_line() = 0;
  663.  
  664.   virtual void _HOOKEP      delete_to_eol() = 0;
  665.  
  666.   virtual long _HOOKEP      distance_to_tab() = 0;
  667.  
  668.   virtual int _HOOKEP       down() = 0;
  669.  
  670.   virtual void _HOOKEP      drop_anchor
  671.                                 (
  672.                                     char mark_type = 1
  673.                                 ) = 0;
  674.  
  675.   virtual int _HOOKEP       end_of_buffer() = 0;
  676.  
  677.   virtual int _HOOKEP       end_of_line() = 0;
  678.  
  679.   virtual int _HOOKEP       end_of_window() = 0;
  680.  
  681.   virtual int _HOOKEP       goto_line
  682.                                 (
  683.                                     long line
  684.                                 ) = 0;
  685.  
  686.   virtual int _HOOKEP       goto_old_line
  687.                                 (
  688.                                     long line
  689.                                 ) = 0;
  690.  
  691.   virtual BufferId _HOOKEP inq_buffer
  692.                                 (
  693.                                     char  * fileName = 0
  694.                                 ) = 0;
  695.  
  696.     //
  697.     //  Returns the length of the current line in characters
  698.     //
  699.   virtual int _HOOKEP       inq_line_length() = 0;
  700.  
  701.   virtual int _HOOKEP       inq_modified() = 0;
  702.  
  703.   virtual void _HOOKEP      inq_names
  704.                                 (
  705.                                     char  * full_name = 0,
  706.                                     char  * extension = 0,
  707.                                     char  * buffer_name = 0
  708.                                 ) = 0;
  709.  
  710.   virtual int _HOOKEP       inq_position
  711.                                 (
  712.                                     long  *  line = 0,
  713.                                     long  *  col = 0
  714.                                 ) = 0;
  715.  
  716.   virtual int _HOOKEP       inq_views
  717.                                 (
  718.                                     BufferId buffer_id = 0
  719.                                 ) = 0;
  720.  
  721.     //
  722.     //  Add only the control string
  723.     //
  724.   virtual void _HOOKEP      insert
  725.                                 (
  726.                                     char  * control_string
  727.                                 ) = 0;
  728.  
  729.   virtual int _HOOKEP       left() = 0;
  730.  
  731.   virtual int _HOOKEP       move_abs
  732.                                 (
  733.                                     long line = 0,
  734.                                     long column = 0
  735.                                 ) = 0;
  736.  
  737.   virtual int _HOOKEP       move_rel
  738.                                 (
  739.                                     long num_lines = 0,
  740.                                     long num_columns = 0
  741.                                 ) = 0;
  742.  
  743.   virtual BufferId _HOOKEP  next_buffer
  744.                                 (
  745.                                     int system_too = 0
  746.                                 ) = 0;
  747.  
  748.   virtual int _HOOKEP       next_char
  749.                                 (
  750.                                     int num_chars = 1
  751.                                 ) = 0;
  752.  
  753.   virtual int _HOOKEP       page_down() = 0;
  754.  
  755.   virtual int _HOOKEP       page_up() = 0;
  756.  
  757.   virtual int _HOOKEP       prev_char
  758.                                 (
  759.                                     int num_chars = 1
  760.                                 ) = 0;
  761.  
  762.   virtual void _HOOKEP      raise_anchor() = 0;
  763.  
  764.     //
  765.     //  NOTE: Be sure to call free_string() with the value returned here.
  766.     //
  767.   virtual char * _HOOKEP    read
  768.                                 (
  769.                                     int length = 0
  770.                                 ) = 0;
  771.  
  772.   virtual int _HOOKEP       read_file
  773.                                 (
  774.                                     char  * filename
  775.                                 ) = 0;
  776.  
  777.   virtual void _HOOKEP      refresh() = 0;
  778.  
  779.   virtual int _HOOKEP       right() = 0;
  780.  
  781.   virtual int _HOOKEP       search_back
  782.                                 (
  783.                                     const char* pattern,
  784.                                     int         regex   = 1,
  785.                                     int         caseSen = 1,
  786.                                     int         block   = 0,
  787.                                     long  *     total_length = 0,
  788.                                     int         grep    = 0
  789.                                 ) = 0;
  790.  
  791.   virtual int _HOOKEP       search_fwd
  792.                                 (
  793.                                     const char *    pattern,
  794.                                     int             regex   = 1,
  795.                                     int             caseSen = 1,
  796.                                     int             block   = 0,
  797.                                     long *          total_length = 0,
  798.                                     int             grep    = 0
  799.                                 ) = 0;
  800.  
  801.   virtual BufferId _HOOKEP  set_buffer
  802.                                 (
  803.                                     BufferId buffer_id
  804.                                 ) = 0;
  805.  
  806.   virtual void _HOOKEP      set_top_left
  807.                                 (
  808.                                     long        top_line = 0,
  809.                                     long        left_col = 0,
  810.                                     ViewId      window_id = 0,
  811.                                     long        line = 0,
  812.                                     long        col = 0,
  813.                                     BufferId    buffer_id = 0
  814.                                 ) = 0;
  815.  
  816.   virtual int _HOOKEP       top_of_buffer() = 0;
  817.  
  818.   virtual int _HOOKEP       top_of_window() = 0;
  819.  
  820.   virtual int _HOOKEP       translate
  821.                                 (
  822.                                     char  * pattern,
  823.                                     char  * replacment,
  824.                                     int     global_flag,
  825.                                     int     regex   = 1,
  826.                                     int     caseSen = 1,
  827.                                     int     block   = 0,
  828.                                     int     forward = 1,
  829.                                     int     grep    = 0
  830.                                 ) = 0;
  831.  
  832.   virtual int _HOOKEP       up() = 0;
  833.  
  834.   virtual int _HOOKEP       write_buffer() = 0;
  835.  
  836.   //----------------------------------------------------------------
  837.   //  This section consists of additional routines that cannot
  838.   //  be built with the BRIEF primitives.
  839.   //
  840.  
  841.   //
  842.   //  Free storage allocated by calls to read
  843.   //
  844.   virtual void _HOOKEP      free_string
  845.                                 (
  846.                                     char  * str      //  string to free 
  847.                                 ) = 0;
  848.  
  849.   //
  850.   //  show_buffer moves an MDI window on the current buffer to the
  851.   //  top of the window stack. If no such window exists, one is created.
  852.   //
  853.   virtual void _HOOKEP      show_buffer() = 0;
  854.  
  855.   virtual int _HOOKEP       save_buffer() = 0;
  856.  
  857.   virtual int _HOOKEP       register_keyhit_handlers
  858.                                 ( 
  859.                                     KeyStroke   *   keyStrokes,
  860.                                     int             numKeyStrokes
  861.                                 ) = 0;
  862. };
  863.  
  864.  
  865. ////////////////////////////////////////////////////
  866. //  Service implementation                        //
  867. //                                                //
  868. //  See the notes above for usage information.    //
  869. ////////////////////////////////////////////////////
  870.  
  871. extern void *   QueryService( int );
  872. extern void     ReleaseService( int, void * );
  873.  
  874. template <class T, int id>
  875. class __Req
  876. {
  877. public:
  878.     __Req() : _id( id )     { _server = (T *)QueryService( id ); }
  879.     ~__Req()                { if( _server ) 
  880.                                 ReleaseService( id, (void *)_server ); }
  881.     operator T  * ()        { return( _server ); }
  882.     T  * operator -> ()     { return( _server ); }
  883.     int operator ! ()       { return( !_server ); }
  884.  
  885. private:
  886.     T  * _server;
  887.     int     _id;
  888. };
  889.  
  890.  
  891. #define SRVR_PROJECT        1
  892. #define SRVR_TOOL           2
  893. #define SRVR_OPTIONSET      3
  894. #define SRVR_TARGETEXPERT   4
  895. #define SRVR_MAKE           5
  896. #define SRVR_EDITOR         6
  897.  
  898. ////////////////////////////////////////////////////
  899. //  Service usage...                              //
  900. //                                                //
  901. //  Use the following typedefs when you are       //
  902. //  accessing a service, when you are coming into //
  903. //  the scope the __Req where the service is      //
  904. //  made, or when going out of the scope where    //
  905. //  the service is released.                      //
  906. ////////////////////////////////////////////////////
  907.  
  908. typedef __Req<ProjectServer,  SRVR_PROJECT >     ProjectReq;
  909. typedef __Req<ToolServer,     SRVR_TOOL    >     ToolReq;
  910. typedef __Req<OptionSetServer,SRVR_OPTIONSET >   OptionSetReq;
  911. typedef __Req<TargetExpert,   SRVR_TARGETEXPERT> TargetExpertReq;
  912. typedef __Req<MakeServer,     SRVR_MAKE >        MakeReq;
  913. typedef __Req<EditorServer,   SRVR_EDITOR >      EditorReq;
  914.  
  915.  
  916. #endif  __IDEHOOK_H
  917.  
  918. // End of file
  919.  
  920.