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

  1. //----------------------------------------------------------------------------
  2. // IdeHook - (C) Copyright 1994 by Borland International
  3. //----------------------------------------------------------------------------
  4. #pragma hdrstop
  5.  
  6. #include "idehook.h"
  7. #include <windows.h>
  8.  
  9.  
  10. //  Editor addon
  11.  
  12. static char szClassHeader[] =
  13. {
  14.     "//\n"
  15.     "//   Class:\n"
  16.     "//\n"
  17.     "//   Description:\n"
  18.     "//\n"
  19.     "//   Last modified date:\n"
  20.     "//   Last modified by:  \n"
  21.     "//\n"
  22. };
  23.  
  24.  
  25. int KeyStrokeTest2( KeyStroke * )
  26. {
  27.     EditorReq   editor;
  28.  
  29.     long    line;
  30.     long    col;
  31.  
  32.     editor->inq_position( &line, &col );
  33.     while( col-- )
  34.         editor->left();
  35.     editor->down();
  36.  
  37.     editor->insert( szClassHeader );
  38.  
  39.     return(1);
  40. }
  41.  
  42. int KeyStrokeTest1( KeyStroke * )
  43. {
  44.     EditorReq   editor;
  45.  
  46.     long    line;
  47.     long    col;
  48.  
  49.     editor->inq_position( &line, &col );
  50.     while( col-- )
  51.         editor->left();
  52.     editor->drop_anchor();
  53.     editor->end_of_line();
  54.     editor->raise_anchor();
  55.  
  56.     return(1);
  57. }
  58.  
  59.  
  60. //
  61. //      Project stuff
  62. //
  63.  
  64. class _HOOKCLASS LocalProjClient : public ProjectClient
  65. {
  66. public:
  67.     LocalProjClient();
  68.    
  69.     virtual void _HOOKEP OpenNotify( const char * name );
  70.     virtual void _HOOKEP CloseNotify()  {}
  71.     virtual void _HOOKEP NodeDeleteNotify(ProjectNode) {}
  72.     virtual void _HOOKEP DependencyQueryResponder(ProjectNode,const char*) {}
  73.  
  74.     int _registered;
  75.  
  76. };
  77.  
  78. LocalProjClient::LocalProjClient()
  79. {
  80.    ProjectReq ps;
  81.  
  82.    ps->RegisterProjectClient(this);
  83. }
  84.  
  85. static LocalProjClient LocalProjClient;
  86.  
  87.  
  88. #define NUM_KEYSTROKES  (sizeof(keyStrokes)/sizeof(keyStrokes[0]))
  89.  
  90. static KeyStroke    keyStrokes[] =
  91. {
  92.     { WM_KEYDOWN, VK_F11, NoModifier,  KeyStrokeTest2 },
  93.     { WM_KEYDOWN, VK_F11, Shift,       KeyStrokeTest1 }
  94. };
  95.  
  96. void _HOOKEP    
  97. LocalProjClient::OpenNotify
  98. (
  99.    const char * // name 
  100. )
  101. {
  102.     if( !_registered )
  103.     {
  104.         EditorReq   editor;
  105.  
  106.         editor->register_keyhit_handlers( keyStrokes, NUM_KEYSTROKES );
  107.  
  108.         _registered = 1;
  109.     }
  110. }
  111.     
  112. // End of file
  113.  
  114.