home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / HELP.E < prev    next >
Text File  |  1995-04-26  |  9KB  |  252 lines

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