home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / prodtool / epm / e_macros / help.e < prev    next >
Encoding:
Text File  |  1992-08-27  |  7.3 KB  |  205 lines

  1. /*      HELP.E       --- Used By EPM  G.C.       */
  2. include 'STDCONST.E'  -- LAM:  Need IBM_IUO
  3. tryinclude 'MYCNF.E'
  4.  compile if not defined(NLS_LANGUAGE)
  5.   const NLS_LANGUAGE = 'ENGLISH'
  6.  compile endif
  7. include NLS_LANGUAGE'.e'
  8.  
  9. const
  10.    PAGESIZE = 21
  11.  
  12. defmain    /* defmain should be used to parse the command line arguments */
  13.    'xcom e 'arg(1)
  14.    prevfile; 'xcom quit'
  15.  
  16. ;  .titletext    = 'EPM Help Browser'
  17.    .titletext    = QUICK_REF__MSG
  18.    .textcolor    =  240            -- WhiteB
  19.    .markcolor    =  240            -- WhiteB
  20.    .tabs         = '1 2 3 4 5 6'
  21.    .margins      = '1 80 1'
  22.    .autosave     = 0
  23.    keys help
  24.    call repaint_window()
  25.    call showwindow('ON')
  26.    'togglecontrol 14 0'     -- Turn cursor off
  27. compile if EVERSION >= '5.50'
  28.    if upcase(rightstr(.filename,8))='DBCS.QHL' then
  29.       .font = registerfont('Mincho', 10, 0)
  30.    else
  31.       .font = registerfont('System Monospaced', 10, 0)
  32.    endif
  33. compile endif
  34. compile if EVERSION < '5.21'
  35.    .statuscolor  =  16+15          -- BlueB + White
  36.    .messagecolor =  16+14          -- BlueB + Yellow
  37.    .statusline=HELP_STATUS__MSG
  38. compile else
  39.    'togglecontrol 26 0'     -- Don't use internal key definitions.
  40.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  41.                       5431,      -- EPM_FRAME_STATUSLINE
  42. compile if EVERSION >= 5.53
  43.                       put_in_buffer(atoi(length(HELP_STATUS__MSG)) || HELP_STATUS__MSG, 0),
  44. compile else
  45.                       put_in_buffer(chr(length(HELP_STATUS__MSG)) || HELP_STATUS__MSG, 0),
  46. compile endif
  47.                       31)        -- BlueB + White
  48.  
  49.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  50.                       4873,      -- EII_EDIT_REFRESHSTATUSLINE
  51.                       1, 1);
  52.  compile if EVERSION < 5.53
  53.    'togglecontrol 23 1'     -- Move status & message line to top
  54.  compile else
  55.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),
  56.                       5907,            -- EFRAMEM_TOGGLECONTROL
  57.                       32 + 2 * 65536,  -- Move extra window to top
  58.                       0)
  59.  compile endif
  60. compile endif
  61. ;  mouse_setpointer 12
  62.    .cursory = 1
  63.    '0'
  64.  
  65. defc e =  -- Only called by someone else posting a command to us.
  66.    call winmessagebox(QUICK_REF__MSG, NO_DROP__MSG, 16454) -- CANCEL + ICONHAND + MOVEABLE
  67.  
  68. defkeys help base clear
  69.  
  70. def pgup=
  71.    .cursory = 1
  72.    PAGESIZE * (max(.line-1,0) % PAGESIZE)
  73.  
  74. def pgdn=
  75.    .cursory = 1
  76.    PAGESIZE * (min(.line+PAGESIZE,.last) % PAGESIZE)
  77.  
  78. def home, c_Home = .cursory=1; '0'
  79.  
  80. def end, c_End = .cursory=1; .last % PAGESIZE * PAGESIZE
  81.  
  82. def esc,F3=  -- 'close'
  83. ; defc close=
  84.    call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  85.                       41,                 -- WM_CLOSE
  86.                       0,
  87.                       0)
  88.  
  89. defproc max(a,b)  -- Support as many arguments as E3 will allow.
  90.    maximum=a
  91.    do i=2 to arg()
  92.       if maximum<arg(i) then maximum=arg(i); endif
  93.    end
  94.    return maximum
  95.  
  96. defproc min(a,b)  -- Support as many arguments as E3 will allow.
  97.    minimum=a
  98.    do i=2 to arg()
  99.       if minimum>arg(i) then minimum=arg(i); endif
  100.    end
  101.    return minimum
  102.  
  103. /* allows the edit window to become invisible or visible  */
  104. defproc showwindow
  105.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
  106.                       5385,
  107.                       upcase(arg(1))<>'OFF', -- 0 if OFF, else 1
  108.                       0)
  109.  
  110. /*
  111. ┌────────────────────────────────────────────────────────────────────────────┐
  112. │ what's it called: repaint_window                                           │
  113. │                                                                            │
  114. │ what does it do : send a paint message to the editor.                      │
  115. │                                                                            │
  116. └────────────────────────────────────────────────────────────────────────────┘
  117. */
  118. defproc repaint_window()
  119.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 35, 0, 0)   -- WM_PAINT
  120.  
  121. defc togglecontrol
  122.    forceon=0
  123.    parse arg controlid fon
  124.    if fon<>'' then
  125.       forceon=(fon+1)*65536
  126.    endif
  127.  
  128.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),   -- Post message to frame
  129.                       5388,               -- EPM_EDIT_CONTROLTOGGLE
  130.                       controlid + forceon,
  131.                       0)
  132.  
  133. defc PROCESSDRAGDROP
  134.    parse arg cmdid hwnd .
  135. ;  hwnd=atol_swap(hwnd)
  136.  
  137.    if cmdid=10 then
  138.       sayerror PRINTING__MSG .filename
  139.       'xcom save /q lpt1'
  140.    elseif cmdid=1 and hwnd<>getpminfo(EPMINFO_EDITCLIENT) and leftstr(.filename,1)<>'.' then
  141.       call PostCmdToEditWindow('e '.filename,hwnd,9,2)
  142.    elseif cmdid=3 then                       -- Open
  143.       call windowmessage(0,  getpminfo(APP_HANDLE),
  144.                          5386,                   -- EPM_EDIT_NEWFILE
  145.                          put_in_buffer(name,2),  -- share = GETable
  146.                          9)                      -- EPM does a GET first & a FREE after.
  147. ;     call dynalink( 'PMWIN',
  148. ;                    'WINPOSTMSG',
  149. ;                     hwnd                       ||
  150. ;                     atoi(5386)                 ||  -- Window Message (EPM_EDIT_NEWFILE)
  151. ;                     put_in_buffer(.filename,2) ||
  152. ;                     atol_swap(9) )
  153. compile if IBM_IUO
  154.    elseif cmdid=4 then
  155.       call winmessagebox(SYS_ED__MSG,SYS_ED1__MSG\10'   :-)', 16406) -- CANCEL + ICONQUESTION
  156. compile endif
  157.    endif
  158.  
  159. defproc PostCmdToEditWindow(cmd,winhndl)
  160. ;; if arg(3)<>'' then mp2=arg(3); else mp2=1; endif
  161.    call windowmessage(0,  winhndl,
  162.                       5377,               -- EPM_EDIT_COMMAND
  163.                       put_in_buffer(cmd,arg(4)),
  164.                       arg(3))
  165.  
  166. defproc put_in_buffer(string)
  167. ;; if arg(2)='' then share=0; else share=arg(2); endif
  168.    strbuffer = "??"                    -- Initialize string pointer.
  169.    r =  dynalink('DOSCALLS',           -- Dynamic link library name
  170.             '#34',                     -- DosAllocSeg
  171.             atoi(length(string)+1) ||  -- Number of bytes requested
  172.             selector(strbuffer)    ||  -- String selector
  173.             offset(strbuffer)      ||  -- String offset
  174.             atoi(arg(2)) )             -- Share information
  175.  
  176.    if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif
  177.    strbuffer = itoa(strbuffer,10)
  178.    poke strbuffer,0,string\0  -- Copy string to new allocated buf
  179.    return mpfrom2short(strbuffer,0)    -- Return a long pointer to buffer
  180.  
  181. defproc winmessagebox(caption, text)
  182.  
  183.   msgtype = 4096                                        -- must be system modal.
  184.   if arg(3) then
  185.      msgtype=arg(3) + 4096 * (1 - (arg(3)%4096 - 2 * (arg(3)%8192)))  -- ensure x'1000' on
  186.   endif
  187.   caption = caption\0
  188.   text    = text\0
  189.   return dynalink( 'PMWIN',
  190.                    'WINMESSAGEBOX',
  191.                    atoi(0) || atoi(1) ||   -- Parent
  192.                    atoi(0) || atoi(1) ||   -- Owner
  193.                    selector(text)     ||   -- Text
  194.                    offset(text)       ||
  195.                    selector(caption)  ||   -- Title
  196.                    offset(caption)    ||
  197.                    atoi(0)            ||   -- Window
  198.                    atoi(msgtype) )         -- Style
  199.  
  200. defproc mpfrom2short(mphigh, mplow)
  201.    return ltoa( atoi(mplow) || atoi(mphigh), 10 )
  202.  
  203. defc processendscroll
  204.  
  205.