home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / editors / epm / e_macros / kwhelp.e < prev    next >
Encoding:
Text File  |  1993-09-01  |  3.9 KB  |  135 lines

  1. /* format of index file:
  2.      (Win*, view winhelp.inf ~)
  3.      (printf, view edchelp.inf printf)
  4. */
  5.  
  6. defc kwhelp=  call pHelp_C_identifier()
  7.  
  8. defproc pHelp_C_identifier
  9.    universal helpindex_id
  10.    if not find_token(startcol, endcol) then
  11.       return
  12.    endif
  13.    getline line
  14.    is_class = 0; colon_pos = 0
  15.    if substr(line, endcol+1, 2) = '::' then  -- Class?
  16.       ch = upcase(substr(line, endcol+3, 1))
  17.       if (ch>='A' & ch<='Z') | ch='_' then
  18.          curcol = .col
  19.          .col = endcol+3
  20.          call find_token(junk, endcol)
  21.          .col = curcol
  22.          is_class = 1
  23.       endif
  24.    elseif startcol>3 then
  25.       if substr(line, startcol-2, 2) = '::' then  -- Class?
  26.          ch = upcase(substr(line, startcol-3, 1))
  27.          if (ch>='A' & ch<='Z') | (ch>='0' & ch<='9') | ch='_' then
  28.             curcol = .col
  29.             .col = startcol-3
  30.             call find_token(startcol, junk)
  31.             .col = curcol
  32.             is_class = 2
  33.          endif
  34.       endif
  35.    endif
  36.    identifier = substr(line, startcol, (endcol-startcol)+1)
  37.  
  38.    getfileid CurrentFile             /* save the ID of the current file */
  39.    if helpindex_id then
  40.       display -2
  41.       rc = 0
  42.       activatefile helpindex_id
  43.       display 2
  44.       if rc then  -- File's gone?
  45.          helpindex_id = 0
  46.       endif
  47.    endif
  48.    if not helpindex_id then
  49.       helplist = Get_Env('HELPNDX')
  50.       if helplist='' then
  51. compile if defined(KEYWORD_HELP_INDEX_FILE)
  52.          helplist = KEYWORD_HELP_INDEX_FILE
  53. compile else
  54.          helplist = 'epmkwhlp.ndx'
  55. compile endif
  56.       endif
  57.       ft = filetype()
  58.       savelist = helplist
  59.       do while helplist<>''
  60.          parse value helplist with helpindex '+' helplist
  61.  
  62.          /* look for the help index file in current dir, EPMPATH, DPATH, and EPM.EXE's dir: */
  63.          findfile destfilename, helpindex, '','D'
  64.  
  65.          if rc then
  66.             /* If that fails, try the standard path. */
  67.             findfile destfilename, helpindex, 'PATH'
  68.             if rc then
  69.                sayerror  'Help index 'helpindex' not found'
  70.                return
  71.             endif
  72.          endif
  73. compile if EVERSION >='5.50'
  74.          if pos(' ',destfilename) then
  75.             destfilename = '"'destfilename'"'
  76.          endif
  77. compile endif
  78.          if helpindex_id then
  79.             bottom
  80.             last = .last
  81.             'get' destfilename
  82.             line = upcase(textline(last+1))
  83.             if word(line,1)='EXTENSIONS:' & wordpos(ft, line) then  -- Move to top
  84.                call psave_mark(savemark)
  85.                call pset_mark(last+1, .last, 1, MAXCOL, 'LINE', helpindex_id)
  86.                0
  87.                move_mark
  88.                call prestore_mark(savemark)
  89.             endif
  90.          else
  91.             'xcom e /d' destfilename
  92.             getfileid helpindex_id
  93.             .visible = 0
  94.          endif
  95.       enddo
  96.       helpindex_id.userstring = savelist
  97.    endif
  98.    top; .col = 1
  99.  
  100.  
  101.    display -2
  102.    getsearch savesearch
  103.    'xcom /('identifier',/'     -- search for the exact match...
  104.    if rc then
  105.       do i = length(identifier) to 0 by -1
  106.          'xcom /('leftstr(identifier, i)'*,/'
  107.          if not rc then
  108.             leave
  109.          endif
  110.       enddo
  111.    endif
  112.    setsearch savesearch
  113.    display 2
  114.  
  115.    if rc then
  116.       sayerror 'Unable to find entry for 'identifier' in 'helpindex_id.userstring'.'
  117.    else
  118.       parse value substr(textline(.line), .col) with ',' line ')'
  119.       /* substitute all occurrances of '~' with the original identifier */
  120.       loop
  121.          i = pos('~', line)
  122.          if not i then
  123.             leave
  124.          endif
  125.          line = leftstr(line, i-1)||identifier||substr(line, i+1)
  126.       endloop
  127.  
  128.       if upcase(word(line,1))='VIEW' then
  129.          sayerror 'Invoking View ...'
  130.       endif
  131.       'dos 'line  -- execute the command
  132.    endif
  133.    activatefile CurrentFile
  134.  
  135.