home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / CBIND.E < prev    next >
Text File  |  1992-08-26  |  4KB  |  77 lines

  1. /*****************************************************************************
  2.  *                              CBIND.E
  3.  *
  4.  *      Alt-q to perform lookup of C-bindings for the word at cursor position.
  5.  *      This macro is extremely useful as a kind of online quick reference for
  6.  *      most of the functions included in OS2 and PM.  It provides a sort of
  7.  *      crude hypertext-like capability when editing OS2 C source code.  At
  8.  *      present, it is designed to look up C function prototype definitions.
  9.  *      It could be extended to provide more comprehensive lookup on #defines
  10.  *      and typedefs.
  11.  *
  12.  *      CBIND works by grabbing the word at the cursor position, then doing
  13.  *      a locate on the word in the appropriate .H file.
  14.  *
  15.  * INSTALLATION:
  16.  *     include 'cbind.e'       in your MYSTUFF.E file
  17.  *     et e.e
  18.  *
  19.  * Written by David Slauson  03/25/89
  20.  ***************************************************************************/
  21. def a_q=
  22.  
  23.    /**************************************************************************/
  24.    /* NOTE: You may need to change the following variables to match your     */
  25.    /*       subdirectory names or .H filenames.                              */
  26.    /**************************************************************************/
  27.    dosbind= 'D:\TOOLKT13\C\INCLUDE\BSEDOS.H'         /* Dos functions        */
  28.    bsebind= 'D:\TOOLKT13\C\INCLUDE\BSESUB.H'         /* Mou, Kbd, Vio functs */
  29.    winbind= 'D:\TOOLKT13\C\INCLUDE\PMWIN.H'          /* Win functions        */
  30.    gpibind= 'D:\TOOLKT13\C\INCLUDE\PMGPI.H'          /* Gpi functions        */
  31.    /***************************************************************************/
  32.   call pmark_word()                    /* mark the word at the cursor position*/
  33.  
  34.   getline line,.line                   /* Get marked word into variable       */
  35.   getmark first_line,last_line,first_col,last_col
  36.   word_len = last_col - first_col + 1
  37.   word = Substr(line,first_col,word_len)
  38.   unmark
  39.  
  40.   tempfile= ''
  41.   word= strip(word,'B','(')
  42.   word= strip(word,'B','{')
  43.   word= strip(word,'B',';')
  44.   parse value word with word1 '(' junk    /* strip off anything after '('     */
  45.   if pos('Dos', word1) > 0 then
  46.         tempfile= dosbind
  47.      elseif pos('Win', word1) > 0 then
  48.         tempfile= winbind
  49.      elseif pos('Gpi', word1) > 0 then
  50.         tempfile= gpibind
  51.      elseif pos('Vio', word1) > 0 then
  52.         tempfile= bsebind
  53.      elseif pos('Mou', word1) > 0 then
  54.         tempfile= bsebind
  55.      elseif pos('Kbd', word1) > 0 then
  56.         tempfile= bsebind
  57.   endif
  58.   if tempfile > '' then                /* valid function name found          */
  59.      'xcom E 'tempfile                 /* edit the appropriate .H file       */
  60.      top
  61.      cmtflag= 1;                       /* assume the line found is a comment */
  62.      do while cmtflag                  /* leave when we've located a non-cmt */
  63.         'xcom /'||word1                /* locate the marked word             */
  64.         getline line,.line
  65.         line= strip(line,'L')          /* strip any leading blanks           */
  66.         if substr(line,1,2) <> '/*' then
  67.            cmtflag= 0                  /* not a comment, probably the hit    */
  68.         else                           /* this is a comment line, skip it    */
  69.            'xcom +1'
  70.         endif
  71.      enddo
  72.      setcommand '/'||word1, 1,1        /* show the user what we've done      */
  73.   else
  74.      sayerror 'Unable to look up "'word1'"...definition .H file unknown.'
  75.   endif
  76.  
  77.