home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epm603a.zip / EPMMAC.ZIP / STDCTRL.E < prev    next >
Text File  |  1995-10-18  |  239KB  |  5,546 lines

  1. compile if EVERSION < 5
  2.    *** Error:  This file supports EPM only, not earlier versions of E.
  3. compile endif
  4. compile if EVERSION < 5.20
  5.    *** Error:  Support for your ancient version of EPM has been dropped from the current macros
  6. compile endif
  7.  
  8. /*
  9. ╔════════════════════════════════════════════════════════════════════════════╗
  10. ║ What's it called: stdctrl.e                                                ║
  11. ║                                                                            ║
  12. ║ What does it do : contains special PM procedures and commands that enable  ║
  13. ║                   the following from the EPM editor:                       ║
  14. ║                                                                            ║
  15. ║                   listbox support - enables the dynamic creation of PM     ║
  16. ║                                     list boxes.   A macro can pop up a     ║
  17. ║                                     list of items and have a the users     ║
  18. ║                                     selection returned to the macro.       ║
  19. ║                                                                            ║
  20. ║                   menu support    - enables the dynamic creation and       ║
  21. ║                                     maintenance of named menus.            ║
  22. ║                                     A macro can create several menus that  ║
  23. ║                                     when shown and selected can execute    ║
  24. ║                                     editor commands.                       ║
  25. ║                                                                            ║
  26. ║                   EPM - E.DLL communication :                              ║
  27. ║                                     gives a EPM macro the ability to       ║
  28. ║                                     converse with EPM.EXE controls.        ║
  29. ║                                     For Example, popping EPM's commandline ║
  30. ║                                     message dialog, etc.                   ║
  31. ║                                                                            ║
  32. ║ Who and When    : Gennaro (Jerry) Cuomo                          3 -88     ║
  33. ║                                                                            ║
  34. ╚════════════════════════════════════════════════════════════════════════════╝
  35. */
  36.  
  37. /*
  38. ┌────────────────────────────────────────────────────────────────────────────┐
  39. │ The following are constant values that are to be used as parameters to     │
  40. │ the getpminfo internal function or as control id's for control toggle.     │
  41. │                                                                            │
  42. │ HAB           0  PARENTFRAME     4  EDITORMSGAREA      8   EDITVIOPS    12 │
  43. │ OWNERCLIENT   1  EDITCLIENT      5  EDITORVSCROLL      9   EDITTITLEBAR 13 │
  44. │ OWNERFRAME    2  EDITFRAME       6  EDITORHSCROLL      10  EDITCURSOR   14 │
  45. │ PARENTCLIENT  3  EDITSTATUSAREA  7  EDITORINTERPRETER  11  PARTIALTEXT  15 │
  46. │ EDITEXSEARCH  16 EDITMENUHWND    17 HDC                18  HINI         19 │
  47. │ RINGICONS     20                    FILEICONS          22  EXTRAWNDPOS  23 │
  48. │ CursorBounce  24 CUA_marking     25 Arrows_Internal    26                  │
  49. └────────────────────────────────────────────────────────────────────────────┘
  50. */
  51.  
  52.  
  53. /*
  54. ┌────────────────────────────────────────────────────────────────────────────┐
  55. │ List Box Functions:                                                        │
  56. │                                                                            │
  57. │      listbox()                                                             │
  58. │      listboxdemo()                                                         │
  59. └────────────────────────────────────────────────────────────────────────────┘
  60. */
  61.  
  62. /************************************************************************
  63. listbox()
  64.     param1 - Listbox title
  65.  
  66.     param2 - string of items, separated by a common separator.  The common
  67.              separator is the first character in the string.
  68.              example:     /cat/dog/fish/
  69.                           separator='/'        list=cat, dog, fish
  70.              example:     $cat/ground$fish/water$
  71.                           separator='$'        list=cat/ground, fish/water
  72.  
  73.              If this parameter starts with an x'00', then it will be assumed to
  74.              represent a buffer, in the format:
  75.                 x'00' || atoi(length(text)) || address(text) [ || flags ]
  76.              (The atoi() is an atol() for 32-bit EPM.)
  77.              'flags' is an ASCII number representing a bit flag:
  78.                 1 - Display the listbox below the specified point
  79.                 2 - Map the specified points to the desktop
  80.                 4 - Support Details button, as for Workframe.  Data has handles
  81.                     (see below) representing a help panel ID; first button is
  82.                     assumed to be "Details".  Pressing button or double-clicking
  83.                     on an item in the list calls the Help Manager, specifying the
  84.                     help panel of the selected item.
  85.                 8 - The listbox should be non-modal.  (Not supported.)
  86.                16 - The listbox contents should be displayed in a monospaced font.
  87.                32 - Each item in the list is preceded by a "handle" - a number in
  88.                     the range 0 - 65535 which is associated with the item (but not
  89.                     visible in the listbox).  When an item is selected, the returned
  90.                     string consists of the handle followed by the item text.  Sample
  91.                     list:  "/1 One/5 Five/42 Answer/".
  92.  
  93.     param3 - (optional) button names.  A maximum of seven button names can be
  94.              specified to allow multiple buttons.
  95.  
  96.     param4 - (optional) row of text in which list box will go under.
  97.              If this parameter is not specified or if a parameter of zero (0)
  98.              is specified, the box will be placed under the cursor.
  99.     param5 - (optional) column of text in which list box will go under.
  100.              If this parameter is not specified or if a parameter of zero (0)
  101.              is specified, the box will be placed under the cursor.
  102.              (NOTE: If the row parameter is selected the column parameter
  103.               must be selected as well.)
  104.     param6 - (optional) height of the listbox in characters
  105.              (NOTE:Since the default PM font is proportional the character
  106.               height and width are approximate values.)
  107.     param7 - (optional) width of listbox in characters.
  108.     param8 - (optional) buffer string (see below)
  109.  
  110. The following procedure creates a PM list box dialog.  The listbox will
  111. wait for user input and return a value that corresponds to the users input.
  112. If the user presses Enter or double clicks on an entry, that entry will
  113. be returned as the result of the listbox function.  If Cancel is selected
  114. or Esc is pressed, the listbox function will return null.   The listbox
  115. is a modal listbox, therefore user input is required before any thing
  116. else can happen.
  117.  
  118. Jerry Cuomo   1-89
  119.  
  120. EPM 5.21 / 5.50 added some new features to the ETOOLKIT interface.  Parameter
  121. 8 is used to expose this to the caller of listbox().  If present, it is a string
  122. consisting of (5.51 & below):  item# || button# || help_ID || handle || prompt
  123. or, in 5.60 & above, of:  handle || item# || button# || help_ID || prompt
  124. where item# is the listbox entry to be initially selected, button# is the button
  125. that will be the default, help_ID is a help panel ID (all shorts), handle is the
  126. window handle of the OWNERCLIENT (needed to call help; ignored if help_ID is 0),
  127. and prompt is an ASCIIZ string to be displayed below the title bar.  If help_ID
  128. is non-zero, the rightmost button is assumed to be the help button.  The new
  129. parameters are passed to the toolkit in the return buffer, which is padded with
  130. nulls, so only the minimum needed string need be sent.  The old way only supported
  131. returning a string if button 1 was pressed; button 2 was assumed to be Cancel, and
  132. returned null; anything else returned the button number.  The new way returns one
  133. byte representing the button number (in hex) followed by the selected item.
  134. A button number of 0 means Esc was pressed or the dialog was closed.  If param8
  135. was passed, the listbox() routine returns this entire string; if not, it parses
  136. it and returns what the old callers expected.
  137.  
  138. Larry Margolis / John Ponzo 6/91
  139.  
  140. ****************************************************************************/
  141.  
  142. defproc listbox(title, listbuf)
  143.    universal app_hini
  144.    if leftstr(listbuf,1)=\0 then
  145. compile if EPM32
  146.       liststuff = substr(listbuf,2,8)
  147.       flags = substr(listbuf,10)
  148. compile else
  149.       liststuff = substr(listbuf,2,6)
  150.       flags = substr(listbuf,8)
  151. compile endif -- EPM32
  152.    else
  153.       listbuf=listbuf \0
  154. compile if EPM32
  155.       liststuff = atol(length(listbuf)-1)    ||   /* length of list                */
  156.                   address(listbuf)                /* list                          */
  157. compile else
  158.       liststuff = atoi(length(listbuf)-1)    ||   /* length of list                */
  159.                   address(listbuf)                /* list                          */
  160. compile endif -- EPM32
  161.       flags = ''
  162.    endif
  163.    title  = title \0
  164.  
  165.    if arg(3)<>'' then                      /* button names were specified    */
  166.       parse value arg(3) with delim 2 but1 (delim) but2 (delim) but3 (delim) but4 (delim) but5 (delim) but6 (delim) but7 (delim)
  167.       nb=0
  168.       if but1<>'' then but1=but1\0; nb=nb+1; else sayerror 'LISTBOX:' BUTTON_ERROR__MSG; return 0; endif
  169.       if but2<>'' then but2=but2\0; nb=nb+1; else but2=\0; endif
  170.       if but3<>'' then but3=but3\0; nb=nb+1; else but3=\0; endif
  171.       if but4<>'' then but4=but4\0; nb=nb+1; else but4=\0; endif
  172.       if but5<>'' then but5=but5\0; nb=nb+1; else but5=\0; endif
  173.       if but6<>'' then but6=but6\0; nb=nb+1; else but6=\0; endif
  174.       if but7<>'' then but7=but7\0; nb=nb+1; else but7=\0; endif
  175.    else
  176.       but1=ENTER__MSG\0; but2=CANCEL__MSG\0; but3=\0; but4=\0; but5=\0 ; but6=\0; but7=\0 -- default buttons
  177.       nb=2
  178.    endif
  179.  
  180.    if arg()>3 then                         /* were row and column specified  */
  181.       row = arg(4); col = arg(5)            /* row and col were passed        */
  182.       if not row then row=.cursory-1 endif  /* zero means current cursor pos  */
  183.       if not col then col=.cursorx endif
  184.    else
  185.       col=.cursorx; row=.cursory-1          /* default: current cursor pos    */
  186.    endif
  187.    if arg()>5 then                         /* were height and width specified*/
  188.       height = arg(6)                      /* height was passed   */
  189.    else
  190.       height = 0                           /* default: 0=use listbox default */
  191.    endif
  192.    if arg()>6 then                         /* were height and width specified*/
  193.       width = arg(7)                       /* width was passed   */
  194.    else
  195.       width = 0                            /* default: 0=use listbox default */
  196.    endif
  197.  
  198.    x = .fontwidth * col                    /* convert row and column into...*/
  199. compile if EVERSION < 5.50
  200.    y = .windowy+.fontheight*(screenheight()-row-1)  /* x,y coordinates in pels */
  201. compile else
  202.    y = .windowy+screenheight()-.fontheight*(row+1)-4  /* (Add a fudge factor temporarily */
  203. compile endif
  204.  
  205. compile if EVERSION >= 5.21
  206.    if arg()>7 then                         /* New way!                       */
  207.       selectbuf = leftstr(arg(8), 255, \0)
  208.    else
  209.       selectbuf = copies(\0,255)  -- Was 85     /* null terminate return buffer  */
  210.    endif
  211. compile else
  212.    selectbuf = leftstr(\0,85)        /* null terminate return buffer  */
  213. compile endif
  214.  
  215.    if flags='' then
  216.       flags=3   -- bit 0=position below pts, bit 1=map to desktop
  217.    endif
  218.    if getpminfo(EPMINFO_EDITFRAME) then
  219.       handle = EPMINFO_EDITFRAME
  220.    else                   -- If frame handle is 0, use edit client instead.
  221.       handle = EPMINFO_EDITCLIENT
  222.    endif
  223. compile if EPM32
  224.    call dynalink32( ERES_DLL,               /* list box control in EDLL dyna */
  225.                    'LISTBOX',                    /* function name                 */
  226.                     gethwndc(handle)           ||   /* edit frame handle             */
  227.                     atol(flags)                ||
  228.                     atol(x)                    ||   /* coordinates                   */
  229.                     atol(y)                    ||
  230.                     atol(height)               ||
  231.                     atol(width)                ||
  232.                     atol(nb)                   ||
  233. compile else
  234.    call dynalink(   ERES_DLL,                /* list box control in EDLL dyna */
  235.                    'LISTBOX',                    /* function name                 */
  236.                     gethwnd(handle)            ||   /* edit frame handle             */
  237.                     atoi(flags)                ||
  238.                     atoi(x)                    ||   /* coordinates                   */
  239.                     atoi(y)                    ||
  240.                     atoi(height)               ||
  241.                     atoi(width)                ||
  242.                     atoi(nb)                   ||
  243. compile endif
  244.                     address(title)             ||   /* list box dialog title         */
  245.                     address(but1)              ||   /* text to appear in buttons     */
  246.                     address(but2)              ||   /*                               */
  247.                     address(but3)              ||   /*                               */
  248.                     address(but4)              ||   /*                               */
  249.                     address(but5)              ||   /*                               */
  250.                     address(but6)              ||   /*                               */
  251.                     address(but7)              ||   /*                               */
  252.                     liststuff                  ||
  253. compile if EPM32
  254.                     address(selectbuf)         ||   /* return string buffer          */
  255.                     atol(app_hini))                 /* Handle to INI file            */
  256. compile else
  257.                     address(selectbuf))             /* return string buffer          */
  258. compile endif -- EPM32
  259.  
  260. compile if EVERSION >= 5.21
  261.    button = asc(leftstr(selectbuf,1))
  262.    if arg()>7 then return selectbuf; endif  -- New way
  263.    if button=0 | button=2 then return ''; endif  -- Old way...
  264.    if button<>1 then return button; endif
  265.    EOS = pos(\0,selectbuf,2)        -- CHR(0) signifies End Of String
  266.    if not EOS then return 'error'; endif
  267.    return substr(selectbuf,2,EOS-2)
  268. compile else
  269.    EOS = pos(\0,selectbuf)        -- CHR(0) signifies End Of String
  270.    if not EOS then return 'error'; endif
  271.    return leftstr(selectbuf,EOS-1)
  272. compile endif
  273.  
  274. /*********** Sample command that uses the old list box function *********
  275. defc listdemo
  276.    select = listbox('My List','/Bryan/Jason/Jerry Cuomo/Ralph/Larry/Richard/');
  277.    if select=='' then
  278.       sayerror 'Nothing Selected'
  279.    else
  280.       sayerror 'list box selection =<' select '>'
  281.    endif
  282. **/
  283. /*********** Sample command that uses the new list box function *********
  284. defc listdemo
  285.    sayerror 'Selected entry 3; default button 2; help panel 9300.'
  286.    selectbuf = listbox('My List','/One/Two/Three',
  287.       '/Go to/Delete/Cancel/Help',0,0,0,0,
  288.   compile if EVERSION >= 5.60
  289.       gethwnd(APP_HANDLE) || atoi(3) || atoi(2) || atoi(9300) ||
  290.   compile else
  291.       atoi(3) || atoi(2) || atoi(9300) || gethwnd(APP_HANDLE) ||
  292.   compile endif
  293.       'Prompt text'\0);
  294.    button = asc(leftstr(selectbuf,1))
  295.    if button=0 then
  296.       sayerror 'Nothing Selected'
  297.    else
  298.       EOS = pos(\0,selectbuf,2)        -- CHR(0) signifies End Of String
  299.       select= substr(selectbuf,2,EOS-2)
  300.       sayerror 'Button' button 'was pressed; string =' select
  301.    endif
  302. **/
  303.  
  304. /*
  305. ┌────────────────────────────────────────────────────────────────────────────┐
  306. │                                                                            │
  307. │ What's it called: Listbox_Buffer_From_File                                 │
  308. │                                                                            │
  309. │ What does it do : Inserts contents of a temp file into a buffer, ready for │
  310. │                   a call to listbox().  Quits the source file.  Returns '' │
  311. │                   if no problems.                                          │
  312. │                                                                            │
  313. │                   startfid - the starting fileid to which we return        │
  314. │                   bufhndl  - (output) the buffer handle                    │
  315. │                   noflines - (output) number of lines inserted in buffer   │
  316. │                   usedsize - (output) amount of space used in the buffer   │
  317. │                                                                            │
  318. │ Who and when    : Larry Margolis               1994/08/29                  │
  319. │                                                                            │
  320. └────────────────────────────────────────────────────────────────────────────┘
  321. Larry Margolis
  322. */
  323. defproc listbox_buffer_from_file(startfid, var bufhndl, var noflines, var usedsize)
  324.    buflen = filesize() + .last + 1
  325.    if buflen > MAXBUFSIZE then
  326.       sayerror LIST_TOO_BIG__MSG '(' buflen '>' MAXBUFSIZE ')'
  327.       buflen = MAXBUFSIZE
  328.    endif
  329.    bufhndl = buffer(CREATEBUF, 'LISTBOX', buflen, 1 )  -- create a private buffer
  330.    if not bufhndl then sayerror 'CREATEBUF' ERROR_NUMBER__MSG RC; return rc; endif
  331.    noflines = buffer(PUTBUF, bufhndl, 1, 0, APPENDCR)
  332.    buf_rc = rc
  333.    .modify = 0
  334.    'xcom quit'
  335.    activatefile startfid
  336.    if not noflines then sayerror 'PUTBUF' ERROR_NUMBER__MSG buf_RC; return buf_RC; endif
  337.    usedsize = buffer(USEDSIZEBUF,bufhndl)
  338.  
  339. /*
  340. ┌────────────────────────────────────────────────────────────────────────────┐
  341. │                                                                            │
  342. │ What's it called: EntryBox                                                 │
  343. │                                                                            │
  344. │ What does it do : Creates a System-Modal Dialog Box.  (A System-Modal box  │
  345. │                   must be processed before the function can continue.)     │
  346. │                   The dialog box contains a entry field and 2 push buttons.│
  347. │                   (Up to 4 as of EPM 5.21 / 5.50.  See below.)             │
  348. │                                                                            │
  349. │                   hwnd    -  handle of owner window                        │
  350. │                   title   -  question to appear on dialog title bar        │
  351. │                   x,y     -  coordinates of lower left of entry box        │
  352. │                              if (0,0) then centered to screen.             │
  353. │                   cols    -  approximate number of cols in entry field     │
  354. │                              in PM font characters                         │
  355. │                   max     -  maximum number of chars                       │
  356. │                   entry   -  entry field string returned                   │
  357. │                                                                            │
  358. │ Who and when    : Gennaro (Jerry) Cuomo            4-89                    │
  359. │                                                                            │
  360. └────────────────────────────────────────────────────────────────────────────┘
  361.  
  362. EPM 5.21 / 5.50 added some new features to the ETOOLKIT interface.  Parameter
  363. 6 is used to expose this to the caller of entrybox().  If present, it is a string
  364. consisting of:  button# || help_ID || handle || prompt
  365.  
  366. See the listbox() comments to see what these represent, and what is returned.
  367.  
  368. Larry Margolis / John Ponzo 6/91
  369.  
  370. LAM:  New feature for EPM 6.01a:  Can pass entryfield flags as a 7th parameter.
  371.       Primarily of interest for getting passwords:
  372. defc pw =
  373.    pw = entrybox('Enter Password',
  374.                  '',  -- Buttons
  375.                  '',  -- Entry text
  376.                  '',  -- Cols
  377.                  '',  -- Max len
  378.                  '',  -- Return buffer
  379.                  140) -- ES_UNREADABLE + ES_AUTOSCROLL + ES_MARGIN
  380.    Sayerror 'Password = "'pw'"'
  381. */
  382.  
  383. -- entrybox title [,buttons][,entrytext][,cols][,maxchars][,param6]
  384. defproc entrybox(title)
  385.    columns = arg(4)
  386. ;  if columns=0 then columns=length(title); endif  -- Now handled (better) internally
  387.  
  388.    title = title \0
  389.    nb = 2                                  -- default number of buttons
  390.    if arg(2)<>'' then                      /* button names were specified    */
  391.       parse value arg(2) with delim 2 but1 (delim) but2 (delim) but3 (delim) but4 (delim)
  392. ;;    sayerror 'but1=<'but1'> but2=<'but2'> but3=<'but3'> but4=<'but4'>'
  393.       if but1<>'' then but1=but1 \0;  else sayerror 'ENTRYBOX:' BUTTON_ERROR__MSG; return 0; endif
  394.       if but2<>'' then but2=but2 \0;  else but2=''\0; endif
  395.       if but3<>'' then but3=but3 \0;nb=3;  else but3=''\0; endif
  396.       if but4<>'' then but4=but4 \0;nb=4;  else but4=''\0; endif
  397.    else
  398.       but1=\0; but2=\0; but3=\0; but4=\0
  399.    endif
  400.  
  401.    if arg()>2 then entrytext=arg(3) \0;     else  entrytext = \0;  endif
  402. ;; if arg()>3 then columns  =max(arg(4),1); else  columns   = 30;  endif
  403.    if columns<0 then columns = 30; endif
  404.    if arg()>4 then maxchars =max(arg(5),1); else  maxchars  = 254; endif
  405.  
  406.    /* null terminate return buffer  */
  407.    if arg()>5 then
  408.       selectbuf = leftstr(arg(6), MAXCOL, \0)
  409.    else
  410.       selectbuf = copies(\0, MAXCOL)
  411.    endif
  412. compile if EPM32
  413.  compile if EVERSION >= '6.01a'
  414.    if arg()>6 then
  415.       flags = arg(7)
  416.    else
  417.       flags = 0
  418.    endif
  419.  compile else
  420.    flags = 0
  421.  compile endif -- EVERSION >= '6.01a'
  422.    call dynalink32( ERES_DLL,                /* entry box control in EDLL dyna */
  423.              'ENTRYBOX',                     /* function name                 */
  424.               gethwndc(EPMINFO_EDITFRAME)||   /* edit frame handle             */
  425.               address(title)             ||   /*                               */
  426.               atol(0)                    ||   /* x coordinate                  */
  427.               atol(0)                    ||   /* y coordinate (0,0) = center   */
  428.               atol(columns)              ||
  429.               atol(maxchars)             ||
  430.               address(entrytext)         ||   /* (optional text in entry field)*/
  431.               atoi(nb)                   ||   /* Number of buttons, and        */
  432.               atoi(flags)                ||   /* flags:  mpfrom2short(flags, nb)*/
  433.               address(but1)              ||   /* (optional button 1 text )     */
  434.               address(but2)              ||   /* (optional button 2 text )     */
  435.               address(but3)              ||   /* (optional button 3 text )     */
  436.               address(but4)              ||   /* (optional button 4 text )     */
  437.               address(selectbuf))             /* return string buffer          */
  438. compile else
  439.    call dynalink( ERES_DLL,                /* entry box control in EDLL dyna */
  440.              'ENTRYBOX',                   /* function name                 */
  441.               gethwnd(EPMINFO_EDITFRAME) ||   /* edit frame handle             */
  442.               --atoi(0) || atoi(1)       ||
  443.               address(title)             ||   /*                               */
  444.               atoi(0)                    ||   /* x coordinate                  */
  445.               atoi(0)                    ||   /* y coordinate (0,0) = center   */
  446.               atoi(columns)              ||
  447.               atoi(maxchars)             ||
  448.               address(entrytext)         ||   /* (optional text in entry field)*/
  449.  compile if EVERSION >= 5.21
  450.               atoi(nb)                   ||   /* Number of buttons             */
  451.  compile endif
  452.               address(but1)              ||   /* (optional button 1 text )     */
  453.               address(but2)              ||   /* ( optional button 2 text )    */
  454.  compile if EVERSION >= 5.21
  455.               address(but3)              ||   /* (optional button 3 text )     */
  456.               address(but4)              ||   /* (optional button 4 text )     */
  457.  compile endif
  458.               address(selectbuf) )            /* return string buffer          */
  459. compile endif  -- EPM32
  460.  
  461. compile if EVERSION >= '5.21'
  462.    if arg(6) then return selectbuf; endif  -- New way
  463.    button = asc(leftstr(selectbuf,1))
  464.    if button=0 | button=2 then return ''; endif  -- Old way...
  465.    if button<>1 then return button; endif
  466.    EOS = pos(\0,selectbuf,2)        -- CHR(0) signifies End Of String
  467.    if not EOS then return 'error'; endif
  468.    return substr(selectbuf,2,EOS-2)
  469. compile else
  470.    EOS = pos(\0,selectbuf)        -- CHR(0) signifies End Of String
  471.    if not EOS then return 'error'; endif
  472.    return leftstr(selectbuf,EOS-1)
  473. compile endif
  474.  
  475. /*
  476. ╔════════════════════════════════════════════════════════════════════════════╗
  477. ║ EPM macro - EPM.EXE communication commands.                                ║
  478. ║                                                                            ║
  479. ║      togglefont      - toggle from large to small to large font            ║
  480. ║      commandline     - show commandline dialog [initialize with text]      ║
  481. ║      messagebox      - show message dialog box [optionally add to it]      ║
  482. ║      opendlg         - show open dialog box                                ║
  483. ║                                                                            ║
  484. ╚════════════════════════════════════════════════════════════════════════════╝
  485. */
  486.  
  487. /*
  488. ┌────────────────────────────────────────────────────────────────────────────┐
  489. │ what's it called: togglecontrol                                            │
  490. │                                                                            │
  491. │ what does it do : The command either toggles a EPM control window on or off│
  492. │                   or forces a EPM control window on or off.                │
  493. │                   arg1   = EPM control window handle ID.  Control window   │
  494. │                            ids given above.  The following windows handles │
  495. │                            are currently supported.                        │
  496. │                            EDITSTATUS, EDITVSCROLL, EDITHSCROLL, and       │
  497. │                            EDITMSGLINE.                                    │
  498. │                   arg2   [optional] = force option.                        │
  499. │                            a value of 0, forces control window off         │
  500. │                            a value of 1, forces control window on          │
  501. │                           IF this argument is not specified the window     │
  502. │                           in question is toggled.                          │
  503. │                                                                            │
  504. │                   This command is possible because of the EPM_EDIT_CONTROL │
  505. │                   EPM_EDIT_CONTROLSTATUS message.                          │
  506. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  507. │                    PACKAGE available on PCTOOLS.)                          │
  508. │                                                                            │
  509. │ who and when    : Jerry C.   2/27/89                                       │
  510. └────────────────────────────────────────────────────────────────────────────┘
  511. */
  512. defc togglecontrol
  513. compile if WANT_DYNAMIC_PROMPTS
  514.    universal menu_prompt
  515. compile endif
  516.    forceon=0
  517.    parse arg controlid fon
  518.    if fon<>'' then
  519.       forceon=(fon+1)*65536
  520. compile if (WANT_NODISMISS_MENUS | WANT_DYNAMIC_PROMPTS) & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  521.    else
  522.       fon = not querycontrol(controlid)  -- Query now, since toggling is asynch.
  523. compile endif  -- WANT_NODISMISS_MENUS
  524.    endif
  525.  
  526.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),
  527.                       5388,               -- EPM_EDIT_CONTROLTOGGLE
  528.                       controlid + forceon,
  529.                       0)
  530. compile if WANT_DYNAMIC_PROMPTS & EVERSION < 5.53 & not ALLOW_PROMPTING_AT_TOP
  531.    if controlid=23 then
  532.       if fon then  -- 1=top; 0=bottom.  If now top, turn off.
  533.          menu_prompt = 0
  534.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  535.          SetMenuAttribute( 422, 8192, 1)
  536.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  537.       endif
  538.    endif
  539. compile endif
  540. compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  541.    p = wordpos(controlid, '  7   8  10 20  22  23')
  542.    if p then       -->     === === === === === ===
  543.       menuid =       word('413 414 415 417 416 421', p)
  544.       SetMenuAttribute( menuid, 8192, not fon)
  545.    endif
  546. compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  547.  
  548. compile if EVERSION >= 5.53
  549. defc toggleframe
  550.  compile if WANT_DYNAMIC_PROMPTS
  551.    universal menu_prompt
  552.  compile endif
  553.    forceon=0
  554.    parse arg controlid fon
  555.    if fon<>'' then
  556.       forceon=(fon+1)*65536
  557. compile if (WANT_NODISMISS_MENUS | WANT_DYNAMIC_PROMPTS) & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  558.    else
  559.       fon = not queryframecontrol(controlid)  -- Query now, since toggling is asynch.
  560. compile endif  -- WANT_NODISMISS_MENUS
  561.    endif
  562.  
  563.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),
  564.                       5907,               -- EFRAMEM_TOGGLECONTROL
  565.                       controlid + forceon,
  566.                       0)
  567.  compile if WANT_DYNAMIC_PROMPTS & not ALLOW_PROMPTING_AT_TOP
  568.    if controlid=32 then
  569.       if fon then  -- 1=top; 0=bottom.  If now top, turn off.
  570.          menu_prompt = 0
  571.   compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  572.          SetMenuAttribute( 422, 8192, 1)
  573.   compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  574.       endif
  575.    endif
  576.  compile endif
  577.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  578.    p = wordpos(controlid, '  1   2   4  16 32')
  579.    if p then       -->     === === === === ===
  580.       menuid =       word('413 414 417 415 421', p)
  581.       SetMenuAttribute( menuid, 8192, not fon)
  582.    endif
  583.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  584.  
  585. defproc queryframecontrol(controlid)
  586.    return windowmessage(1,  getpminfo(EPMINFO_EDITFRAME),   -- Send message to edit client
  587.                         5907,               -- EFRAMEM_TOGGLECONTROL
  588.                         controlid,
  589.                         1)
  590. compile endif -- EVERSION >= 5.53
  591.  
  592. compile if WANT_DYNAMIC_PROMPTS
  593. defc toggleprompt
  594.    universal menu_prompt
  595.    menu_prompt = not menu_prompt
  596.  compile if not ALLOW_PROMPTING_AT_TOP
  597.    if menu_prompt then
  598.  compile if EVERSION < 5.53
  599.       'togglecontrol 23 0'    -- Force Extra window to bottom.
  600.  compile else
  601.       'toggleframe 32 0'      -- Force Extra window to bottom.
  602.  compile endif
  603.    endif
  604.  compile endif  -- not ALLOW_PROMPTING_AT_TOP
  605.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  606.    SetMenuAttribute( 422, 8192, not menu_prompt)
  607.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  608. compile endif
  609.  
  610. defc setscrolls
  611. compile if EVERSION >= 5.53
  612.    'toggleframe 8'
  613.    'toggleframe 16'
  614. compile else
  615.    'togglecontrol 9'
  616.    'togglecontrol 10'
  617.  compile if EVERSION < '5.50'
  618.    if not querycontrol(10) & not querycontrol(23) then
  619.       'togglecontrol 23 1'    -- Force Extra window to top.
  620.       sayerror 'Can not have info at bottom w/o scroll bars in EPM' EVERSION
  621.    endif
  622.  
  623.  
  624. defc toggle_info
  625.    'togglecontrol 23'
  626.    if not querycontrol(10) & not querycontrol(23) then
  627.       'togglecontrol 9 1'
  628.       'togglecontrol 10 1'
  629.       sayerror 'Can not have info at bottom w/o scroll bars in EPM' EVERSION
  630.    endif
  631.  compile endif
  632. compile endif  -- EVERSION >= 5.53
  633.  
  634. compile if EVERSION >= 5.60
  635. defc toggle_bitmap
  636.    universal bitmap_present, bm_filename
  637.    bitmap_present = not bitmap_present
  638. ;; bm_filename = ''
  639.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
  640.                       5498 - (44*bitmap_present), 0, 0)
  641.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  642.    SetMenuAttribute( 437, 8192, not bitmap_present)
  643.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  644.  
  645.  compile if EPM32
  646. defc load_dt_bitmap
  647.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
  648.                       5499,            -- EPM_EDIT_SETDTBITMAPFROMFILE
  649.                       put_in_buffer(arg(1)),
  650.                       0)
  651.  
  652. defc drop_bitmap
  653.    universal bm_filename
  654.    parse arg x y bm_filename
  655.    'load_dt_bitmap' bm_filename
  656.  compile else
  657. defc drop_bitmap
  658.    parse arg . . bm_filename
  659.    call winmessagebox(bm_filename, 'Can not drop bitmaps on pre-6.00 versions of editor.', MB_CANCEL + MB_CUAWARNING + MB_MOVEABLE)
  660.  compile endif
  661. compile endif  -- EVERSION >= 5.60
  662.  
  663. defproc querycontrol(controlid)
  664.    return windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),   -- Send message to edit client
  665.                         5388,               -- EPM_EDIT_CONTROLTOGGLE
  666.                         controlid,
  667.                         1)
  668.  
  669. defc cursoroff=call cursoroff()    -- Turn cursor off
  670. defproc cursoroff           -- Turn cursor off
  671.     'togglecontrol 14 0'
  672.  
  673. ; Trim window so it's an exact multiple of the font size.
  674. defc trim=call windowsize1(.windowheight,.windowwidth,0,0,1)
  675.  
  676. defc windowsize1
  677.    parse arg row col x y flag junk
  678.    if x='' | junk<>'' then
  679.       sayerror -263  -- Invalid argument
  680.    else
  681.       call windowsize1(row,col,x,y,flag)
  682.    endif
  683.  
  684. defproc windowsize1(row,col,x,y)
  685.  
  686.    if upcase(leftstr(row,1))='P' then  -- Already in pels
  687.       cy = substr(row,2)
  688.    else
  689.       cy = .fontheight *  row          -- convert row into y coordinate in pels
  690.    endif
  691.    if upcase(leftstr(col,1))='P' then  -- Already in pels
  692.       cx = substr(col,2)
  693.    else
  694.       cx = .fontwidth * col            -- convert col into x coordinate in pels
  695.    endif
  696.  
  697.    if arg(5)<>'' then opts=arg(5); else opts=3; endif  -- Default = SWP_SIZE (1) + SWP_MOVE (2)
  698.  
  699.    if opts // 2 then                        -- Don't bother calculating unless SWP_SIZE on
  700. compile if EPM32
  701.       swp1 = copies(\0, 36)
  702.       swp2 = swp1
  703.       call dynalink32('PMWIN',
  704.                       '#837',
  705.                       gethwndc(EPMINFO_EDITCLIENT)  ||
  706.                       address(swp1) )
  707.       call dynalink32('PMWIN',
  708.                       '#837',
  709.                       gethwndc(EPMINFO_EDITFRAME)   ||
  710.                       address(swp2) )
  711.       cx = cx + ltoa(substr(swp2,9,4),10) - ltoa(substr(swp1,9,4),10)
  712.       cy = cy + ltoa(substr(swp2,5,4),10) - ltoa(substr(swp1,5,4),10)
  713.    endif
  714.  
  715.    call dynalink32( 'PMWIN',
  716.                     '#875',
  717.                     gethwndc(EPMINFO_EDITFRAME) ||
  718.                     atol(3)                    ||      /* HWND_TOP   */
  719.                     atol(x)                    ||
  720.                     atol(y)                    ||
  721.                     atol(cx)                   ||
  722.                     atol(cy)                   ||
  723.                     atol(opts))                        /* SWP_MOVE | SWP_SIZE */
  724. compile else
  725.       swp1 = copies(\0,18)
  726.       swp2 = swp1
  727.       call dynalink('PMWIN',
  728.                     'WINQUERYWINDOWPOS',
  729.                      gethwnd(EPMINFO_EDITCLIENT)  ||
  730.                      address(swp1) )
  731.       call dynalink('PMWIN',
  732.                     'WINQUERYWINDOWPOS',
  733.                      gethwnd(EPMINFO_EDITFRAME)   ||
  734.                      address(swp2) )
  735.       cx = cx + itoa(substr(swp2,5,2),10) - itoa(substr(swp1,5,2),10)
  736.       cy = cy + itoa(substr(swp2,3,2),10) - itoa(substr(swp1,3,2),10)
  737.    endif
  738.  
  739.    call dynalink( 'PMWIN',
  740.              'WINSETWINDOWPOS',
  741.               gethwnd(EPMINFO_EDITFRAME) ||
  742.               atoi(0) || atoi(3)         ||      /* HWND_TOP   */
  743.               atoi(x)                    ||
  744.               atoi(y)                    ||
  745.               atoi(cx)                   ||
  746.               atoi(cy)                   ||
  747.               atoi(opts))                        /* SWP_MOVE | SWP_SIZE */
  748. compile endif  -- EPM32
  749.  
  750. compile if 0  -- Unused, so don't waste space.  LAM
  751. defc qcontrol
  752.    if querycontrol(arg(1))  then
  753.       sayerror 'control on'
  754.    else
  755.       sayerror 'control off'
  756.    endif
  757. compile endif
  758.  
  759. /*
  760. ┌────────────────────────────────────────────────────────────────────────────┐
  761. │ what's it called: fontlist                                                 │
  762. │                                                                            │
  763. │ what does it do : Display a listbox containing the possible font cell sizes│
  764. │                   for the particular display type being used.              │
  765. │                   The font dimensions are extracted from the fontlist str. │
  766. │                                                                            │
  767. │ who and when    : Jerry C.  11/04/89                                       │
  768. └────────────────────────────────────────────────────────────────────────────┘
  769. */
  770. compile if EVERSION < 5.50      -- AVIO version
  771.    defc fontlist
  772.  compile if EVERSION >= 5.20  -- 5.20 beta 5; added a change font dialog.
  773.       call windowmessage(0,  getpminfo(APP_HANDLE),
  774.                          5138,               -- EPM_POPAVIOFONTDIALOG
  775.                          0,
  776.                          .fontwidth*65536 + .fontheight )
  777.  compile else
  778.       fontlist= '/1. 8 x 14  (Large)  '||
  779.                 '/2. 8 x 8  (Small)  '
  780.       if dos_version()>=1020 then
  781.  compile if EVERSION < 5.20
  782.          fontlist= '/8. 12 x 30  (Large)'||
  783.                    '/7. 12 x 22'  ||
  784.                    '/6. 12 x 20'  ||
  785.                    '/5. 12 x 16'  ||
  786.                    '/4. 8 x 17  (Medium)  '||
  787.                    '/3. 8 x 8'    ||
  788.                    '/2. 7 x 25'   ||
  789.                    '/1. 7 x 15  (Small)'
  790.  compile else
  791.          outcount = atol(248)        -- Room for 31 pairs of longs
  792.          outdata = copies(' ',248)
  793.          r =  dynalink( 'PMGPI',     -- Returns 1 if OK; 0 if not implemented; -1 if error
  794.                         'DEVESCAPE',
  795.                         gethwnd(EPMINFO_HDC)  ||
  796.                         atol_swap(2)          ||  -- DEVESC_QUERYVIOCELLSIZES
  797.                         atol(0)               ||  -- incount
  798.                         atol(0)               ||  -- indata
  799.                         address(outcount)    ||
  800.                         address(outdata) )
  801.          if r=1 then
  802.             n = ltoa(substr(outdata,5,4),10)
  803.             fontlist = ''
  804.             do i = (n*8+1) to 9 by -8
  805.                fontlist = fontlist'/'n'.' ltoa(substr(outdata,i,4),10) 'x' ltoa(substr(outdata,i+4,4),10)
  806.                n=n-1
  807.             enddo
  808.          endif
  809.  compile endif
  810.       endif
  811.  
  812.       do forever
  813.         retvalue=listbox(FONTLIST_PROMPT__MSG .fontwidth 'x' .fontheight,fontlist,'/'SELECT__MSG'/'CANCEL__MSG'/'HELP__MSG,2,screenwidth()/2)
  814.         if retvalue<>3 then leave; endif
  815.         'helpmenu 6010'
  816.       enddo
  817.  
  818.       if retvalue then
  819.          parse value retvalue with . width . height .
  820.          -- sayerror 'height and width =('height','width')'
  821.          call setfont(width, height)
  822.       endif
  823.  compile endif
  824. compile else      -- GPI version
  825.  
  826.    defc fontlist
  827.        call windowmessage(0,  getpminfo(APP_HANDLE),
  828.                          5130,               -- EPM_POPFONTDLG
  829.                          put_in_buffer(queryfont(.font)'.'trunc(.textcolor//16)'.'.textcolor%16),
  830.                          0)
  831.    defc processfontrequest
  832.    universal default_font
  833.  compile if EVERSION >= '6.00c'
  834.    universal statfont, msgfont
  835.    universal appname, app_hini
  836.  compile endif  -- EVERSION >= '6.00c'
  837.       parse value arg(1) with fontname '.' fontsize '.' fontsel '.' setfont '.' markedonly '.' fg '.' bg
  838.       -- sayerror 'Fontname=' fontname ' Fontsize=' fontsize 'Fontsel=' fontsel 'arg(1)="'arg(1)'"'
  839.  compile if EVERSION >= '6.00c'
  840.       if markedonly = 2 then  -- Statusline font
  841.          statfont = fontsize'.'fontname'.'fontsel
  842.          "setstatface" getpminfo(EPMINFO_EDITSTATUSHWND) fontname
  843.          "setstatptsize" getpminfo(EPMINFO_EDITSTATUSHWND) fontsize
  844.          if setfont then
  845.             call setprofile( app_hini, appname, INI_STATUSFONT, statfont)
  846.          endif
  847.          return
  848.       endif  -- markedonly = 2
  849.       if markedonly = 3 then  -- Messageline font
  850.          msgfont = fontsize'.'fontname'.'fontsel
  851.          "setstatface" getpminfo(EPMINFO_EDITMSGHWND) fontname
  852.          "setstatptsize" getpminfo(EPMINFO_EDITMSGHWND) fontsize
  853.          if setfont then
  854.             call setprofile( app_hini, appname, INI_MESSAGEFONT, msgfont)
  855.          endif
  856.          return
  857.       endif  -- markedonly = 3
  858.  compile endif  -- EVERSION >= '6.00c'
  859.  
  860.       fontid=registerfont(fontname, fontsize, fontsel)
  861.  
  862.       if setfont & not markedonly then
  863.  compile if WANT_APPLICATION_INI_FILE
  864.          call setini( INI_FONT, fontname'.'fontsize'.'fontsel, 1)
  865.  compile endif
  866.          getfileid startid
  867.          display -1
  868.          do i=1 to filesinring(1)
  869.             if .font=default_font then
  870.                .font = fontid
  871.             endif
  872.             next_file
  873.             getfileid curfile
  874.             if curfile = startid then leave; endif
  875.          enddo  -- Loop through all files in ring
  876.          activatefile startid  -- Make sure we're back where we started (in case was .HIDDEN)
  877.          display 1
  878.          default_font = fontid
  879.       endif
  880.  
  881.       if markedonly then
  882.         -- insert font attribute within marked area only!
  883.  
  884.          themarktype = marktype()
  885.          if not themarktype then             /* check if mark exists              */
  886.             sayerror NO_MARK__MSG
  887.             return                           /* if mark doesn't exist, return     */
  888.          endif
  889.          getmark fstline,                    /* returned:  first line of mark     */
  890.                  lstline,                    /* returned:  last  line of mark     */
  891.                  fstcol,                     /* returned:  first column of mark   */
  892.                  lstcol,                     /* returned:  last  column of mark   */
  893.                  mkfileid                    /* returned:  file id of marked file */
  894.          if fontid <> .font then
  895.             call attribute_on(4)  -- Mixed fonts flag
  896.             addfont = 1
  897.          else
  898.  compile if EVERSION >= '6.01b'
  899.             addfont = .levelofattributesupport bitand 4
  900.  compile else
  901.             addfont = .levelofattributesupport%4 - 2*(.levelofattributesupport%(8))
  902.  compile endif
  903.          endif
  904.          if bg<>'' then
  905.             fg = bg*16+fg
  906.             call attribute_on(1)  -- Colors flag
  907.          endif
  908.          if themarktype='BLOCK' then
  909.             do i = fstline to lstline
  910.                if addfont then
  911.                   Insert_Attribute_Pair(16, fontid, i, i, fstcol, lstcol, mkfileid)
  912.                endif
  913.                if bg<>'' then
  914.                   Insert_Attribute_Pair(1, fg, i, i, fstcol, lstcol, mkfileid)
  915.                endif
  916.             enddo
  917.          else
  918.             if themarktype='LINE' then
  919.                getline line, lstline, mkfileid
  920.                lstcol=length(line)
  921.             endif
  922.             if addfont then
  923.                Insert_Attribute_Pair(16, fontid, fstline, lstline, fstcol, lstcol, mkfileid)
  924.             endif
  925.             if bg<>'' then
  926.                Insert_Attribute_Pair(1, fg, fstline, lstline, fstcol, lstcol, mkfileid)
  927.             endif
  928.          endif
  929.          call attribute_on(8)  -- "Save attributes" flag
  930.       else
  931.          .font = fontid
  932.       endif
  933.  
  934. defc Process_Style
  935. compile if WANT_APPLICATION_INI_FILE
  936.    universal app_hini
  937.    universal EPM_utility_array_ID
  938.    call checkmark()     -- verify there is a marked area,
  939.    parse arg stylename   -- can include spaces
  940.    stylestuff = queryprofile(app_hini, 'Style', stylename)
  941.    if stylestuff='' then return; endif  -- Shouldn't happen
  942.    parse value stylestuff with fontname '.' fontsize '.' fontsel '.' fg '.' bg
  943.    getmark fstline, lstline, fstcol, lstcol, mkfileid
  944.    if get_array_value(EPM_utility_array_ID, 'sn.'stylename, styleindex) then  -- See if we have an index
  945.       do_array 3, EPM_utility_array_ID, 'si.0', styleindex          -- Get the
  946.       styleindex = styleindex + 1                                 --   next index
  947.       do_array 2, EPM_utility_array_ID, 'si.0', styleindex          -- Save next index
  948.       do_array 2, EPM_utility_array_ID, 'si.'styleindex, stylename  -- Save index.name
  949.       do_array 2, EPM_utility_array_ID, 'sn.'stylename, styleindex  -- Save name.index
  950.    endif
  951.    oldmod = .modify
  952.    if bg<>'' then
  953. ;;    fg = 256 + bg*16 + fg
  954.       fg = bg*16 + fg
  955.       if marktype()='BLOCK' then
  956.          do i = fstline to lstline
  957.             Insert_Attribute_Pair(1, fg, i, i, fstcol, lstcol, mkfileid)
  958.          enddo
  959.       else
  960.          if marktype()='LINE' then
  961.             getline line, lstline, mkfileid
  962.             lstcol=length(line)
  963.          endif
  964.          Insert_Attribute_Pair(1, fg, fstline, lstline, fstcol, lstcol, mkfileid)
  965.       endif
  966.       call attribute_on(1)  -- Colors flag
  967.    endif
  968.    if fontsel<>'' then
  969.       call attribute_on(4)  -- Mixed fonts flag
  970.       fontid=registerfont(fontname, fontsize, fontsel)
  971.       if marktype()='BLOCK' then
  972.          do i = fstline to lstline
  973.             Insert_Attribute_Pair(16, fontid, i, i, fstcol, lstcol, mkfileid)
  974.          enddo
  975.       else
  976.          Insert_Attribute_Pair(16, fontid, fstline, lstline, fstcol, lstcol, mkfileid)
  977.       endif
  978.    endif
  979.    Insert_Attribute_Pair(14, styleindex, fstline, lstline, fstcol, lstcol, mkfileid)
  980.    call attribute_on(8)  -- "Save attributes" flag
  981.    .modify = oldmod + 1
  982. compile else
  983.    sayerror 'WANT_APPLICATION_INI_FILE = 0'
  984. compile endif -- WANT_APPLICATION_INI_FILE
  985.  
  986. defc ChangeStyle
  987. compile if WANT_APPLICATION_INI_FILE
  988.    universal app_hini
  989.    universal EPM_utility_array_ID
  990.    parse arg stylename  -- Can include spaces
  991.    if get_array_value(EPM_utility_array_ID, 'sn.'stylename, styleindex) then
  992.       return  -- If not known, then we're not using it, so nothing to do.
  993.    endif
  994.    stylestuff = queryprofile(app_hini, 'Style', stylename)
  995.    if stylestuff='' then return; endif  -- Shouldn't happen
  996.    parse value stylestuff with fontname '.' fontsize '.' fontsel '.' fg '.' bg
  997.    getfileid startid
  998.    fontid=registerfont(fontname, fontsize, fontsel)
  999.    fg = bg*16 + fg
  1000.    do i=1 to filesinring(1)  -- Provide an upper limit; prevent looping forever
  1001.  compile if EVERSION >= '6.01b'
  1002.       if .levelofattributesupport bitand 8 then  -- Is attribute 8 on?
  1003.  compile else
  1004.       if (.levelofattributesupport%8 - 2*(.levelofattributesupport%16)) then  -- Is attribute 8 on?
  1005.  compile endif
  1006.                                                                  -- "Save attributes" flag
  1007.          line=0; col=1; offst=0
  1008.          do forever
  1009.             class = 14  -- STYLE_CLASS
  1010.             attribute_action 1, class, offst, col, line -- 1=FIND NEXT ATTR
  1011.             if class=0 then leave; endif  -- not found
  1012.             query_attribute class, val, IsPush, offst, col, line
  1013.             if val=styleindex then  -- If it's this style, then...
  1014.                offst = offst+1
  1015.                query_attribute class, val, IsPush, offst, col, line
  1016.                if class=16 & val<>fontid then  -- Replace the font ID (if changed)
  1017.                   insert_attribute class, fontid, IsPush, offst, col, line
  1018.                   attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP
  1019.                endif
  1020.                offst = offst+1
  1021.                query_attribute class, val, IsPush, offst, col, line
  1022.                if class=1 & val<>fg then  -- Replace the color attribute (if changed)
  1023.                   insert_attribute class, fg, IsPush, offst, col, line
  1024.                   attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP
  1025.                endif
  1026.             endif
  1027.          enddo  -- Loop looking for STYLE_CLASS in current file
  1028.       endif  -- "Save attributes" flag
  1029.       next_file
  1030.       getfileid curfile
  1031.       if curfile = startid then leave; endif
  1032.    enddo  -- Loop through all files in ring
  1033.    activatefile startid  -- Make sure we're back where we started (in case was .HIDDEN)
  1034. compile else
  1035.    sayerror 'WANT_APPLICATION_INI_FILE = 0'
  1036. compile endif -- WANT_APPLICATION_INI_FILE
  1037.  
  1038. defc Delete_Style
  1039. compile if WANT_APPLICATION_INI_FILE
  1040.    universal app_hini
  1041.    universal EPM_utility_array_ID
  1042.    stylename = arg(1)
  1043.    stylestuff = queryprofile(app_hini, 'Style', stylename)
  1044.    call setprofile(app_hini, 'Style', stylename, '')
  1045.    if stylestuff='' then return; endif  -- Shouldn't happen
  1046.    if get_array_value(EPM_utility_array_ID, 'sn.'stylename, styleindex) then
  1047.       return  -- If not known, then we're not using it, so nothing to do.
  1048.    endif
  1049. ;  parse value stylestuff with fontname '.' fontsize '.' fontsel '.' fg '.' bg
  1050.    getfileid startid
  1051. ;  fontid=registerfont(fontname, fontsize, fontsel)
  1052. ;  fg = bg*16 + fg
  1053.    do i=1 to filesinring(1)  -- Provide an upper limit; prevent looping forever
  1054.  compile if EVERSION >= '6.01b'
  1055.       if .levelofattributesupport bitand 8 then  -- Is attribute 8 on?
  1056.  compile else
  1057.       if .levelofattributesupport%8 - 2*(.levelofattributesupport%16) then  -- Is attribute 8 on?
  1058.  compile endif
  1059.                    -- "Save attributes" flag --> using styles in this file
  1060.          oldmod = .modify
  1061.          line=0; col=1; offst=0
  1062.          do forever
  1063.             class = 14  -- STYLE_CLASS
  1064.             attribute_action 1, class, offst, col, line -- 1=FIND NEXT ATTR
  1065.             if class=0 then  -- not found
  1066.                if .modify <> oldmod then  -- We've deleted at least one...
  1067.                    call delete_ea('EPM.STYLES')
  1068.                    call delete_ea('EPM.ATTRIBUTES')
  1069.                   .modify = oldmod + 1  -- ...count as a single change.
  1070.                endif
  1071.                leave
  1072.             endif
  1073.             query_attribute class, val, IsPush, offst, col, line
  1074.             if val=styleindex then  -- If it's this style, then...
  1075.                attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP
  1076.                offst = offst+1
  1077.                query_attribute class, val, IsPush, offst, col, line
  1078.                if class=16 then  -- Delete the font ID
  1079.                   attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP
  1080.                endif
  1081.                offst = offst+1
  1082.                query_attribute class, val, IsPush, offst, col, line
  1083.                if class=1 then  -- Delete the color attribute
  1084.                   attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP
  1085.                endif
  1086.             endif
  1087.          enddo  -- Loop looking for STYLE_CLASS in current file
  1088.       endif  -- "Save attributes" flag
  1089.       next_file
  1090.       getfileid curfile
  1091.       if curfile = startid then leave; endif
  1092.    enddo  -- Loop through all files in ring
  1093.    activatefile startid  -- Make sure we're back where we started (in case was .HIDDEN)
  1094. compile else
  1095.    sayerror 'WANT_APPLICATION_INI_FILE = 0'
  1096. compile endif -- WANT_APPLICATION_INI_FILE
  1097.  
  1098. defc monofont
  1099.    parse value queryfont(.font) with fontname '.' fontsize '.'
  1100.    if fontname<>'Courier' & fontname<>'System Monospaced' then
  1101.       if rightstr(fontsize,2)='BB' then  -- Bitmapped font
  1102.          parse value fontsize with 'DD' decipoints 'WW' width 'HH' height 'BB'
  1103.          if width & height then  -- It's fixed pitch
  1104.             return
  1105.          endif
  1106.       endif
  1107.       .font = registerfont('System Monospaced', SYS_MONOSPACED_SIZE, 0)
  1108.    endif
  1109. compile endif  -- GPI version
  1110.  
  1111. /*
  1112. ┌────────────────────────────────────────────────────────────────────────────┐
  1113. │ what's it called: Get_Array_Value(array_ID, array_index, value)            │
  1114. │                                                                            │
  1115. │ what does it do : Looks up the index in the array, and if found, puts the  │
  1116. │                   value in VALUE.  The result returned for the function    │
  1117. │                   is the return code from the array lookup - 0 if          │
  1118. │                   successful.  If the index wasn't found, VALUE will       │
  1119. │                   contain the null string.                                 │
  1120. │                                                                            │
  1121. │ who and when    : Larry M.   9/12/91                                       │
  1122. └────────────────────────────────────────────────────────────────────────────┘
  1123. */
  1124. defproc get_array_value(array_ID, array_index, var array_value)
  1125.    rc = 0
  1126.    array_value = ''
  1127.    display -2
  1128.    do_array 3, array_ID, array_index, array_value
  1129.    display 2
  1130.    return rc
  1131.  
  1132. defproc Insert_Attribute_Pair(attribute, val, fstline, lstline, fstcol, lstcol, fileid)
  1133.    universal EPM_utility_array_ID
  1134. ;sayerror 'Insert_Attribute_Pair('attribute',' val',' fstline',' lstline',' fstcol',' lstcol',' fileid')'
  1135.    class = attribute
  1136.    offst1 = -255
  1137.    col = fstcol
  1138.    line = fstline
  1139.    pairoffst = -255
  1140.    attribute_action 1, class, offst1, col, line, fileid -- 1=FIND NEXT ATTR
  1141. ;sayerror 'attribute_action FIND NEXT ATTR,' class',' offst1',' col',' line',' fileid -- 1=FIND NEXT ATTR
  1142.    if class & col = fstcol & line = fstline  then  -- Found one!
  1143.       offst2 = offst1
  1144.       attribute_action 3, class, offst2, col, line, fileid -- 3=FIND MATCH ATTR
  1145. ;sayerror 'attribute_action FIND MATCH ATTR,' class',' offst2',' col',' line',' fileid -- 1=FIND NEXT ATTR
  1146.       if class then
  1147.          lc1 = lstcol + 1
  1148.          if line=lstline & col=lc1 then  -- beginning and end match, so replace the old attributes
  1149. compile if defined(COMPILING_FOR_ULTIMAIL)
  1150.             replace_it = 1
  1151.             if class=14 then  -- STYLE_CLASS
  1152.                query_attribute class, val2, IsPush, offst1, fstcol, fstline, fileid
  1153.                do_array 3, EPM_utility_array_ID, 'si.'val, stylename -- Get the style name
  1154.                is_color1 = wordpos(stylename, "black blue red pink green cyan yellow white darkgray darkblue darkred darkpink darkgreen darkcyan brown palegray")
  1155.                do_array 3, EPM_utility_array_ID, 'si.'val2, stylename -- "
  1156.                is_color2 = wordpos(stylename, "black blue red pink green cyan yellow white darkgray darkblue darkred darkpink darkgreen darkcyan brown palegray")
  1157.                if (is_color1 & not is_color2) | (is_color2 & not is_color1) then
  1158.                   replace_it = 0
  1159.                endif
  1160.             endif
  1161.             if replace_it then
  1162. compile endif
  1163.                attribute_action 16, class, offst1, fstcol, fstline, fileid -- 16=DELETE ATTR
  1164. ;sayerror 'attribute_action DELETE ATTR,' class',' offst1',' fstcol',' fstline',' fileid -- 1=FIND NEXT ATTR
  1165.                attribute_action 16, class, offst2, lc1, lstline, fileid -- 16=DELETE ATTR
  1166. ;sayerror 'attribute_action DELETE ATTR,' class',' offst2',' lc1',' lstline',' fileid -- 1=FIND NEXT ATTR
  1167.                pairoffst = offst1 + 1
  1168.                if not pairoffst then
  1169.                   lstcol = lc1
  1170.                endif
  1171. compile if defined(COMPILING_FOR_ULTIMAIL)
  1172.             endif
  1173. compile endif
  1174.          elseif line>lstline | (line=lstline & col>lstcol) then  -- old range larger then new
  1175. ;sayerror 'pair offset set to 0'
  1176.             pairoffst = 0  -- so add attributes on the inside.
  1177.             lstcol = lc1
  1178.          endif
  1179.       endif
  1180. compile if 1  -- Disallow overlapping attributes.
  1181.    else  -- While we have an attribute that's before the desired endpoint, ...
  1182.       do while class & (line < lstline | (line = lstline & col < lstcol))  -- Found one; check for overlap
  1183.          query_attribute class, val2, IsPush, offst1, col, line, fileid
  1184.          if not IsPush then  -- Found a pop before a push!
  1185.             sayerror OVERLAPPING_ATTRIBS__MSG
  1186.             return
  1187.          endif
  1188.          offst2 = offst1
  1189.          col2 = col
  1190.          line2 = line
  1191.          attribute_action 3, class, offst2, col2, line2, fileid -- 3=FIND MATCH ATTR
  1192. ;sayerror 'attribute_action FIND MATCH ATTR,' class',' offst2',' col2',' line2',' fileid -- 1=FIND NEXT ATTR
  1193.          if not class then  -- No match?  Most curious...
  1194.             leave
  1195.          endif
  1196.          if line2 > lstline | (line2 = lstline & col2 > lstcol) then
  1197.             sayerror OVERLAPPING_ATTRIBS__MSG
  1198.             return
  1199.          endif
  1200.          offst1 = offst2 + 1
  1201.          col = col2
  1202.          line = line2
  1203.          attribute_action 1, class, offst1, col, line, fileid -- 1=FIND NEXT ATTR
  1204. ;sayerror 'attribute_action FIND NEXT ATTR,' class',' offst1',' col',' line',' fileid -- 1=FIND NEXT ATTR
  1205.       enddo
  1206. compile endif
  1207.    endif
  1208.    insert_attribute attribute, val, 1, pairoffst, fstcol, fstline, fileid
  1209.    insert_attribute attribute, val, 0, -pairoffst, lstcol, lstline, fileid
  1210.  
  1211. ; Turns on the specified bit (1, 2, 4, etc.) and returns 0 or 1 depending
  1212. ; on whether it was originally off or on.
  1213. defproc attribute_on(bit)
  1214. compile if EVERSION >= '6.01b'
  1215.    flag = (.levelofattributesupport bitand bit) <> 0
  1216. compile else
  1217.    flag = .levelofattributesupport%bit - 2*(.levelofattributesupport%(bit*2))
  1218. compile endif
  1219.    if not flag then  -- Is that bit off?
  1220.       .levelofattributesupport = .levelofattributesupport + bit  -- Turn it on!
  1221.    endif
  1222.    return flag
  1223.  
  1224. /*
  1225. ┌────────────────────────────────────────────────────────────────────────────┐
  1226. │ what's it called: setfont                                                  │
  1227. │                                                                            │
  1228. │ what does it do : Send change font message to editor.                      │
  1229. │                   Arguments are the font cell width and the font cell      │
  1230. │                   height.  example:  setfont(7, 15)                        │
  1231. │                                                                            │
  1232. │                                                                            │
  1233. │ who and when    : Jerry C.  11/04/89                                       │
  1234. └────────────────────────────────────────────────────────────────────────────┘
  1235. */
  1236. defproc setfont(width, height)
  1237.    call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),   -- Post message to edit client
  1238.                       5381,               -- EPM_EDIT_CHANGEFONT
  1239.                       height,
  1240.                       width)
  1241.  
  1242. compile if EVERSION < 5.21
  1243. /*
  1244. ┌────────────────────────────────────────────────────────────────────────────┐
  1245. │ what's it called: togglefont                                               │
  1246. │                                                                            │
  1247. │ what does it do : toggle from large to small font using by sending the     │
  1248. │                   current edit window a EPM_EDIT_CHANGEFONT message.       │
  1249. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1250. │                    PACKAGE available on PCTOOLS.)                          │
  1251. │                                                                            │
  1252. │ universals      : the universal variable 'font' is used to keep track of   │
  1253. │                   the current font state.                                  │
  1254. │                                                                            │
  1255. │ who and when    : Jerry C.   2/27/89                                       │
  1256. └────────────────────────────────────────────────────────────────────────────┘
  1257. */
  1258. defc togglefont
  1259.    universal font,defaultmenu
  1260.  compile if INCLUDE_MENU_SUPPORT
  1261.    if font then                                 /* large font is active    */
  1262.       font = FALSE                              /* about to change to small*/
  1263.       buildmenuitem  defaultmenu,               /* replace text in option..*/
  1264.                      4, 408,                    /* menu.                   */
  1265.                      LARGE_FONT_MENU__MSG,
  1266.                      'togglefont'LARGE_FONT_MENUP__MSG,0,mpfrom2short(HP_OPTIONS_FONT, 0)
  1267.    else                                         /* small font is active    */
  1268.       font = TRUE                               /* about to change to large*/
  1269.       buildmenuitem  defaultmenu,               /* replace text in option..*/
  1270.                      4, 408,                    /* menu.                   */
  1271.                      SMALL_FONT_MENU__MSG,
  1272.                      'togglefont'SMALL_FONT_MENUP__MSG,0,mpfrom2short(HP_OPTIONS_FONT, 0)
  1273.    endif
  1274.  
  1275.    showmenu defaultmenu                         /* activate above changes  */
  1276.                                                 /* in the menu             */
  1277.  compile endif
  1278.    call setfont(0, 0)                           /* change font             */
  1279. compile endif
  1280.  
  1281. ----------------------------------------------------------------------------
  1282. ----  UNDO   JAC 11/90
  1283. ----------------------------------------------------------------------------
  1284. defc processundo
  1285.    --undoaction 1, PresentState;
  1286.    --undoaction 2, OldestState;
  1287.    CurrentUndoState=arg(1)
  1288.    --
  1289.    --if CurrentUndoState<OldestState then
  1290.    --  return
  1291.    --endif
  1292.    --sayerror 'Undoing State ' CurrentUndoState ' old='OldestState ' new='PresentState
  1293.    undoaction 7, CurrentUndoState;
  1294.    --refresh;
  1295.  
  1296. defc restoreundo
  1297.    action=1
  1298.    undoaction 5, action;
  1299.  
  1300. defc renderundoinfo
  1301.     undoaction 1, PresentState        -- Do to fix range, not for value.
  1302. ;   undoaction 2, OldestState;
  1303. ;   statestr=PresentState OldestState \0
  1304.     undoaction 6, StateRange               -- query range
  1305.     parse value staterange with oldeststate neweststate
  1306.     statestr=newestState oldeststate\0
  1307.     action=1
  1308.     undoaction 4, action
  1309.     -- sayerror '<'statestr'>'
  1310.     call windowmessage(1,  arg(1),   -- send message back to dialog
  1311.                        32,               -- WM_COMMAND - 0x0020
  1312.                        9999,
  1313.                        ltoa(offset(statestr) || selector(statestr), 10) )
  1314.  
  1315. defc undodlg
  1316. ;   undoaction 1, PresentState        -- Do to fix range, not for value.
  1317. ;   undoaction 6, StateRange               -- query range
  1318. ;   parse value staterange with oldeststate neweststate
  1319. ;   if oldeststate=neweststate  then
  1320. ;      sayerror 'No other undo states recorded.'
  1321. ;   else
  1322.        call windowmessage(0,  getpminfo(APP_HANDLE),
  1323.                          5131,               -- EPM_POPUNDODLG
  1324.                          0,
  1325.                          0)
  1326. ;   endif
  1327.  
  1328. /*
  1329. ┌────────────────────────────────────────────────────────────────────────────┐
  1330. │ what's it called: commandline     syntax:  commandline [optional text]     │
  1331. │                                                                            │
  1332. │ what does it do : ask EPM.EXE to pop up its internal commandline control.  │
  1333. │                   This is done by posting a EPM_POPCMDLINE message to the  │
  1334. │                   EPM Book window.                                         │
  1335. │                   An optional string of text can be specified.  If a string│
  1336. │                   is specified then it will be inserted on the command line│
  1337. │                                                                            │
  1338. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1339. │                    PACKAGE available on PCTOOLS.)                          │
  1340. │                                                                            │
  1341. │ who and when    : Jerry C.   2/27/89                                       │
  1342. └────────────────────────────────────────────────────────────────────────────┘
  1343. */
  1344. defc commandline  -- The application will free the buffer allocated by this macro !!!
  1345.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1346.                       5124,               -- EPM_POPCMDLINE
  1347.                       0,
  1348.                       put_in_buffer(arg(1)) )
  1349.  
  1350.  
  1351. /*
  1352. ┌────────────────────────────────────────────────────────────────────────────┐
  1353. │ what's it called: PostCmdToEditWindow(cmd, winhandle [, mp2 [, buflg]] )   │
  1354. │                                                                            │
  1355. │ what does it do : ask EPM.EXE to post a command to an edit window.  MP2 is │
  1356. │                   optional MP2 for the WinPostMsg.  Default is 1 (EPM      │
  1357. │                   should free the command buffer).  4 means process        │
  1358. │                   synchronously (not safe), and 8 means that EPM should do │
  1359. │                   a DosGetBuf to get the buffer.  Optional 4th argument is │
  1360. │                   passed to put_in_buffer (flag for DosAllocSeg; see       │
  1361. │                   put_in_buffer routine for details).                      │
  1362. │                                                                            │
  1363. │ who and when    : Larry M.   7/23/90                                       │
  1364. └────────────────────────────────────────────────────────────────────────────┘
  1365. */
  1366. defproc PostCmdToEditWindow(cmd,winhndl)
  1367.    if arg(3)<>'' then mp2=arg(3); else mp2=1; endif
  1368.    call windowmessage(0,  winhndl,
  1369.                       5377,               -- EPM_EDIT_COMMAND
  1370.                       put_in_buffer(cmd,arg(4)),
  1371.                       mp2)
  1372.  
  1373. /*
  1374. ┌────────────────────────────────────────────────────────────────────────────┐
  1375. │ what's it called: PostMe          syntax:   PostMe command                 │
  1376. │                                                                            │
  1377. │ what does it do : Ask EPM.EXE to post a command to the current edit window.│
  1378. │                   Useful if you want to send a command on an OPEN but      │
  1379. │                   don't want to tie up the main queue while the command is │
  1380. │                   executing.  By posting the command back to the window,   │
  1381. │                   it will execute from the EI queue, and not keep everyone │
  1382. │                   else waiting.                                            │
  1383. │                                                                            │
  1384. │                   Example of usage:                                        │
  1385. │                      "open 'PostMe long_running_command'"                  │
  1386. │                                                                            │
  1387. │ who and when    : Larry M.   89/08/14                                      │
  1388. └────────────────────────────────────────────────────────────────────────────┘
  1389. */
  1390. defc PostMe
  1391.    call PostCmdToEditWindow(arg(1),getpminfo(EPMINFO_EDITCLIENT))
  1392.  
  1393. /*
  1394. ┌────────────────────────────────────────────────────────────────────────────┐
  1395. │ what's it called: buffer_command    syntax:   buffer_command buff_address  │
  1396. │                                                                            │
  1397. │ what does it do : Executes the command that's stored in the buffer, then   │
  1398. │                   frees the buffer.  Useful if you want to send a command  │
  1399. │                   to another window but don't want to worry about length   │
  1400. │                   or invalid characters.                                   │
  1401. │                                                                            │
  1402. │                   Example of usage:                                        │
  1403. │                      "open 'buffer_command" put_in_buffer(cmd_string)      │
  1404. │                                                                            │
  1405. │ who and when    : Larry M.   91/09/03                                      │
  1406. └────────────────────────────────────────────────────────────────────────────┘
  1407. */
  1408. defc buffer_command
  1409.    parse arg buff .
  1410.    if not buff then return; endif  -- Null pointer = no command
  1411.    buffer_long = atol(buff)
  1412.    peekz(buffer_long)              -- Get the command from the buffer, & execute it
  1413. compile if EPM32
  1414.    call dynalink32('DOSCALLS',          -- Dynamic link library name
  1415.             '#304',                    -- Dos32FreeMem
  1416.             buffer_long)
  1417. compile else
  1418.    call dynalink('DOSCALLS',       -- dynamic link library name
  1419.             '#39',                 -- DosFreeSeg
  1420.             rightstr(buffer_long,2) )
  1421. compile endif
  1422.  
  1423. compile if EPM32
  1424. defc buff_link
  1425.    parse arg buff .
  1426.    if not buff then return; endif
  1427.    rc = dynalink32('DOSCALLS',
  1428.                    '#302',  -- Dos32GetSharedMem
  1429.                    atol(buff)      ||  -- Base address
  1430.                    atol(1))             -- PAG_READ
  1431.    if rc then
  1432.       messageNwait('DosGetSharedMem' ERROR__MSG rc)
  1433.    endif
  1434.    buff_ofs = 4
  1435.    buff_len = ltoa(peek32(buff, 0, 4), 10)
  1436.    do while buff_len > buff_ofs
  1437.       link_file = peekz32(buff, buff_ofs)
  1438.       if upcase(link_file)<>'EPM.EX' then
  1439.          if linked(link_file) < 0 then  -- Not already linked
  1440.             'linkverify' link_file
  1441.          endif
  1442.       endif
  1443.       buff_ofs = buff_ofs + length(link_file) + 1  -- +1 for ASCIIZ null
  1444.    enddo
  1445. compile endif  -- EPM32
  1446.  
  1447. /*
  1448. ┌────────────────────────────────────────────────────────────────────────────┐
  1449. │ what's it called: messagebox      syntax:   messagebox [optional string]   │
  1450. │                                                                            │
  1451. │ what does it do : ask EPM.EXE to pop up its internal message box control.  │
  1452. │                   This is done by posting a EPM_POPMSGBOX  message to the  │
  1453. │                   EPM Book window.                                         │
  1454. │                   An optional string of text can be specified.  If a string│
  1455. │                   is specified then it will be inserted into the message bx│
  1456. │                                                                            │
  1457. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1458. │                    PACKAGE available on PCTOOLS.)                          │
  1459. │                                                                            │
  1460. │ who and when    : Jerry C.   2/27/89                                       │
  1461. └────────────────────────────────────────────────────────────────────────────┘
  1462. */
  1463. defc messagebox  -- The application will free the buffer allocated by this macro !!!
  1464.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1465.                       5125,               -- EPM_POPMSGBOX
  1466.                       0,
  1467.                       put_in_buffer(arg(1)) )
  1468.  
  1469. /*
  1470. ┌────────────────────────────────────────────────────────────────────────────┐
  1471. │ what's it called: opendlg         syntax:   opendlg [EDIT  |  GET]         │
  1472. │                                                                            │
  1473. │ what does it do : ask EPM.EXE to pop up its internal message box control.  │
  1474. │                   This is done by posting a EPM_POPOPENDLG message to the  │
  1475. │                   EPM Book window.                                         │
  1476. │                   If a file    is selected, by default, it will be present-│
  1477. │                   ed in a new window.  If the 'EDIT' option is specified   │
  1478. │                   the file specified will be opened in the active edit     │
  1479. │                   window.                                                  │
  1480. │                                                                            │
  1481. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1482. │                    PACKAGE available on PCTOOLS.)                          │
  1483. │                                                                            │
  1484. │ who and when    : Jerry C.   2/27/89                                       │
  1485. └────────────────────────────────────────────────────────────────────────────┘
  1486. */
  1487. defc opendlg
  1488. compile if RING_OPTIONAL
  1489.    universal ring_enabled
  1490. compile endif
  1491. compile if WPS_SUPPORT
  1492.    universal wpshell_handle
  1493.    if wpshell_handle & not arg(1) then
  1494.       call windowmessage(0,  getpminfo(APP_HANDLE),
  1495.                          5160,                   -- EPM_WPS_OPENFILEDLG
  1496.                          getpminfo(EPMINFO_EDITCLIENT),
  1497.                          0)
  1498.  
  1499.    else
  1500. compile endif
  1501.  
  1502.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1503.                       5126,               -- EPM_POPOPENDLG
  1504. compile if RING_OPTIONAL
  1505.                       ring_enabled,
  1506. compile else
  1507.                       1,
  1508. compile endif
  1509.                       pos(upcase(strip(arg(1))),'   EDITGET')%4 * 65536)  -- OPEN=0; EDIT=1; GET=2
  1510. compile if WPS_SUPPORT
  1511.    endif
  1512. compile endif
  1513.  
  1514. /*
  1515. ┌────────────────────────────────────────────────────────────────────────────┐
  1516. │ what's it called: searchdlg       syntax:   searchdlg [next]               │
  1517. │                                                                            │
  1518. │ what does it do : ask EPM.EXE to pop up its internal search & replace dlg. │
  1519. │                   This is done by posting a EPM_POPCHANGEDLG message to the│
  1520. │                   EPM Book window.                                         │
  1521. │                   if the [next] param = 'F'  a find next will take place   │
  1522. │                   if the [next] param = 'C'  a change next will take place │
  1523. │                                                                            │
  1524. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1525. │                    PACKAGE available on PCTOOLS.)                          │
  1526. │                                                                            │
  1527. │ who and when    : Jerry C.   2/27/89                                       │
  1528. └────────────────────────────────────────────────────────────────────────────┘
  1529. */
  1530. defc searchdlg
  1531.    universal default_search_options, search_len
  1532.  
  1533.    parse value upcase(arg(1)) with uparg .
  1534.  
  1535.    if uparg='C' then
  1536.       'c'                             /* repeat last change */
  1537.    elseif uparg='F' then
  1538.       repeat_find
  1539. compile if defined(HIGHLIGHT_COLOR)
  1540.       call highlight_match(search_len)
  1541. compile endif
  1542.    else  -- The application will free the buffer allocated by this macro !!!
  1543.       call windowmessage(0,  getpminfo(APP_HANDLE),
  1544.                          5128,               -- EPM_POPCHANGEDLG
  1545.                          0,
  1546.                          put_in_buffer(default_search_options))
  1547.    endif
  1548.  
  1549. /*
  1550. ┌────────────────────────────────────────────────────────────────────────────┐
  1551. │ what's it called: configdlg       syntax:   configdlg                      │
  1552. │                                                                            │
  1553. │ what does it do : ask EPM.EXE to pop up its internal configuration dialog. │
  1554. │                   This is done by posting a EPM_POPCONFIGDLG message to the│
  1555. │                   EPM Book window.                                         │
  1556. │                                                                            │
  1557. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  1558. │                    PACKAGE available on PCTOOLS.)                          │
  1559. │                                                                            │
  1560. │ who and when    : Jerry C.   7/20/89                                       │
  1561. └────────────────────────────────────────────────────────────────────────────┘
  1562. */
  1563. compile if WANT_APPLICATION_INI_FILE
  1564. defc configdlg
  1565.  compile if CHECK_FOR_LEXAM
  1566.    universal LEXAM_is_available
  1567.  compile endif
  1568.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1569.  compile if EVERSION < 5.60
  1570.                       5129,               -- EPM_POPCONFIGDLG
  1571.  compile else
  1572.                       5129+(18*(arg(1)='SYS')),  -- EPM_POPCONFIGDLG / EPM_POPSYSCONFIGDLG
  1573.  compile endif
  1574.  compile if ENHANCED_ENTER_KEYS
  1575.                       0,           -- Omit no pages
  1576.  compile elseif EPM32
  1577.                     32,           -- Bit 6 on means omit page 6
  1578.  compile else
  1579.                     64,           -- Bit 7 on means omit page 7
  1580.  compile endif
  1581.  compile if SPELL_SUPPORT
  1582.   compile if CHECK_FOR_LEXAM
  1583.                       not LEXAM_is_available)
  1584.   compile else
  1585.                       0)
  1586.   compile endif
  1587.  compile else
  1588.                       1)           -- Bit 0 on means omit spell stuff from page 4
  1589.  compile endif  -- SPELL_SUPPORT
  1590.  
  1591.  
  1592. /*
  1593. ┌────────────────────────────────────────────────────────────────────────────┐
  1594. │ what's it called:  renderconfig                                            │
  1595. │           syntax:  renderconfig reply_window_hwnd page SEND_DEFAULT        │
  1596. │                                                                            │
  1597. │ what does it do : Upon the request of a external window, sent configuration│
  1598. │                   information in the form of special WM_COMMAND messages   │
  1599. │                   to the window handle specified in parameter one.         │
  1600. │                                                                            │
  1601. │                   The second parameter is the page number of the config    │
  1602. │                   dialog which is requesting the information; this tells   │
  1603. │                   us the range of information desired.  (Each page only    │
  1604. │                   gets sent the information for that page, when the page   │
  1605. │                   is activated.  Better performance than sending every-    │
  1606. │                   thing when the dialog is initialized.)                   │
  1607. │                                                                            │
  1608. │                   The third parameter is a flag, as follows:               │
  1609. │                      0 -> send value from .ini file                        │
  1610. │                      1 -> send default value (ignoring .ini)               │
  1611. │                      2 -> send current value (5.60 & above, only)          │
  1612. │                                                                            │
  1613. │                   The fuction is used by EPM to fill in the EPM CONFIG     │
  1614. │                   dialog box.                                              │
  1615. │                                                                            │
  1616. │ who and when    : Jerry C. & LAM  7/20/89                                  │
  1617. └────────────────────────────────────────────────────────────────────────────┘
  1618. */
  1619. defc renderconfig
  1620.    universal  ADDENDA_FILENAME
  1621.    universal  DICTIONARY_FILENAME
  1622.    universal  vAUTOSAVE_PATH, vTEMP_PATH
  1623.    universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE
  1624.    universal appname, app_hini
  1625. compile if ENHANCED_ENTER_KEYS
  1626.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  1627.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  1628. compile endif
  1629. compile if CHECK_FOR_LEXAM
  1630.    universal LEXAM_is_available
  1631. compile endif
  1632. compile if EVERSION >= 5.50
  1633.    universal default_font
  1634. compile endif
  1635. compile if EVERSION >= 5.60
  1636.    universal vMESSAGECOLOR, vSTATUSCOLOR
  1637. compile endif
  1638. compile if EVERSION >= '6.00c'
  1639.    universal statfont, msgfont
  1640.    universal bm_filename
  1641.    universal bitmap_present
  1642.    universal toolbar_loaded
  1643.  compile if WANT_STREAM_MODE = 'SWITCH'
  1644.    universal stream_mode
  1645.  compile endif
  1646.  compile if WANT_LONGNAMES='SWITCH'
  1647.    universal SHOW_LONGNAMES
  1648.  compile endif
  1649.  compile if WANT_PROFILE='SWITCH'
  1650.    universal REXX_PROFILE
  1651.  compile endif
  1652.  compile if WANT_CUA_MARKING = 'SWITCH'
  1653.    universal CUA_marking_switch
  1654.  compile endif
  1655.  compile if TOGGLE_TAB
  1656.    universal TAB_KEY
  1657.  compile endif
  1658.  compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  1659.    universal CUA_MENU_ACCEL
  1660.  compile endif
  1661. compile endif  -- EVERSION >= '6.00c'
  1662. compile if WPS_SUPPORT
  1663.    universal wpshell_handle
  1664. compile endif
  1665. universal vEPM_POINTER, cursordimensions
  1666.  
  1667.    parse arg hndle page send_default .
  1668. compile if EVERSION <= 5.20  -- Pre notebook configuration dialog -------------
  1669.    tempstr= queryprofile( app_hini, appname, INI_STUFF)
  1670.    if tempstr='' | tempstr=1 then
  1671.       tempstr=TEXTCOLOR MARKCOLOR STATUSCOLOR MESSAGECOLOR
  1672.    endif
  1673.    parse value tempstr with ttextcolor tmarkcolor tstatuscolor tmessagecolor .
  1674.    call send_config_data(hndle, checkini(send_default, INI_MARGINS, DEFAULT_MARGINS), 1, 0)
  1675.    call send_config_data(hndle, checkini(send_default, INI_AUTOSAVE, DEFAULT_AUTOSAVE), 2, 0)
  1676.    call send_config_data(hndle, checkini(send_default, INI_TABS, DEFAULT_TABS), 3, 0)
  1677.    call send_config_data(hndle, ttextcolor, 4, 0)
  1678.    call send_config_data(hndle, tmarkcolor, 5, 0)
  1679.    call send_config_data(hndle, tstatuscolor, 6, 0)
  1680.    call send_config_data(hndle, tmessagecolor, 7, 0)
  1681.  compile if SPELL_SUPPORT  -- Display spell-checking fields (dictionary & addenda paths)
  1682.   compile if CHECK_FOR_LEXAM
  1683.    if LEXAM_is_available then
  1684.   compile endif
  1685.       call send_config_data(hndle, '', 8, 0)
  1686.   compile if CHECK_FOR_LEXAM
  1687.    endif
  1688.   compile endif
  1689.  compile endif
  1690.    call send_config_data(hndle, checkini(send_default, INI_AUTOSPATH, vAUTOSAVE_PATH, AUTOSAVE_PATH), 9, 0)
  1691.    call send_config_data(hndle, checkini(send_default, INI_TEMPPATH, vTEMP_PATH, TEMP_PATH), 10, 0)
  1692.  compile if SPELL_SUPPORT  -- Display spell-checking fields (dictionary & addenda paths)
  1693.   compile if CHECK_FOR_LEXAM
  1694.    if LEXAM_is_available then
  1695.   compile endif
  1696.       call send_config_data(hndle, checkini(send_default, INI_DICTIONARY, DICTIONARY_FILENAME), 11, 0)
  1697.       call send_config_data(hndle, checkini(send_default, INI_ADDENDA, ADDENDA_FILENAME), 12, 0)
  1698.   compile if CHECK_FOR_LEXAM
  1699.    endif
  1700.   compile endif
  1701.  compile endif  -- SPELL_SUPPORT
  1702. compile else  -- Notebook control ---------------------------------------------
  1703.  compile if WPS_SUPPORT
  1704.    if wpshell_handle then
  1705.       help_panel = 5350 + page
  1706.    else
  1707.  compile endif
  1708.       help_panel = 5300 + page
  1709.  compile if WPS_SUPPORT
  1710.     endif
  1711.  compile endif
  1712.    if page=1 then                    -- Page 1 is tabs
  1713.  compile if EVERSION >= 5.60
  1714.       if send_default=2 then tempstr=.tabs
  1715.       else tempstr = checkini(send_default, INI_TABS, DEFAULT_TABS)
  1716.       endif
  1717.       call send_config_data(hndle, tempstr, 3, help_panel)
  1718.   compile if TOGGLE_TAB & EVERSION >= 6.02
  1719.       tempstr = 0
  1720.       if not send_default then  -- Send .INI file values
  1721.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  1722.          if words(newcmd) >= 14 then
  1723.             tempstr = word(newcmd, 14)
  1724.          endif
  1725.       elseif send_default=2 then  -- Send current values
  1726.          tempstr = TAB_KEY
  1727.       endif
  1728.       call send_config_data(hndle, tempstr, 19, help_panel)
  1729.   compile endif
  1730.  compile else
  1731.       call send_config_data(hndle, checkini(send_default, INI_TABS, DEFAULT_TABS), 3, help_panel)
  1732.  compile endif
  1733.    elseif page=2 then                -- Page 2 is margins
  1734.  compile if EVERSION >= 5.60
  1735.       if send_default=2 then tempstr=.margins
  1736.       else tempstr = checkini(send_default, INI_MARGINS, DEFAULT_MARGINS)
  1737.       endif
  1738.       call send_config_data(hndle, tempstr, 1, 5301)
  1739.  compile else
  1740.       call send_config_data(hndle, checkini(send_default, INI_MARGINS, DEFAULT_MARGINS), 1, help_panel)
  1741.  compile endif
  1742.    elseif page=3 then                -- Page 3 is colors
  1743.  compile if EVERSION >= 5.60
  1744.       if send_default = 2 then
  1745.          tempstr = .textcolor .markcolor vSTATUSCOLOR vMESSAGECOLOR
  1746.       else
  1747.  compile endif
  1748.          if send_default then
  1749.             tempstr = ''
  1750.          else
  1751.             tempstr= queryprofile( app_hini, appname, INI_STUFF)
  1752.          endif
  1753.          if tempstr='' | tempstr=1 then
  1754.             tempstr=TEXTCOLOR MARKCOLOR STATUSCOLOR MESSAGECOLOR
  1755.          endif
  1756.  compile if EVERSION >= 5.60
  1757.       endif
  1758.  compile endif
  1759.       parse value tempstr with ttextcolor tmarkcolor tstatuscolor tmessagecolor .
  1760.       call send_config_data(hndle, ttextcolor, 4, help_panel)
  1761.       call send_config_data(hndle, tmarkcolor, 5, help_panel)
  1762.       call send_config_data(hndle, tstatuscolor, 6, help_panel)
  1763.       call send_config_data(hndle, tmessagecolor, 7, help_panel)
  1764.    elseif page=4 then                -- Page 4 is paths
  1765.  compile if SPELL_SUPPORT   -- If dictionary & addenda present, ...
  1766.   compile if WPS_SUPPORT
  1767.       if not wpshell_handle then
  1768.   compile endif
  1769.   compile if CHECK_FOR_LEXAM
  1770.       if LEXAM_is_available then
  1771.   compile endif
  1772.          help_panel = 5390          -- Different help panel
  1773.   compile if CHECK_FOR_LEXAM
  1774.       endif
  1775.   compile endif
  1776.   compile if WPS_SUPPORT
  1777.       endif
  1778.   compile endif
  1779.  compile endif
  1780.  compile if EVERSION < '6.00c'  -- Moved to Autosave page in latest 6.00
  1781.       call send_config_data(hndle, checkini(send_default, INI_AUTOSPATH, vAUTOSAVE_PATH, AUTOSAVE_PATH), 9, help_panel)
  1782.  compile endif
  1783.       call send_config_data(hndle, checkini(send_default, INI_TEMPPATH, vTEMP_PATH, TEMP_PATH), 10, help_panel)
  1784.  compile if SPELL_SUPPORT  -- Display spell-checking fields (dictionary & addenda paths)
  1785.   compile if CHECK_FOR_LEXAM
  1786.       if LEXAM_is_available then
  1787.   compile endif
  1788.          call send_config_data(hndle, checkini(send_default, INI_DICTIONARY, DICTIONARY_FILENAME), 11, help_panel)
  1789.          call send_config_data(hndle, checkini(send_default, INI_ADDENDA, ADDENDA_FILENAME), 12, help_panel)
  1790.   compile if CHECK_FOR_LEXAM
  1791.       endif
  1792.   compile endif
  1793.  compile endif  -- SPELL_SUPPORT
  1794.    elseif page=5 then                -- Page 5 is autosave
  1795.  compile if EVERSION >= 5.60
  1796.       if send_default=2 then tempstr=.autosave
  1797.       else tempstr = checkini(send_default, INI_AUTOSAVE, DEFAULT_AUTOSAVE)
  1798.       endif
  1799.       call send_config_data(hndle, tempstr, 2, help_panel)
  1800.  compile else
  1801.       call send_config_data(hndle, checkini(send_default, INI_AUTOSAVE, DEFAULT_AUTOSAVE), 2, help_panel)
  1802.  compile endif
  1803.  compile if EVERSION >= '6.00c'
  1804.       call send_config_data(hndle, checkini(send_default, INI_AUTOSPATH, vAUTOSAVE_PATH, AUTOSAVE_PATH), 9, help_panel)
  1805.  compile endif
  1806.    elseif page=6 then                -- Page 6 is fonts
  1807.  compile if EVERSION >= 5.50 /* GPI */ and EVERSION < '6.00c'  -- Now have 3 fonts in dialog, so need a range
  1808.       call send_config_data(hndle, queryfont(word(default_font 0 .font, send_default+1))'.'trunc(.textcolor//16)'.'.textcolor%16, 13, help_panel)
  1809.  compile elseif EVERSION >= '6.00c'
  1810.       call send_config_data(hndle, queryfont(word(default_font 0 .font, send_default+1))'.'trunc(.textcolor//16)'.'.textcolor%16, 24, help_panel)
  1811.       if not send_default then  -- Use value from .ini file
  1812.          tempstr= checkini(send_default, INI_STATUSFONT, '')
  1813.          if tempstr then
  1814.             parse value tempstr with ptsize'.'facename'.'attr
  1815.             tempstr = facename'.'ptsize'.'attr
  1816.          else
  1817.             tempstr = queryfont(0)
  1818.          endif
  1819.       elseif send_default=1 then  -- Use default value
  1820.          tempstr = queryfont(0)
  1821.       else                        -- Use current value
  1822.          if statfont then
  1823.             parse value statfont with ptsize'.'facename'.'attr
  1824.             tempstr = facename'.'ptsize'.'attr
  1825.          else
  1826.             tempstr = queryfont(0)
  1827.          endif
  1828.       endif
  1829.       call send_config_data(hndle, tempstr'.'trunc(vSTATUSCOLOR//16)'.'vSTATUSCOLOR%16, 25, help_panel)
  1830.       if not send_default then  -- Use value from .ini file
  1831.          tempstr= checkini(send_default, INI_MESSAGEFONT, '')
  1832.          if tempstr then
  1833.             parse value tempstr with ptsize'.'facename'.'attr
  1834.             tempstr = facename'.'ptsize'.'attr
  1835.          else
  1836.             tempstr = queryfont(0)
  1837.          endif
  1838.       elseif send_default=1 then  -- Use default value
  1839.          tempstr = queryfont(0)
  1840.       else                        -- Use current value
  1841.          if msgfont then
  1842.             parse value msgfont with ptsize'.'facename'.'attr
  1843.             tempstr = facename'.'ptsize'.'attr
  1844.          else
  1845.             tempstr = queryfont(0)
  1846.          endif
  1847.       endif
  1848.       call send_config_data(hndle, tempstr'.'trunc(vMESSAGECOLOR//16)'.'vMESSAGECOLOR%16, 26, help_panel)
  1849.  compile endif  -- EVERSION >= '6.00c'
  1850.  compile if ENHANCED_ENTER_KEYS
  1851.    elseif page=7 then                -- Page 7 is enter keys
  1852.       if send_default=1 then
  1853.   compile if ENTER_ACTION='' | ENTER_ACTION='ADDLINE'  -- The default
  1854.          ek = \1
  1855.   compile elseif ENTER_ACTION='NEXTLINE'
  1856.          ek = \2
  1857.   compile elseif ENTER_ACTION='ADDATEND'
  1858.          ek = \3
  1859.   compile elseif ENTER_ACTION='DEPENDS'
  1860.          ek = \4
  1861.   compile elseif ENTER_ACTION='DEPENDS+'
  1862.          ek = \5
  1863.   compile elseif ENTER_ACTION='STREAM'
  1864.          ek = \6
  1865.   compile endif
  1866.   compile if C_ENTER_ACTION='ADDLINE'
  1867.          c_ek = \1
  1868.   compile elseif C_ENTER_ACTION='' | C_ENTER_ACTION='NEXTLINE'  -- The default
  1869.          c_ek = \2
  1870.   compile elseif C_ENTER_ACTION='ADDATEND'
  1871.          c_ek = \3
  1872.   compile elseif C_ENTER_ACTION='DEPENDS'
  1873.          c_ek = \4
  1874.   compile elseif C_ENTER_ACTION='DEPENDS+'
  1875.          c_ek = \5
  1876.   compile elseif C_ENTER_ACTION='STREAM'
  1877.          c_ek = \6
  1878.   compile endif
  1879.          tempstr = ek || ek || c_ek || ek || ek || ek || c_ek || ek
  1880.       else
  1881.          tempstr = chr(enterkey) || chr(a_enterkey) || chr(c_enterkey) || chr(s_enterkey) || chr(padenterkey) || chr(a_padenterkey) || chr(c_padenterkey) || chr(s_padenterkey)
  1882.       endif
  1883.       call send_config_data(hndle, tempstr, 14, help_panel)
  1884.  compile endif
  1885.  compile if EVERSION >= '6.00c'
  1886.    elseif page=8 then                -- Page 8 is Frame controls
  1887.       tempstr = '1111010'  -- StatWnd, MsgWnd, hscroll, vscroll, extrawnd, bgbitmap, drop
  1888.       if not send_default then  -- Send .INI file values
  1889.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  1890.          if newcmd <> '' then
  1891.             parse value newcmd with statflg msgflg vscrollflg hscrollflg . . extraflg . . . . . . . new_bitmap . drop_style .
  1892.             tempstr = statflg || msgflg || hscrollflg || vscrollflg || extraflg || new_bitmap || drop_style
  1893.          endif
  1894.       elseif send_default=2 then  -- Send current values
  1895.          tempstr = queryframecontrol(1) || queryframecontrol(2) || queryframecontrol(16) || queryframecontrol(8) || queryframecontrol(32) || bitmap_present || queryframecontrol(8192)
  1896.       endif
  1897.       call send_config_data(hndle, tempstr, 15, help_panel)
  1898.       call send_config_data(hndle, checkini(send_default, INI_BITMAP, bm_filename, ''), 16, help_panel)
  1899.    elseif page=9 then                -- Page 9 is Misc.
  1900.       tempstr = '0000100'  -- CUA marking, stram mode, Rexx profile, longnames, I-beam pointer, underline cursor, menu accelerators
  1901.       if not send_default then  -- Send .INI file values
  1902.          newcmd=queryprofile( app_hini, appname, INI_OPT2FLAGS)
  1903.          if newcmd <> '' then
  1904.             parse value newcmd with pointer_style cursor_shape .
  1905.          else
  1906.             pointer_style = (vEPM_POINTER=2)
  1907.             cursor_shape = (cursordimensions = '-128.3 -128.-64') -- 1 if underline; 0 if vertical
  1908.          endif
  1909.  
  1910.          newcmd=queryprofile( app_hini, appname, INI_CUAACCEL)
  1911.          if newcmd<>'' then menu_accel = newcmd
  1912.                        else menu_accel = 0
  1913.          endif
  1914.  
  1915.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  1916.          if newcmd <> '' then
  1917.             parse value newcmd with . . . . . . . markflg . streamflg longnames profile .
  1918.             tempstr = markflg || streamflg || longnames || profile || pointer_style || cursor_shape || menu_accel
  1919.          endif
  1920.       elseif send_default=2 then  -- Send current values
  1921.  compile if WANT_STREAM_MODE <> 'SWITCH'  -- Set a local variable
  1922.          stream_mode = WANT_STREAM_MODE
  1923.  compile endif
  1924.  compile if WANT_LONGNAMES<>'SWITCH'
  1925.          SHOW_LONGNAMES = WANT_LONGNAMES
  1926.  compile endif
  1927.  compile if WANT_PROFILE<>'SWITCH'
  1928.          REXX_PROFILE = WANT_PROFILE
  1929.  compile endif
  1930.  compile if WANT_CUA_MARKING <> 'SWITCH'
  1931.          CUA_marking_switch = WANT_CUA_MARKING
  1932.  compile endif
  1933.  compile if BLOCK_ACTIONBAR_ACCELERATORS <> 'SWITCH'
  1934.          CUA_MENU_ACCEL = not BLOCK_ACTIONBAR_ACCELERATORS
  1935.  compile endif                                                                                                 -- 1 if underline; 0 otherwise
  1936.          tempstr = CUA_marking_switch || stream_mode || REXX_PROFILE || SHOW_LONGNAMES || (vEPM_POINTER=2) || (cursordimensions = '-128.3 -128.-64') || CUA_MENU_ACCEL
  1937.       endif
  1938.       call send_config_data(hndle, tempstr, 18, help_panel)
  1939.    elseif page=12 then                -- Page 12 is Toolbar config
  1940.       if send_default = 1 then tempstr = ''
  1941.       else tempstr = queryprofile( app_hini, 'UCMenu', 'ConfigInfo')
  1942.       endif
  1943.       if tempstr = '' then
  1944.          tempstr = \1'8'\1'32'\1'32'\1'8.Helv'\1'16777216'\1'16777216'\1
  1945.       endif
  1946.       call send_config_data(hndle, tempstr, 22, help_panel)
  1947.    elseif page=13 then                -- Page 13 is Toolbar name & on/off
  1948.       active_toolbar = toolbar_loaded
  1949.       if active_toolbar = \1 then active_toolbar = ''; endif
  1950.       call send_config_data(hndle, checkini(send_default, INI_DEF_TOOLBAR, active_toolbar, ''), 20, help_panel)
  1951.       call send_config_data(hndle, queryframecontrol(EFRAMEF_TOOLBAR), 21, help_panel)
  1952.  compile endif  -- EVERSION >= '6.00c'
  1953.    endif
  1954. compile endif  -- EVERSION <= 5.20 --------------------------------------------
  1955.  
  1956. defproc send_config_data(hndle, strng, i, help_panel)
  1957.    strng = strng\0          -- null terminate (asciiz)
  1958.    call windowmessage(1,  hndle,
  1959.                       32,               -- WM_COMMAND - 0x0020
  1960.                       mpfrom2short(help_panel, i),
  1961.                       ltoa(offset(strng) || selector(strng), 10) )
  1962.  
  1963. compile if ENHANCED_ENTER_KEYS
  1964. defc enterkeys =
  1965.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  1966.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  1967.    universal appname, app_hini
  1968.    parse arg perm enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey
  1969.    if perm then
  1970.       call setprofile(app_hini, appname,INI_ENTERKEYS, enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey)
  1971.    endif
  1972. compile endif
  1973.  
  1974. ; send_default is a flag that says we're reverting to the default product options.
  1975. ; defaultdata is the value to be used as the window default if INIKEY isn't found
  1976. ; in the EPM.INI; it will also be used as the product default if no fourth parameter
  1977. ; is given.
  1978. defproc checkini(send_default, inikey, defaultdata )
  1979.    universal appname, app_hini
  1980.    if send_default then
  1981.       if send_default=1 & arg()>3 then
  1982.          return arg(4)
  1983.       endif
  1984.       return defaultdata
  1985.    endif
  1986.    inidata=queryprofile(app_hini, appname,inikey)
  1987.    if inidata<>'' then
  1988.       return inidata
  1989.    endif
  1990.    return defaultdata
  1991.  
  1992. ; 5.21 lets you apply without saving, so we add an optional 3rd parameter.
  1993. ; If omitted, assume the old way - save.  If present, only save if 1.
  1994. defproc setini( inikey, inidata )
  1995.    universal appname, app_hini
  1996.    if arg()>=3 then
  1997.       perm=arg(3)
  1998.    else
  1999.       perm=1
  2000.    endif
  2001.    if perm then
  2002.       call setprofile(app_hini, appname, inikey, inidata)
  2003.    endif
  2004.    return inidata
  2005.  
  2006. /*
  2007. ┌────────────────────────────────────────────────────────────────────────────┐
  2008. │ what's it called: setconfig       syntax:   setconfig configid  newvalue   │
  2009. │                                                                            │
  2010. │ what does it do : The function is called by the EPM CONFIG dialog box to   │
  2011. │                   return values set by the user.                           │
  2012. │                                                                            │
  2013. │                                                                            │
  2014. │ who and when    : Jerry C. & LAM  7/20/89                                  │
  2015. └────────────────────────────────────────────────────────────────────────────┘
  2016. */
  2017. defc setconfig
  2018.    universal  ADDENDA_FILENAME
  2019.    universal  DICTIONARY_FILENAME
  2020.    universal  vTEMP_FILENAME, vTEMP_PATH
  2021.    universal  vAUTOSAVE_PATH
  2022.    universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE
  2023.    universal  appname, app_hini
  2024. compile if EPATH = 'LAMPATH'
  2025.    universal mail_list_wid
  2026. compile endif
  2027. compile if EVERSION >= 5.21
  2028.    universal vMESSAGECOLOR, vSTATUSCOLOR
  2029. compile endif
  2030. compile if EVERSION >= '6.00c'
  2031.    universal statfont, msgfont
  2032.    universal bm_filename
  2033.    universal bitmap_present
  2034.    universal toolbar_loaded
  2035.  compile if WANT_STREAM_MODE = 'SWITCH'
  2036.    universal stream_mode
  2037.  compile endif
  2038.  compile if WANT_LONGNAMES='SWITCH'
  2039.    universal SHOW_LONGNAMES
  2040.  compile endif
  2041.  compile if WANT_PROFILE='SWITCH'
  2042.    universal REXX_PROFILE
  2043.  compile endif
  2044.  compile if WANT_CUA_MARKING = 'SWITCH'
  2045.    universal CUA_marking_switch
  2046.  compile endif
  2047.  compile if TOGGLE_TAB
  2048.    universal TAB_KEY
  2049.  compile endif
  2050.  compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2051.    universal CUA_MENU_ACCEL
  2052.  compile endif
  2053.    universal vEPM_POINTER, cursordimensions
  2054. compile endif
  2055.  
  2056. compile if EVERSION >= 5.21
  2057.    parse value arg(1) with configid perm newcmd
  2058. compile else
  2059.    parse value upcase(arg(1)) with configid newcmd; perm=1
  2060. compile endif
  2061.  
  2062.    if     configid= 1 then
  2063.       if .margins<>newcmd then 'postme maybe_reflow_all'; endif
  2064.       .margins=newcmd; vDEFAULT_MARGINS=setini(INI_MARGINS, .margins, perm);
  2065.    elseif configid= 2 then .autosave=setini(INI_AUTOSAVE,newcmd, perm); vDEFAULT_AUTOSAVE=newcmd
  2066.    elseif configid= 3 then rc=0; .tabs=newcmd; if not rc then vDEFAULT_TABS=setini(INI_TABS,newcmd, perm); endif
  2067.    elseif configid= 4 then .textcolor=newcmd
  2068.    elseif configid= 5 then .markcolor=newcmd
  2069. compile if EVERSION < 5.21
  2070.    elseif configid= 6 then .statuscolor=newcmd
  2071.    elseif configid= 7 then .messagecolor=newcmd
  2072.       call setprofile( app_hini, appname, INI_STUFF, .textcolor .markcolor .statuscolor .messagecolor)
  2073. compile else
  2074.    elseif configid= 6 & newcmd<>vSTATUSCOLOR then
  2075.                            vSTATUSCOLOR=newcmd
  2076.                            'setstatusline'
  2077.    elseif configid= 7 & newcmd<>vMESSAGECOLOR then
  2078.                            vMESSAGECOLOR=newcmd
  2079.                            'setmessageline'
  2080. compile endif
  2081.    elseif configid= 9 then
  2082.       if newcmd<>'' & rightstr(newcmd,1)<>'\' then
  2083.          newcmd=newcmd'\'
  2084.       endif
  2085.       if rightstr(newcmd,2)='\\' then             -- Temp fix for dialog bug
  2086.          newcmd=leftstr(newcmd,length(newcmd)-1)
  2087.       endif
  2088.       vAUTOSAVE_PATH=setini(INI_AUTOSPATH,newcmd, perm)
  2089.    elseif configid=10 then
  2090.       if newcmd<>'' & rightstr(newcmd,1)<>'\' then
  2091.          newcmd=newcmd'\'
  2092.       endif
  2093.       if rightstr(newcmd,2)='\\' then             -- Temp fix for dialog bug
  2094.          newcmd=leftstr(newcmd,length(newcmd)-1)
  2095.       endif
  2096.       if upcase(leftstr(vTEMP_FILENAME,length(vTEMP_PATH))) = upcase(vTEMP_PATH) then
  2097.          vTEMP_FILENAME=newcmd||substr(vTEMP_FILENAME,length(vTEMP_PATH)+1)
  2098.       elseif not verify(vTEMP_FILENAME,':\','M') then   -- if not fully qualified
  2099.          vTEMP_FILENAME=newcmd||vTEMP_FILENAME
  2100.       endif
  2101.       vTEMP_PATH=setini(INI_TEMPPATH,newcmd, perm)
  2102.    elseif configid=11 then DICTIONARY_FILENAME = setini(INI_DICTIONARY,newcmd, perm)
  2103.    elseif configid=12 then ADDENDA_FILENAME    = setini(INI_ADDENDA,newcmd, perm)
  2104. compile if EPM32
  2105.    elseif configid=15 then
  2106.       parse value newcmd with statflg 2 msgflg 3 hscrollflg 4 vscrollflg 5 extraflg 6 new_bitmap 7 drop_style 8
  2107.       'toggleframe 1' statflg
  2108.       'toggleframe 2' msgflg
  2109.       'toggleframe 8' vscrollflg
  2110.       'toggleframe 16' hscrollflg
  2111.       'toggleframe 32' extraflg
  2112.       'toggleframe 8192' drop_style
  2113.       if bitmap_present <> new_bitmap then
  2114.          'toggle_bitmap'
  2115.          if bitmap_present then bm_filename = ''; endif  -- Will be reset; want to ensure it's reloaded.
  2116.       endif
  2117.       if perm then
  2118.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  2119.          if newcmd <> '' then
  2120.             parse value newcmd with . . . . w1 w2 . w3 w4 w5 w6 w7 w8 w9 . w10 . rest
  2121.             call setprofile(app_hini, appname, INI_OPTFLAGS,
  2122.                queryframecontrol(1) queryframecontrol(2) queryframecontrol(8) queryframecontrol(16) w1 w2 queryframecontrol(32) w3 w4 w5 w6 w7 w8 w9 bitmap_present w10 queryframecontrol(8192) rest)
  2123.          else
  2124.             'saveoptions OptOnly'
  2125.          endif
  2126.       endif
  2127.    elseif configid=16 then
  2128.       if bm_filename <> newcmd then
  2129.          bm_filename = newcmd
  2130.          if bitmap_present then
  2131.             if bm_filename = '' then  -- Need to turn off & back on to get default bitmap
  2132.                'toggle_bitmap'
  2133.                'toggle_bitmap'
  2134.             else
  2135.                'load_dt_bitmap' bm_filename
  2136.             endif
  2137.          endif
  2138.       endif
  2139.       if perm then
  2140.          call setprofile(app_hini, appname, INI_BITMAP, bm_filename)
  2141.       endif
  2142.    elseif configid=18 then
  2143.       parse value newcmd with markflg 2 streamflg 3 profile 4 longnames 5 pointer_style 6 cursor_shape 7 menu_accel 8
  2144.       vEPM_POINTER = 1 + pointer_style
  2145.       mouse_setpointer vEPM_POINTER
  2146. compile if not defined(my_CURSORDIMENSIONS)
  2147.     compile if DYNAMIC_CURSOR_STYLE
  2148.       'cursor_style' (cursor_shape+1)
  2149.     compile else
  2150.       if cursor_shape=0 then  -- Vertical bar
  2151.          cursordimensions = '-128.-128 2.-128'
  2152.       elseif cursor_shape=1 then  -- Underline cursor
  2153.          cursordimensions = '-128.3 -128.-64'
  2154.       endif
  2155.       call fixup_cursor()
  2156.     compile endif -- DYNAMIC_CURSOR_STYLE
  2157. compile endif
  2158. compile if WANT_CUA_MARKING = 'SWITCH'
  2159.        if markflg<>CUA_marking_switch then
  2160.           'CUA_mark_toggle'
  2161.        endif
  2162. compile endif
  2163. compile if WANT_STREAM_MODE = 'SWITCH'
  2164.       if streamflg<>stream_mode then 'stream_toggle'; endif
  2165. compile endif
  2166. compile if WANT_LONGNAMES='SWITCH'
  2167.       if longnames<>'' then
  2168.          SHOW_LONGNAMES = longnames
  2169.       endif
  2170. compile endif
  2171. compile if WANT_PROFILE='SWITCH'
  2172.       if PROFILE<>'' then
  2173.          REXX_PROFILE = PROFILE
  2174.       endif
  2175. compile endif
  2176. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2177.       if CUA_MENU_ACCEL <> menu_accel then
  2178.          'accel_toggle'
  2179.       endif
  2180. compile endif
  2181.       if perm then
  2182.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  2183.          if newcmd <> '' then
  2184.             parse value newcmd with w1 w2 w3 w4 w5 w6 w7 . w8 . . . rest
  2185.             call setprofile(app_hini, appname, INI_OPTFLAGS,
  2186.                   w1 w2 w3 w4 w5 w6 w7 markflg w8 streamflg longnames profile rest)
  2187.          else
  2188.             'saveoptions OptOnly'
  2189.          endif
  2190.          call setprofile(app_hini, appname, INI_OPT2FLAGS, pointer_style cursor_shape)
  2191. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2192.          call setprofile(app_hini, appname, INI_CUAACCEL, menu_accel)
  2193. compile endif
  2194.       endif
  2195. compile if TOGGLE_TAB
  2196.    elseif configid=19 then
  2197.       TAB_KEY = newcmd
  2198.       if perm then
  2199.          newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  2200.          if newcmd <> '' then
  2201.             call setprofile(app_hini, appname, INI_OPTFLAGS,
  2202.                   subword(newcmd, 1, 13) tab_key subword(newcmd, 15))
  2203.          else
  2204.             'saveoptions OptOnly'
  2205.          endif
  2206.       endif
  2207. compile endif
  2208.    elseif configid=20 then
  2209.       if newcmd = '' then  -- Null string; use compiled-in toolbar
  2210.          if toolbar_loaded <> \1 then
  2211.             'loaddefaulttoolbar'
  2212.          endif
  2213.       elseif newcmd <> toolbar_loaded then
  2214.          call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(newcmd))
  2215.          toolbar_loaded = newcmd
  2216.       endif
  2217.       if perm then
  2218.          call setprofile(app_hini, appname, INI_DEF_TOOLBAR, newcmd)
  2219.       endif
  2220.    elseif configid=21 then
  2221.       if newcmd <> queryframecontrol(EFRAMEF_TOOLBAR) then
  2222.          'toggleframe' EFRAMEF_TOOLBAR newcmd
  2223.       endif
  2224.       if perm then
  2225.          temp=queryprofile( app_hini, appname, INI_OPTFLAGS)
  2226.          if temp <> '' then
  2227.             call setprofile(app_hini, appname, INI_OPTFLAGS,
  2228.                   subword(temp, 1, 15) newcmd subword(temp, 17))
  2229.          else
  2230.             'saveoptions OptOnly'  -- Possible synch problem?
  2231.          endif
  2232.       endif
  2233.    elseif configid=22 then
  2234.       call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5921, put_in_buffer(newcmd), 0)
  2235.  compile if 0
  2236.       parse value newcmd with \1 style \1 cx \1 cy \1 font \1 color \1 itemcolor \1
  2237.       if perm then
  2238.          call setprofile( app_hini, 'UCMenu', 'Style', style)
  2239.          call setprofile( app_hini, 'UCMenu', 'Cx', cx)
  2240.          call setprofile( app_hini, 'UCMenu', 'Cy', cy)
  2241.          call setprofile( app_hini, 'UCMenu', 'Font', font)
  2242.          call setprofile( app_hini, 'UCMenu', 'Color', color)
  2243.          call setprofile( app_hini, 'UCMenu', 'ItemColor', itemcolor)
  2244.       endif
  2245.  compile else
  2246.       if perm then
  2247.          call setprofile( app_hini, 'UCMenu', 'ConfigInfo', newcmd)
  2248.       endif
  2249.  compile endif
  2250. compile endif  -- EPM32
  2251. compile if EVERSION >= 5.21  -- Now, only do this once
  2252.    elseif configid= 0 then call setprofile( app_hini, appname, INI_STUFF, .textcolor .markcolor vstatuscolor vmessagecolor)
  2253. compile endif
  2254.    endif
  2255.  
  2256. compile if EPATH = 'LAMPATH'
  2257.  compile if 1                -- last item = 12
  2258.    if mail_list_wid<>'' & configid=12 then
  2259.  compile else                -- last item = 10; no spell checking
  2260.    if mail_list_wid<>'' & configid=10 then
  2261.  compile endif
  2262.       cmd = 'initconfig'\0
  2263.       call windowmessage(1,  mail_list_wid,
  2264.                          5515,             -- x158B; LAM BROADCAST COM
  2265.                          ltoa(offset(cmd) || selector(cmd), 10),
  2266.                          65536)
  2267.    endif
  2268. compile endif
  2269.  
  2270. /*
  2271. ┌────────────────────────────────────────────────────────────────────────────┐
  2272. │ what's it called: initconfig                                               │
  2273. │                                                                            │
  2274. │ what does it do : Set universal variables according to the  values         │
  2275. │                   previously saved in the EPM.INI file.                    │
  2276. │                                                                            │
  2277. └────────────────────────────────────────────────────────────────────────────┘
  2278. */
  2279. defc initconfig
  2280.    universal  ADDENDA_FILENAME
  2281.    universal  DICTIONARY_FILENAME
  2282.    universal  vTEMP_FILENAME, vTEMP_PATH
  2283.    universal  vAUTOSAVE_PATH
  2284.    universal  appname, app_hini, font, bitmap_present, optflag_extrastuff
  2285.    universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE
  2286. compile if EVERSION >= 5.60
  2287.    universal statfont, msgfont, bm_filename
  2288. compile endif
  2289. compile if EVERSION >= '5.50'
  2290.    universal default_font
  2291. compile endif
  2292. compile if WANT_CUA_MARKING = 'SWITCH'
  2293.    universal CUA_marking_switch
  2294. compile endif
  2295. compile if WANT_DYNAMIC_PROMPTS
  2296.    universal  menu_prompt
  2297. compile endif
  2298. compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH)
  2299.    universal savepath
  2300. compile endif
  2301. compile if EVERSION >= 5.21
  2302.    universal vMESSAGECOLOR, vSTATUSCOLOR
  2303.  compile if EVERSION >= 5.60
  2304.    universal vDESKTOPColor
  2305.  compile endif
  2306. compile endif
  2307. compile if ENHANCED_ENTER_KEYS
  2308.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  2309.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  2310. compile endif
  2311. compile if WANT_STREAM_MODE = 'SWITCH'
  2312.    universal stream_mode
  2313. compile endif
  2314. compile if RING_OPTIONAL
  2315.    universal ring_enabled
  2316. compile endif
  2317. compile if WANT_LONGNAMES='SWITCH'
  2318.    universal SHOW_LONGNAMES
  2319. compile endif
  2320. compile if WANT_PROFILE='SWITCH'
  2321.    universal REXX_PROFILE
  2322. compile endif
  2323. compile if TOGGLE_ESCAPE
  2324.    universal ESCAPE_KEY
  2325. compile endif
  2326. compile if TOGGLE_TAB
  2327.    universal TAB_KEY
  2328. compile endif
  2329.    universal vEPM_POINTER, cursordimensions
  2330.  
  2331. compile if WPS_SUPPORT
  2332.    universal wpshell_handle
  2333.    useWPS = upcase(arg(1))<>'NOWPS'
  2334.    if wpshell_handle & useWPS then
  2335.       load_wps_config(wpshell_handle)
  2336.       newcmd = 1  -- For a later IF
  2337.    else
  2338. compile endif
  2339.    newcmd= queryprofile( app_hini, appname, INI_STUFF)
  2340.    if newcmd then
  2341. compile if EVERSION < 5.21
  2342.       parse value newcmd with ttextcolor tmarkcolor tstatuscolor tmessagecolor .
  2343.       .textcolor=ttextcolor; .markcolor=tmarkcolor; .statuscolor=tstatuscolor; .messagecolor=tmessagecolor
  2344. compile else
  2345.       parse value newcmd with ttextcolor tmarkcolor tstatuscolor tmessagecolor .
  2346.       .textcolor=ttextcolor; .markcolor=tmarkcolor
  2347.       if tstatuscolor<>'' & tstatuscolor<>vSTATUSCOLOR then vSTATUSCOLOR=tstatuscolor; 'setstatusline'; endif
  2348.       if tmessagecolor<>'' & tmessagecolor<>vMESSAGECOLOR then vMESSAGECOLOR=tmessagecolor; 'setmessageline'; endif
  2349. compile endif
  2350.       newcmd=queryprofile( app_hini, appname, INI_MARGINS)
  2351.       if newcmd then
  2352. compile if EVERSION < 5.60
  2353.          if word(newcmd,2)>MAXMARGIN then  -- Avoid error messages if 5.51 sees 5.60's huge margins
  2354.             newcmd = word(newcmd,1) MAXMARGIN word(newcmd,3)
  2355.          endif
  2356. compile endif
  2357.          .margins=newcmd; vDEFAULT_MARGINS=newcmd; endif
  2358.       newcmd=queryprofile( app_hini, appname, INI_AUTOSAVE)
  2359.       if newcmd<>'' then .autosave=newcmd; vDEFAULT_AUTOSAVE=newcmd; endif
  2360.       newcmd=queryprofile( app_hini, appname, INI_TABS)
  2361.       if newcmd then .tabs=newcmd; vDEFAULT_TABS=newcmd; endif
  2362.       newcmd=queryprofile( app_hini, appname, INI_TEMPPATH)
  2363.       if newcmd then vTEMP_PATH=newcmd
  2364.                      if rightstr(vTemp_Path,1)<>'\' then
  2365.                         vTemp_Path = vTemp_Path'\'          -- Must end with a backslash.
  2366.                      endif
  2367.                      if not verify(vTEMP_FILENAME,':\','M') then   -- if not fully qualified
  2368.                         vTEMP_FILENAME=vTEMP_PATH||vTEMP_FILENAME
  2369.                      endif
  2370.       endif
  2371.       newcmd=queryprofile( app_hini, appname, INI_AUTOSPATH)
  2372.       if newcmd then vAUTOSAVE_PATH=newcmd
  2373.                      if rightstr(vAUTOSAVE_Path,1)<>'\' then
  2374.                         vAUTOSAVE_Path = vAUTOSAVE_Path'\'  -- Must end with a backslash.
  2375.                      endif
  2376. compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH)
  2377.                      savepath=vAUTOSAVE_PATH
  2378. compile endif
  2379.       endif
  2380.       newcmd=queryprofile( app_hini, appname, INI_DICTIONARY)
  2381.       if newcmd then DICTIONARY_FILENAME=newcmd endif
  2382.       newcmd=queryprofile( app_hini, appname, INI_ADDENDA)
  2383.       if newcmd then ADDENDA_FILENAME=newcmd endif
  2384.    endif
  2385.  
  2386.        -- Options from Option pulldown
  2387.    newcmd=queryprofile( app_hini, appname, INI_OPTFLAGS)
  2388. compile if WPS_SUPPORT
  2389.    endif  -- wpshell_handle
  2390. compile endif
  2391.    if newcmd='' then
  2392.       optflag_extrastuff = ''
  2393. compile if EVERSION >= '5.60'
  2394.  compile if not defined(WANT_BITMAP_BACKGROUND)
  2395.       new_bitmap = 1
  2396.  compile else
  2397.       new_bitmap = WANT_BITMAP_BACKGROUND
  2398.  compile endif -- not defined(WANT_BITMAP_BACKGROUND)
  2399.    drop_style = 0
  2400. compile endif -- 5.60
  2401. compile if WANT_TOOLBAR
  2402.  compile if defined(INITIAL_TOOLBAR)
  2403.       toolbar_present = INITIAL_TOOLBAR
  2404.  compile else
  2405.       toolbar_present = 1
  2406.  compile endif
  2407. compile endif -- WANT_TOOLBAR
  2408.    else
  2409. compile if WPS_SUPPORT
  2410.    if  wpshell_handle & useWPS then  -- Keys 15, 18 & 19
  2411.       parse value peekz(peek32(wpshell_handle, 60, 4)) with statflg 2 msgflg 3 hscrollflg 4 vscrollflg 5 extraflg 6 new_bitmap 7 drop_style 8
  2412.       parse value peekz(peek32(wpshell_handle, 72, 4)) with markflg 2 streamflg 3 profile 4 longnames 5 pointer_style 6 cursor_shape 7
  2413.       parse value peekz(peek32(wpshell_handle, 76, 4)) with tabkey 2
  2414.       parse value peekz(peek32(wpshell_handle, 84, 4)) with toolbar_present 2
  2415.       rotflg = 1
  2416.    else
  2417. compile endif
  2418.       parse value newcmd with statflg msgflg vscrollflg hscrollflg fileiconflg rotflg extraflg markflg menu_prompt streamflg longnames profile escapekey tabkey new_bitmap toolbar_present drop_style optflag_extrastuff
  2419. compile if WPS_SUPPORT
  2420.    endif  -- wpshell_handle
  2421. compile endif
  2422. compile if EVERSION >= '5.53'
  2423.       'toggleframe 1' statflg
  2424.       'toggleframe 2' msgflg
  2425.       'toggleframe 8' vscrollflg
  2426.       'toggleframe 16' hscrollflg
  2427.  compile if RING_OPTIONAL
  2428.        if ring_enabled then 'toggleframe 4' rotflg; endif
  2429.  compile else
  2430.       'toggleframe 4' rotflg
  2431.  compile endif
  2432.       'toggleframe 32' extraflg
  2433.       if drop_style <> '' then
  2434.          'toggleframe 8192' drop_style
  2435.       endif
  2436. compile else  -- if EVERSION >= '5.53'
  2437.       'togglecontrol 7' statflg
  2438.       'togglecontrol 8' msgflg
  2439.       'togglecontrol 9' vscrollflg
  2440.       'togglecontrol 10' hscrollflg
  2441.  compile if EVERSION < 5.50  -- File icon not optional in 5.50
  2442.       'togglecontrol 22' fileiconflg
  2443.  compile endif
  2444.  compile if RING_OPTIONAL
  2445.        if ring_enabled then 'togglecontrol 20' rotflg; endif
  2446.  compile else
  2447.       'togglecontrol 20' rotflg
  2448.  compile endif
  2449.       'togglecontrol 23' extraflg
  2450. compile endif
  2451. compile if EVERSION >= '5.60'
  2452.       if new_bitmap='' then
  2453.  compile if not defined(WANT_BITMAP_BACKGROUND)
  2454.          new_bitmap = 1
  2455.  compile else
  2456.          new_bitmap = WANT_BITMAP_BACKGROUND
  2457.  compile endif -- not defined(WANT_BITMAP_BACKGROUND)
  2458.       endif
  2459. compile else
  2460.       bitmap_present = new_bitmap
  2461. compile endif
  2462. compile if WANT_CUA_MARKING = 'SWITCH'
  2463.        if markflg<>CUA_marking_switch then
  2464.           'CUA_mark_toggle'
  2465.        endif
  2466. compile endif
  2467. compile if WANT_STREAM_MODE = 'SWITCH'
  2468.       if streamflg<>stream_mode then 'stream_toggle'; endif
  2469. compile endif
  2470. compile if WANT_LONGNAMES='SWITCH'
  2471.       if longnames<>'' then
  2472.          SHOW_LONGNAMES = longnames
  2473.       endif
  2474. compile endif
  2475. compile if WANT_PROFILE='SWITCH'
  2476.       if PROFILE<>'' then
  2477.          REXX_PROFILE = PROFILE
  2478.       endif
  2479. compile endif
  2480. compile if TOGGLE_ESCAPE
  2481.       if ESCAPEKEY<>'' then
  2482.          ESCAPE_KEY = ESCAPEKEY
  2483.       endif
  2484. compile endif
  2485. compile if TOGGLE_TAB
  2486.       if TABKEY<>'' then
  2487.          TAB_KEY = TABKEY
  2488.       endif
  2489. compile endif
  2490. compile if EVERSION >= 5.50      -- 5.50 configures enter keys as part of
  2491.    endif  /* INI_OPTFLAGS 1/3 */ -- Settings dlg, not as part of Save Options
  2492. compile endif
  2493. compile if WPS_SUPPORT
  2494.    if not (wpshell_handle & useWPS) then
  2495. compile endif
  2496. compile if EVERSION >= 5.60
  2497.    if bitmap_present <> new_bitmap then
  2498.       'toggle_bitmap'
  2499.    endif
  2500. compile endif
  2501. compile if WANT_STREAM_MODE <> 1 and ENHANCED_ENTER_KEYS
  2502.       newcmd=queryprofile( app_hini, appname, INI_ENTERKEYS)
  2503.       if newcmd<>'' then
  2504.          parse value newcmd with enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey .
  2505.       endif
  2506. compile endif
  2507. compile if EVERSION >= 5.60
  2508.       newcmd=queryprofile( app_hini, appname, INI_STATUSFONT)
  2509.       if newcmd<>'' then
  2510.          statfont = newcmd  -- Need to keep?
  2511.          parse value newcmd with psize"."facename"."attr
  2512.          "setstatface" getpminfo(EPMINFO_EDITSTATUSHWND) facename
  2513.          "setstatptsize" getpminfo(EPMINFO_EDITSTATUSHWND) psize
  2514.       endif
  2515.       newcmd=queryprofile( app_hini, appname, INI_MESSAGEFONT)
  2516.       if newcmd<>'' then
  2517.          msgfont = newcmd   -- Need to keep?
  2518.          parse value newcmd with psize"."facename"."attr
  2519.          "setstatface" getpminfo(EPMINFO_EDITMSGHWND) facename
  2520.          "setstatptsize" getpminfo(EPMINFO_EDITMSGHWND) psize
  2521.       endif
  2522.       newcmd=queryprofile( app_hini, appname, INI_BITMAP)
  2523.       if newcmd<>'' then
  2524.          bm_filename = newcmd  -- Need to keep?
  2525.  compile if EPM32
  2526.          if bitmap_present then
  2527.             'load_dt_bitmap' bm_filename
  2528.          endif
  2529.  compile endif
  2530.       endif
  2531. compile endif
  2532. compile if WPS_SUPPORT
  2533.    endif  -- not wpshell_handle
  2534. compile endif
  2535. compile if EVERSION >= 5.21 & EVERSION < 5.50 -- 5.21 configures font on config panel,
  2536. endif   /* INI_OPTFLAGS 2/3 */                -- not as part of Save Options
  2537. compile endif
  2538.  
  2539. compile if EPM32
  2540.  compile if WPS_SUPPORT
  2541.    if not (wpshell_handle & useWPS) then
  2542.  compile endif
  2543.       parse value queryprofile( app_hini, appname, INI_OPT2FLAGS) with pointer_style cursor_shape .
  2544.  compile if WPS_SUPPORT
  2545.    endif  -- not wpshell_handle
  2546.  compile endif
  2547.    if pointer_style <> '' then
  2548.       vEPM_POINTER = 1 + pointer_style
  2549.       mouse_setpointer vEPM_POINTER
  2550.    endif
  2551.  compile if not defined(my_CURSORDIMENSIONS)
  2552.    if cursor_shape <> '' then
  2553.   compile if DYNAMIC_CURSOR_STYLE
  2554.       'cursor_style' (cursor_shape+1)
  2555.   compile else
  2556.       if cursor_shape=0 then  -- Vertical bar
  2557.          cursordimensions = '-128.-128 2.-128'
  2558.       elseif cursor_shape=1 then  -- Underline cursor
  2559.          cursordimensions = '-128.3 -128.-64'
  2560.       endif
  2561.       call fixup_cursor()
  2562.   compile endif -- DYNAMIC_CURSOR_STYLE
  2563.    endif
  2564.  compile endif -- not defined(my_CURSORDIMENSIONS)
  2565. compile endif -- EPM32
  2566.  
  2567. compile if EVERSION < 5.50
  2568.       newcmd =queryprofile( app_hini, appname, INI_FONTCY)
  2569.       if newcmd<>'' then
  2570.  compile if EVERSION < 5.20  -- Earlier EPM versions didn't do DEVESCAPE
  2571.          if screenxysize('X')>1000 and dos_version()>=1020 then  -- BGA and 1.2 or above
  2572.  compile else                -- We can assume 1.2 or above; 1.1 no longer supported
  2573.          if screenxysize('X')>1000 or dos_version()>=1030 then  -- BGA *or* 1.3 for many fonts
  2574.  compile endif
  2575.             call setfont(queryprofile(app_hini, appname, INI_FONTCX),newcmd) -- don't care what pulldown says
  2576.          elseif font = (newcmd=8) then  -- if font true and smallfont, or font false and largefont
  2577.             'togglefont'  -- this changes the font and updates the "change to xxx font" pulldown
  2578.          endif
  2579.       endif
  2580. compile else
  2581.  compile if WPS_SUPPORT
  2582.     if not (wpshell_handle & useWPS) then
  2583.  compile endif
  2584.       newcmd =queryprofile( app_hini, appname, INI_FONT)
  2585.       parse value newcmd with fontname '.' fontsize '.' fontsel
  2586.       if newcmd<>'' then .font=registerfont(fontname, fontsize, fontsel); default_font = .font endif
  2587.  compile if WPS_SUPPORT
  2588.    endif  -- not wpshell_handle
  2589.  compile endif
  2590. compile endif
  2591.  
  2592. compile if EVERSION < 5.21     -- Before 5.21 saves font as part
  2593. endif   /* INI_OPTFLAGS 3/3 */ -- of Save Options processing.
  2594. compile endif
  2595.  
  2596. compile if WANT_TOOLBAR
  2597.    if toolbar_present then
  2598.       'default_toolbar'
  2599. ;  else
  2600. ;     'toggleframe' EFRAMEF_TOOLBAR toolbar_present
  2601.    endif
  2602. compile endif
  2603.  
  2604. compile if EVERSION >= 5.60
  2605.    newcmd = queryprofile(app_hini, appname, INI_DTCOLOR)
  2606.    if newcmd<>'' then
  2607.       vDESKTOPColor = newcmd
  2608.       call windowmessage( 0,  getpminfo(EPMINFO_EDITCLIENT),  -- post
  2609.                          5497,      -- EPM_EDIT_SETDTCOLOR
  2610.                          vDESKTOPColor,
  2611.                          0)
  2612.    endif
  2613. compile endif
  2614.  
  2615. compile if WPS_SUPPORT
  2616. defproc load_wps_config(shared_mem)
  2617.    universal vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE, vDEFAULT_TABS, vSTATUSCOLOR,  vMESSAGECOLOR,vAUTOSAVE_PATH
  2618.    universal vTEMP_PATH, vTEMP_FILENAME, DICTIONARY_FILENAME, ADDENDA_FILENAME
  2619.    universal default_font
  2620.  compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL')
  2621.    universal savepath
  2622.  compile endif
  2623.  compile if ENHANCED_ENTER_KEYS
  2624.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  2625.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  2626.  compile endif
  2627.    universal bitmap_present, bm_filename
  2628. /* shared_memx = "x'"ltoa(atol(shared_mem), 16)"'"                                                                                                                                        */
  2629. /*    thisptr = ''                                                                                                                                                                        */
  2630. /*    do i=1 to 14                                                                                                                                                                        */
  2631. /*         thisptr = thisptr i"=x'"ltoa(peek32(shared_mem, i*4, 4), 16)"'"                                                                                                                */
  2632. /*    enddo                                                                                                                                                                               */
  2633. /* call winmessagebox('load_wps_config('shared_memx') pointers', thisptr, 16432) -- MB_OK + MB_INFORMATION + MB_MOVEABLE                                                                  */
  2634. ;  if rc then
  2635. ;     messageNwait('DosGetSharedMem' ERROR__MSG rc)
  2636. ;     return
  2637. ;  endif
  2638.  
  2639. ; Key 1
  2640.    this_ptr = peek32(shared_mem, 4, 4);  -- if this_ptr = \0\0\0\0 then return; endif
  2641. /** call winmessagebox('load_wps_config('shared_memx')', "First pointer = x'"ltoa(this_ptr, 16)"'", 16432)*/
  2642. /** call winmessagebox('load_wps_config('shared_memx')', 'First pointer -> "'peekz(this_ptr)'"', 16432)*/
  2643.    .margins = peekz(this_ptr); vDEFAULT_MARGINS = .margins
  2644. /** sayerror '1:  Margins set OK:' peekz(this_ptr)  */
  2645. ; Key 2
  2646.    this_ptr = peek32(shared_mem, 8, 4);  -- if this_ptr = \0\0\0\0 then return; endif
  2647. /** call winmessagebox('load_wps_config('shared_memx')', "Second pointer = x'"ltoa(this_ptr, 16)"'", 16432) */
  2648. /** call winmessagebox('load_wps_config('shared_memx')', 'Second pointer -> "'peekz(this_ptr)'"', 16432) */
  2649.    .autosave = peekz(this_ptr); vDEFAULT_AUTOSAVE = .autosave
  2650. /** sayerror '2:  Autosave set OK:' peekz(this_ptr) */
  2651. ; Key 3
  2652.    this_ptr = peek32(shared_mem, 12, 4);  -- if this_ptr = \0\0\0\0 then return; endif
  2653.    .tabs = peekz(this_ptr); vDEFAULT_TABS = .tabs
  2654. /** sayerror '3:  Tabs set OK:' peekz(this_ptr) */
  2655. ; Key 4
  2656.    this_ptr = peek32(shared_mem, 16, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2657.    .textcolor = peekz(this_ptr)
  2658. /** sayerror '4:  Textcolor set OK:' peekz(this_ptr) */
  2659. ; Key 5
  2660.    this_ptr = peek32(shared_mem, 20, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2661.    .markcolor = peekz(this_ptr)
  2662. /** sayerror '5:  Markcolor set OK:' peekz(this_ptr) */
  2663. ; Key 6
  2664.    this_ptr = peek32(shared_mem, 24, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2665.    vSTATUSCOLOR = peekz(this_ptr); 'setstatusline'
  2666. /** sayerror '6:  Statuscolor set OK:' peekz(this_ptr) */
  2667. ; Key 7
  2668.    this_ptr = peek32(shared_mem, 28, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2669.    vMESSAGECOLOR = peekz(this_ptr); 'setmessageline'
  2670. /** sayerror '7:  Messagecolor set OK:' peekz(this_ptr) */
  2671. ; Key 9
  2672.    this_ptr = peek32(shared_mem, 36, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2673.    vAUTOSAVE_PATH = peekz(this_ptr)
  2674.    if vAUTOSAVE_PATH & rightstr(vAUTOSAVE_Path,1)<>'\' then
  2675.       vAUTOSAVE_Path = vAUTOSAVE_Path'\'  -- Must end with a backslash.
  2676.    endif
  2677.  compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH)
  2678.    savepath=vAUTOSAVE_PATH
  2679.  compile endif
  2680. /** sayerror '9:  AutosavePath set OK:' peekz(this_ptr) */
  2681. ; Key 10
  2682.    this_ptr = peek32(shared_mem, 40, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2683.    vTEMP_PATH = peekz(this_ptr)
  2684.    if rightstr(vTemp_Path,1)<>'\' then
  2685.       vTemp_Path = vTemp_Path'\'          -- Must end with a backslash.
  2686.    endif
  2687.    if not verify(vTEMP_FILENAME,':\','M') then   -- if not fully qualified
  2688.       vTEMP_FILENAME=vTEMP_PATH||vTEMP_FILENAME
  2689.    endif
  2690. /** sayerror '10:  TempPath set OK:' peekz(this_ptr) */
  2691. ; Key 11
  2692.    this_ptr = peek32(shared_mem, 44, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2693.    DICTIONARY_FILENAME = peekz(this_ptr)
  2694. /** sayerror '11:  Dictionary set OK:' peekz(this_ptr) */
  2695. ; Key 12
  2696.    this_ptr = peek32(shared_mem, 48, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2697.    ADDENDA_FILENAME = peekz(this_ptr)
  2698. /** sayerror '12:  Addenda file set OK:' peekz(this_ptr) */
  2699. ; Key 15
  2700.       parse value peekz(peek32(shared_mem, 60, 4)) with 6 new_bitmap 7
  2701.    if bitmap_present <> new_bitmap then
  2702.       'toggle_bitmap'
  2703.    endif
  2704. ; Key 16
  2705.    if bm_filename<>peekz(peek32(shared_mem, 64, 4)) then
  2706.       bm_filename = peekz(peek32(shared_mem, 64, 4))
  2707.       if bitmap_present then
  2708.          'load_dt_bitmap' bm_filename
  2709.       endif
  2710.    endif
  2711. ; Key 24
  2712.    this_ptr = peek32(shared_mem, 96, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2713. /** call winmessagebox('load_wps_config('shared_memx')', '13th pointer -> "'peekz(this_ptr)'"', 16432) */
  2714.    parse value peekz(this_ptr) with fontname '.' fontsize '.' fontsel '.'
  2715. /*  sayerror 'data = "'peekz(this_ptr)'"; fontname = "'fontname'"; fontsize="'fontsize'"; fontsel="'fontsel'"'  */
  2716.    .font=registerfont(fontname, fontsize, fontsel); default_font = .font
  2717. /*  sayerror '24:  Font set OK:' peekz(this_ptr) '.font =' default_font  */
  2718.  compile if ENHANCED_ENTER_KEYS
  2719. ; Key 14
  2720.    this_ptr = peek32(shared_mem, 56, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2721. /** call winmessagebox('load_wps_config('shared_memx')', '14th pointer -> "'peekz(this_ptr)'"', 16432) */
  2722.    tempstr = peekz(this_ptr)
  2723.    enterkey      = asc(substr(tempstr, 1, 1))
  2724.    a_enterkey    = asc(substr(tempstr, 2, 1))
  2725.    c_enterkey    = asc(substr(tempstr, 3, 1))
  2726.    s_enterkey    = asc(substr(tempstr, 4, 1))
  2727.    padenterkey   = asc(substr(tempstr, 5, 1))
  2728.    a_padenterkey = asc(substr(tempstr, 6, 1))
  2729.    c_padenterkey = asc(substr(tempstr, 7, 1))
  2730.    s_padenterkey = asc(substr(tempstr, 8, 1))
  2731. /** sayerror '14:  Enter keys set OK:' peekz(this_ptr) */
  2732.  compile endif
  2733. /** call winmessagebox('load_wps_config('shared_memx')', 'All done!', 16432)  */
  2734. ; Key 25
  2735.    this_ptr = peek32(shared_mem, 100, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2736. /** call winmessagebox('load_wps_config('shared_memx')', '25th pointer -> "'peekz(this_ptr)'"', 16432) */
  2737.    parse value peekz(this_ptr) with fontname '.' fontsize '.' fontsel '.'
  2738. /*  sayerror 'data = "'peekz(this_ptr)'"; fontname = "'fontname'"; fontsize="'fontsize'"; fontsel="'fontsel'"'  */
  2739.    statfont = fontsize'.'fontname'.'fontsel
  2740.    "setstatface" getpminfo(EPMINFO_EDITSTATUSHWND) fontname
  2741.    "setstatptsize" getpminfo(EPMINFO_EDITSTATUSHWND) fontsize
  2742. ; Key 26
  2743.    this_ptr = peek32(shared_mem, 104, 4); -- if this_ptr = \0\0\0\0 then return; endif
  2744. /** call winmessagebox('load_wps_config('shared_memx')', '26th pointer -> "'peekz(this_ptr)'"', 16432) */
  2745.    parse value peekz(this_ptr) with fontname '.' fontsize '.' fontsel '.'
  2746. /*  sayerror 'data = "'peekz(this_ptr)'"; fontname = "'fontname'"; fontsize="'fontsize'"; fontsel="'fontsel'"'  */
  2747.    msgfont = fontsize'.'fontname'.'fontsel
  2748.    "setstatface" getpminfo(EPMINFO_EDITMSGHWND) fontname
  2749.    "setstatptsize" getpminfo(EPMINFO_EDITMSGHWND) fontsize
  2750.  
  2751. ;defproc ppeek32(longaddr, offst, len)
  2752. ;   parse value atol(longaddr+offst) with hex_ofs 3 hex_seg
  2753. ;   return peek(ltoa(hex_seg\0\0, 10), ltoa(hex_ofs\0\0, 10), len)
  2754.  
  2755. defc refresh_config
  2756.    universal app_hini
  2757.    universal wpshell_handle
  2758.    universal toolbar_loaded
  2759.  compile if WANT_CUA_MARKING = 'SWITCH'
  2760.    universal CUA_marking_switch
  2761.  compile endif
  2762.  compile if WANT_STREAM_MODE = 'SWITCH'
  2763.    universal stream_mode
  2764.  compile endif
  2765.  compile if RING_OPTIONAL
  2766.    universal ring_enabled
  2767.  compile endif
  2768.  compile if WANT_LONGNAMES='SWITCH'
  2769.    universal SHOW_LONGNAMES
  2770.  compile endif
  2771.  compile if TOGGLE_ESCAPE
  2772.    universal ESCAPE_KEY
  2773.  compile endif
  2774.  compile if TOGGLE_TAB
  2775.    universal TAB_KEY
  2776.  compile endif
  2777. compile if WANT_PROFILE='SWITCH'
  2778.    universal REXX_PROFILE
  2779. compile endif
  2780. compile if WANT_DYNAMIC_PROMPTS
  2781.    universal  menu_prompt
  2782. compile endif
  2783. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2784.    universal CUA_MENU_ACCEL
  2785. compile endif
  2786.    universal bitmap_present, bm_filename
  2787.    universal cursordimensions
  2788.    universal vEPM_POINTER
  2789.    if wpshell_handle then
  2790.       load_wps_config(wpshell_handle)
  2791. ; Key 15
  2792.       parse value peekz(peek32(wpshell_handle, 60, 4)) with statflg 2 msgflg 3 hscrollflg 4 vscrollflg 5 extraflg 6 new_bitmap 7
  2793.       'toggleframe 1' statflg
  2794.       'toggleframe 2' msgflg
  2795.       'toggleframe 8' vscrollflg
  2796.       'toggleframe 16' hscrollflg
  2797.       'toggleframe 32' extraflg
  2798. ;  if bitmap_present <> new_bitmap then
  2799. ;     'toggle_bitmap'
  2800. ;  endif
  2801. ; Key 18
  2802.       parse value peekz(peek32(wpshell_handle, 72, 4)) with markflg 2 streamflg 3 rexx_profile 4 longnames 5 pointer_style 6 cursor_shape 7 menu_accel 8
  2803.  compile if WANT_CUA_MARKING = 'SWITCH'
  2804.       if markflg<>CUA_marking_switch then
  2805.          'CUA_mark_toggle'
  2806.       endif
  2807.  compile endif
  2808.  compile if WANT_STREAM_MODE = 'SWITCH'
  2809.       if streamflg<>stream_mode then 'stream_toggle'; endif
  2810.  compile endif
  2811.  compile if WANT_LONGNAMES='SWITCH'
  2812.       SHOW_LONGNAMES = longnames
  2813.  compile endif
  2814. ;compile if TOGGLE_ESCAPE
  2815. ;     ESCAPE_KEY = ESCAPEKEY
  2816. ;compile endif
  2817.       vEPM_POINTER = 1 + pointer_style
  2818.       mouse_setpointer vEPM_POINTER
  2819.  compile if not defined(my_CURSORDIMENSIONS)
  2820.   compile if DYNAMIC_CURSOR_STYLE
  2821.       'cursor_style' (cursor_shape+1)
  2822.   compile else
  2823.       if cursor_shape=0 then  -- Vertical bar
  2824.          cursordimensions = '-128.-128 2.-128'
  2825.       elseif cursor_shape=1 then  -- Underline cursor
  2826.          cursordimensions = '-128.3 -128.-64'
  2827.       endif
  2828.       call fixup_cursor()
  2829.   compile endif -- DYNAMIC_CURSOR_STYLE
  2830.  compile endif -- not defined(my_CURSORDIMENSIONS)
  2831.  compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2832.       if CUA_MENU_ACCEL <> menu_accel then
  2833.          'accel_toggle'
  2834.       endif
  2835.  compile endif
  2836. ; Key 19
  2837.       parse value peekz(peek32(wpshell_handle, 76, 4)) with TAB_KEY 2
  2838. ;     parse value peekz(peek32(wpshell_handle, 68, 4)) with rexx_profile 2 menu_prompt 3 new_bitmap 4
  2839. ;     if new_bitmap <> bitmap_present then
  2840. ;        'toggle_bitmap'
  2841. ;     endif
  2842. ; Key 20
  2843.       newcmd = peekz(peek32(wpshell_handle, 80, 4))
  2844.       if newcmd = '' then  -- Null string; use compiled-in toolbar
  2845.          if toolbar_loaded <> \1 then
  2846.             'loaddefaulttoolbar'
  2847.          endif
  2848.       elseif newcmd <> toolbar_loaded then
  2849.          call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(newcmd))
  2850.          toolbar_loaded = newcmd
  2851.       endif
  2852. ; Key 21
  2853.       parse value peekz(peek32(wpshell_handle, 84, 4)) with toolbar_flg 2
  2854.       if toolbar_flg <> queryframecontrol(EFRAMEF_TOOLBAR) then
  2855.          'toggleframe' EFRAMEF_TOOLBAR toolbar_flg
  2856.       endif
  2857. ; Key 22
  2858.       call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5921,
  2859.                          put_in_buffer(peekz(peek32(wpshell_handle, 88, 4))), 0)
  2860.    endif -- wpshell_handle
  2861. compile endif  -- WPS_SUPPORT
  2862.  
  2863. /*
  2864. ┌────────────────────────────────────────────────────────────────────────────┐
  2865. │ what's it called: saveoptions                                              │
  2866. │                                                                            │
  2867. │ what does it do : save state of items on options pull down in os2ini       │
  2868. │                                                                            │
  2869. └────────────────────────────────────────────────────────────────────────────┘
  2870. */
  2871. defc saveoptions
  2872.    universal appname, app_hini, bitmap_present, optflag_extrastuff, toolbar_present
  2873. compile if EVERSION >= 5.60
  2874.    universal statfont, msgfont
  2875.    universal bm_filename
  2876. compile endif
  2877. compile if WANT_DYNAMIC_PROMPTS
  2878.    universal menu_prompt
  2879. compile endif
  2880. compile if EPATH = 'LAMPATH'
  2881.    universal mail_list_wid
  2882. compile endif
  2883. compile if ENHANCED_ENTER_KEYS & EVERSION < 5.21
  2884.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  2885.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  2886. compile endif
  2887. compile if RING_OPTIONAL
  2888.    universal ring_enabled
  2889. compile endif
  2890. compile if WANT_STACK_CMDS = 'SWITCH'
  2891.    universal stack_cmds
  2892. compile endif
  2893. compile if WANT_STREAM_MODE = 'SWITCH'
  2894.    universal stream_mode
  2895. compile endif
  2896. compile if WANT_LONGNAMES='SWITCH'
  2897.    universal SHOW_LONGNAMES
  2898. compile endif
  2899. compile if WANT_PROFILE='SWITCH'
  2900.    universal REXX_PROFILE
  2901. compile endif
  2902. compile if TOGGLE_ESCAPE
  2903.    universal ESCAPE_KEY
  2904. compile endif
  2905. compile if TOGGLE_TAB
  2906.    universal TAB_KEY
  2907. compile endif
  2908. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2909.    universal CUA_MENU_ACCEL
  2910. compile endif
  2911. compile if WANT_CUA_MARKING = 'SWITCH'
  2912.    universal CUA_marking_switch
  2913. compile else
  2914.    CUA_marking_switch = 0
  2915. compile endif
  2916.  
  2917. compile if not WANT_DYNAMIC_PROMPTS
  2918.    menu_prompt = 1
  2919. compile endif
  2920. compile if WANT_STREAM_MODE <> 'SWITCH'
  2921.    stream_mode = 0
  2922. compile endif
  2923. compile if WANT_LONGNAMES<>'SWITCH'
  2924.    show_longnames = 0
  2925. compile endif
  2926. compile if WANT_PROFILE<>'SWITCH'
  2927.    REXX_PROFILE = 0
  2928. compile endif
  2929. compile if not TOGGLE_ESCAPE
  2930.    ESCAPE_KEY = 1
  2931. compile endif
  2932. compile if not TOGGLE_TAB
  2933.    TAB_KEY = 0
  2934. compile endif
  2935.  
  2936.    call setprofile(app_hini, appname, INI_OPTFLAGS,
  2937. compile if EVERSION >= 6  -- Only 32-bit versions have toolbar
  2938.       queryframecontrol(1) queryframecontrol(2) queryframecontrol(8) queryframecontrol(16) queryframecontrol(64) queryframecontrol(4) queryframecontrol(32) CUA_marking_switch menu_prompt stream_mode show_longnames rexx_profile escape_key tab_key ||
  2939.       ' 'bitmap_present queryframecontrol(EFRAMEF_TOOLBAR) queryframecontrol(8192) optflag_extrastuff)
  2940. compile elseif EVERSION >= 5.53
  2941.       queryframecontrol(1) queryframecontrol(2) queryframecontrol(8) queryframecontrol(16) queryframecontrol(64) queryframecontrol(4) queryframecontrol(32) CUA_marking_switch menu_prompt stream_mode show_longnames rexx_profile escape_key tab_key ||
  2942.       ' 'bitmap_present toolbar_present optflag_extrastuff)
  2943. compile else
  2944.       querycontrol(7) querycontrol(8) querycontrol(9) querycontrol(10) querycontrol(22) querycontrol(20) querycontrol(23) CUA_marking_switch menu_prompt stream_mode show_longnames rexx_profile escape_key tab_key bitmap_present optflag_extrastuff)
  2945. compile endif
  2946. ;     messageline     statusline      vert. scroll    horiz. scroll    file icon        rotate buttons   info window pos.
  2947.    if arg(1)='OptOnly' then
  2948.       return
  2949.    endif
  2950. compile if EVERSION < 5.50
  2951.    call setprofile(app_hini, appname, INI_FONTCX,  .fontwidth      ) -- font width
  2952.    call setprofile(app_hini, appname, INI_FONTCY,  .fontheight     ) -- font height
  2953. compile endif
  2954. compile if WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21
  2955.    call setprofile(app_hini, appname, INI_ENTERKEYS, enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey)
  2956. compile endif
  2957. compile if RING_OPTIONAL
  2958.    call setprofile(app_hini, appname, INI_RINGENABLED,   ring_enabled)
  2959. compile endif
  2960. compile if WANT_STACK_CMDS = 'SWITCH'
  2961.    call setprofile(app_hini, appname, INI_STACKCMDS,     stack_cmds)
  2962. compile endif
  2963. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  2964.    call setprofile(app_hini, appname, INI_CUAACCEL,      CUA_MENU_ACCEL)
  2965. compile endif
  2966. compile if EVERSION >= 5.60
  2967.    if statfont <> '' then
  2968.       call setprofile(app_hini, appname, INI_STATUSFONT, statfont)
  2969.    endif
  2970.    if msgfont <> '' then
  2971.       call setprofile(app_hini, appname, INI_MESSAGEFONT, msgfont)
  2972.    endif
  2973. ;  if bm_filename <> '' then  -- Set even if null, so Toggle_Bitmap can remove dropped background.
  2974.       call setprofile(app_hini, appname, INI_BITMAP, bm_filename)
  2975. ;  endif
  2976. compile endif
  2977.    call windowmessage(0,  getpminfo(APP_HANDLE),
  2978.                       62, 0, 0)               -- x'003E' = WM_SAVEAPPLICATION
  2979. compile if EPATH = 'LAMPATH'
  2980.    cmd = 'initconfig'\0
  2981.    if mail_list_wid<>'' then
  2982.       call windowmessage(1,  mail_list_wid,   -- This updates LaMail's hidden window
  2983.                          5515,                -- x158B; LAM BROADCAST COM
  2984.                          ltoa(offset(cmd) || selector(cmd), 10),
  2985.                          65536)
  2986.    endif
  2987. compile endif
  2988. compile if SUPPORT_USER_EXITS
  2989.    if isadefproc('saveoptions_exit') then
  2990.       call saveoptions_exit()
  2991.    endif
  2992. compile endif
  2993.  
  2994. compile if EVERSION >= 5.60
  2995. /*
  2996. ┌────────────────────────────────────────────────────────────────────────────┐
  2997. │ what's it called: savefont                                                 │
  2998. │                                                                            │
  2999. │ what does it do : save fonts in the ini file                               │
  3000. │ who&when : GLS  09/16/93                                                   │
  3001. └────────────────────────────────────────────────────────────────────────────┘
  3002. */
  3003. defc savefont
  3004.    universal appname, app_hini, bitmap_present, optflag_extrastuff
  3005.    universal statfont, msgfont
  3006.  compile if EPATH = 'LAMPATH'
  3007.    universal mail_list_wid
  3008.  compile endif
  3009.  
  3010.    parse value upcase(arg(1)) with prefix
  3011.    if prefix == 'EDIT' then
  3012.       call setini( INI_FONT, queryfont(.font), 1)
  3013.    elseif prefix == 'STAT' & statfont <> '' then
  3014.       call setprofile(app_hini, appname, INI_STATUSFONT, statfont)
  3015.    elseif prefix == 'MSG' & msgfont <> '' then
  3016.       call setprofile(app_hini, appname, INI_MESSAGEFONT, msgfont)
  3017.  compile if EPATH = 'LAMPATH'
  3018.    else
  3019.       return
  3020.  compile endif
  3021.    endif
  3022.  compile if EPATH = 'LAMPATH'
  3023.    cmd = 'initconfig'\0
  3024.    if mail_list_wid<>'' then
  3025.       call windowmessage(1,  mail_list_wid,   -- This updates LaMail's hidden window
  3026.                          5515,                -- x158B; LAM BROADCAST COM
  3027.                          ltoa(offset(cmd) || selector(cmd), 10),
  3028.                          65536)
  3029.    endif
  3030.  compile endif
  3031.  
  3032. /*
  3033. ┌────────────────────────────────────────────────────────────────────────────┐
  3034. │ what's it called: savecolor                                                │
  3035. │                                                                            │
  3036. │ what does it do : save color in the ini file                               │
  3037. │ who&when : GLS  09/16/93                                                   │
  3038. └────────────────────────────────────────────────────────────────────────────┘
  3039. */
  3040. defc savecolor
  3041.    universal appname, app_hini
  3042.    universal vstatuscolor, vmessagecolor, vDESKTOPCOLOR
  3043.  
  3044.  compile if EPATH = 'LAMPATH'
  3045.    universal mail_list_wid
  3046.  compile endif
  3047.  
  3048. -- for now we save the mark edit status and message color in one block
  3049. -- (INI_STUFF topic in the ini file)
  3050.  
  3051.    call setprofile( app_hini, appname, INI_DTCOLOR, vDESKTOPColor)
  3052.    call setprofile( app_hini, appname, INI_STUFF, .textcolor .markcolor vstatuscolor vmessagecolor)
  3053.  
  3054.  compile if EPATH = 'LAMPATH'
  3055.    cmd = 'initconfig'\0
  3056.    if mail_list_wid<>'' then
  3057.       call windowmessage(1,  mail_list_wid,   -- This updates LaMail's hidden window
  3058.                          5515,                -- x158B; LAM BROADCAST COM
  3059.                          ltoa(offset(cmd) || selector(cmd), 10),
  3060.                          65536)
  3061.    endif
  3062.  compile endif
  3063.  
  3064.  
  3065. /*
  3066. ┌────────────────────────────────────────────────────────────────────────────┐
  3067. │ what's it called: savewindowsize                                           │
  3068. │                                                                            │
  3069. │ what does it do : save size of the edit window in the ini file             │
  3070. │ who did it&when : GLS 09/15/93                                             │
  3071. └────────────────────────────────────────────────────────────────────────────┘
  3072. */
  3073. defc savewindowsize
  3074.    call windowmessage(0,  getpminfo(APP_HANDLE),
  3075.                       62, 0, 0)               -- x'003E' = WM_SAVEAPPLICATION
  3076.  
  3077. compile endif -- EVERSION >= 5.60
  3078.  
  3079. compile endif  -- WANT_APPLICATION_INI_FILE
  3080.  
  3081.  
  3082. /*
  3083. ┌────────────────────────────────────────────────────────────────────────────┐
  3084. │ what's it called: processdragdrop                                          │
  3085. │                                                                            │
  3086. │ what does it do : this defc is automatically called by the                 │
  3087. │                   toolkit when a drag drop event is successfully made      │
  3088. │                                                                            │
  3089. │ what are the args:    cmdid =  1   - epm edit window                       │
  3090. │                                2   - File icon window (self)               │
  3091. │                                3   - epm book icon                         │
  3092. │                                4   - system editor                         │
  3093. │                                5   - File Manager folder                   │
  3094. │                                10  - Print manager                         │
  3095. │                                                                            │
  3096. │                       hwnd  =  handle of target window's frame             │
  3097. └────────────────────────────────────────────────────────────────────────────┘
  3098. */
  3099. defc PROCESSDRAGDROP
  3100.    parse arg cmdid hwnd
  3101. ;  hwnd=atol_swap(hwnd)
  3102.  
  3103.    if cmdid=10 then
  3104. compile if EVERSION >= '5.51'
  3105.     call windowmessage(0,
  3106.                        getpminfo(APP_HANDLE),
  3107.                        5144,               -- EPM_PRINTDLG
  3108.                        hwnd='M',
  3109.                        0)
  3110. compile elseif ENHANCED_PRINT_SUPPORT
  3111.       'printdlg'
  3112. compile else
  3113.       sayerror PRINTING__MSG .filename
  3114.  compile if EVERSION < '5.50'
  3115.       'xcom save' default_printer()
  3116.  compile else
  3117.       'xcom save /ne' default_printer()
  3118.  compile endif
  3119.       sayerror 0
  3120. compile endif
  3121.    elseif cmdid=1 and hwnd<>getpminfo(EPMINFO_EDITFRAME) and leftstr(.filename,1)<>'.' then
  3122.       call PostCmdToEditWindow('e '.filename,hwnd,9,2)  -- Get-able
  3123.    elseif cmdid=3 then
  3124.       if .filename=UNNAMED_FILE_NAME then name=''; else name=.filename; endif
  3125.       call windowmessage(0,  getpminfo(APP_HANDLE),
  3126.                          5386,                   -- EPM_EDIT_NEWFILE
  3127.                          put_in_buffer(name,2),  -- share = GETable
  3128.                          9)                      -- EPM does a GET first & a FREE after.
  3129.    elseif cmdid=4 then
  3130.       call winmessagebox(SYS_ED__MSG,SYS_ED1__MSG\10'   :-)', 16406) -- CANCEL + ICONQUESTION + MB_MOVEABLE
  3131.    elseif cmdid=5 then
  3132.       str=leftstr('',MAXCOL)
  3133. compile if EPM32
  3134.       len= dynalink32( 'PMWIN',
  3135.                 '#841',             --   'WINQUERYWINDOWTEXT',
  3136.                  atol(hwnd)         ||
  3137.                  atol(MAXCOL)       ||
  3138.                  address(str), 2)
  3139. compile else
  3140.       len= dynalink( 'PMWIN',
  3141.                 'WINQUERYWINDOWTEXT',
  3142.                  atol_swap(hwnd)         ||
  3143.                  atoi(MAXCOL)            ||
  3144.                  address(str) )
  3145. compile endif  -- EPM32
  3146.       p = lastpos('\',leftstr(str,len))
  3147.       if p then
  3148.          str = leftstr(str,p)'='
  3149.          call parse_filename(str, .filename)
  3150.          if exist(str) then
  3151.             if 1<>winmessagebox(str, EXISTS_OVERLAY__MSG, 16417) then -- OKCANCEL + CUANWARNING + MOVEABLE
  3152.                return  -- 1 = MB OK
  3153.             endif
  3154.          endif
  3155.          'save' str
  3156.          if not rc then sayerror SAVED_TO__MSG str; endif
  3157.       else
  3158.          call winmessagebox('"'leftstr(str,len)'"',NO_SLASH__MSG, 16406) -- CANCEL + ICONQUESTION + MB_MOVEABLE
  3159.       endif
  3160.    endif
  3161.  
  3162.  
  3163. /*
  3164. ┌────────────────────────────────────────────────────────────────────────────┐
  3165. │ what's it called: repaint_window                                           │
  3166. │                                                                            │
  3167. │ what does it do : send a paint message to the editor.                      │
  3168. │                                                                            │
  3169. └────────────────────────────────────────────────────────────────────────────┘
  3170. */
  3171. defproc repaint_window()
  3172.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 35, 0, 0)   -- WM_PAINT
  3173.  
  3174. compile if EVERSION >= 5.21
  3175. /*
  3176. ┌────────────────────────────────────────────────────────────────────────────┐
  3177. │ what's it called: saveas_dlg      syntax:   saveas_dlg                     │
  3178. │                                                                            │
  3179. │ what does it do : ask EPM.EXE to pop up its "Save as" dialog box control.  │
  3180. │                   This is done by posting a EPM_POPOPENDLG message to the  │
  3181. │                   EPM Book window.                                         │
  3182. │                                                                            │
  3183. │                   (All EPM_EDIT_xxx messages are defined in the ETOOLKT    │
  3184. │                    PACKAGE available on PCTOOLS.)                          │
  3185. │                                                                            │
  3186. │ who and when    : Larry M.   6/12/91                                       │
  3187. └────────────────────────────────────────────────────────────────────────────┘
  3188. */
  3189. defc saveas_dlg
  3190.  compile if WANT_LONGNAMES='SWITCH'
  3191.    universal SHOW_LONGNAMES
  3192.  compile endif
  3193.  compile if WANT_LAN_SUPPORT | EVERSION >= '5.51'
  3194.    if .lockhandle then
  3195.       sayerror LOCKED__MSG
  3196.       return
  3197.    endif
  3198.  compile endif
  3199.    if not saveas_dlg(name, type) then
  3200.  compile if EVERSION >= '5.50'
  3201.       if leftstr(name,1)='"' & rightstr(name,1)='"' then
  3202.          name=substr(name,2,length(name)-2)
  3203.       endif
  3204.  compile endif
  3205.       autosave_name = MakeTempName()
  3206.       oldname = .filename
  3207.       .filename = name
  3208.       if get_EAT_ASCII_value('.LONGNAME')<>'' & upcase(oldname)<>upcase(name) then
  3209.          call delete_ea('.LONGNAME')
  3210.  compile if WANT_LONGNAMES
  3211.   compile if WANT_LONGNAMES='SWITCH'
  3212.          if SHOW_LONGNAMES then
  3213.   compile endif
  3214.             .titletext = ''
  3215.   compile if WANT_LONGNAMES='SWITCH'
  3216.          endif
  3217.   compile endif
  3218.  compile endif  -- WANT_LONGNAMES
  3219.       endif
  3220.  compile if SUPPORT_USER_EXITS
  3221.       if isadefproc('rename_exit') then
  3222.          call rename_exit(oldname, .filename, 1)
  3223.       endif
  3224.  compile endif
  3225.  compile if INCLUDE_BMS_SUPPORT
  3226.       if isadefproc('BMS_rename_exit') then
  3227.          call BMS_rename_exit(oldname, .filename, 1)
  3228.       endif
  3229.  compile endif
  3230.       'save'
  3231.       if rc then  -- Problem saving?
  3232.          call dosmove(autosave_name, MakeTempName())  -- Rename the autosave file
  3233.       else
  3234.          call erasetemp(autosave_name)
  3235.       endif
  3236.    endif
  3237.  
  3238. defproc saveas_dlg(var name, var type)
  3239.    type = copies(\0,255)
  3240.    if .filename=UNNAMED_FILE_NAME then
  3241.       name = type
  3242.    else
  3243.       name = leftstr(.filename,255,\0)
  3244.    endif
  3245.  compile if EPM32
  3246.    res= dynalink32( ERES2_DLL,                -- library name
  3247.                    'ERESSaveas',              -- function name
  3248.                    gethwndc(EPMINFO_EDITCLIENT)  ||
  3249.                    gethwndc(APP_HANDLE)          ||
  3250.                    address(name)                 ||
  3251.                    address(type) )
  3252.  compile else
  3253.    res= dynalink( ERES2_DLL,                 -- library name
  3254.                   'ERESSAVEAS',              -- function name
  3255.                   gethwnd(EPMINFO_EDITCLIENT)  ||
  3256.                   gethwnd(APP_HANDLE)          ||
  3257.                   address(name)                ||
  3258.                   address(type) )
  3259.  compile endif  -- EPM32
  3260. ; Return codes:  0=OK; 1=memory problem; 2=bad string; 3=couldn't load control from DLL
  3261.    if res=2 then      -- File dialog didn't like the .filename;
  3262.       name = copies(\0,255)  -- try again with no file name
  3263.  compile if EPM32
  3264.       call dynalink32( ERES2_DLL,                -- library name
  3265.                       'ERESSaveas',              -- function name
  3266.                       gethwndc(EPMINFO_EDITCLIENT)  ||
  3267.                       gethwndc(APP_HANDLE)          ||
  3268.                       address(name)                 ||
  3269.                       address(type) )
  3270.  compile else
  3271.       call dynalink( ERES2_DLL,                 -- library name
  3272.                      'ERESSAVEAS',              -- function name
  3273.                      gethwnd(EPMINFO_EDITCLIENT)  ||
  3274.                      gethwnd(APP_HANDLE)          ||
  3275.                      address(name)                ||
  3276.                      address(type) )
  3277.  compile endif  -- EPM32
  3278.    endif
  3279.    parse value name with name \0
  3280.    parse value type with type \0
  3281.    if name='' then return -275; endif  -- sayerror('Missing filename')
  3282.    if exist(name) then
  3283.       if 1<>winmessagebox(SAVE_AS__MSG, name\10\10||EXISTS_OVERLAY__MSG, 16417) then -- OKCANCEL + CUANWARNING + MOVEABLE
  3284.          return -5  -- sayerror('Access denied')
  3285.       endif
  3286.    endif
  3287.    if type then
  3288.       call delete_ea('.TYPE')
  3289.       'add_ea .TYPE' type
  3290.    endif
  3291. compile endif  -- EVERSION >= 5.21
  3292.  
  3293. /*
  3294. ┌────────────────────────────────────────────────────────────────────────────┐
  3295. │ what's it called: showwindow                                               │
  3296. │                                                                            │
  3297. │ what does it do : allows the edit window to become invisible or visible    │
  3298. │                                                                            │
  3299. └────────────────────────────────────────────────────────────────────────────┘
  3300. */
  3301. defproc showwindow
  3302.    -- post the EPM_EDIT_SHOW message
  3303.    call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
  3304.                       5385,
  3305.                       upcase(arg(1))<>'OFF', -- 0 if OFF, else 1
  3306.                       0)
  3307.  
  3308. /*
  3309. ┌────────────────────────────────────────────────────────────────────────────┐
  3310. │ what's it called: settitletext                                             │
  3311. │                                                                            │
  3312. │ what does it do : set the text in the editors active title bar.            │
  3313. │                                                                            │
  3314. └────────────────────────────────────────────────────────────────────────────┘
  3315. */
  3316. defproc settitletext()
  3317.    text = arg(1)
  3318.  
  3319. compile if SHOW_MODIFY_METHOD = 'TITLE'
  3320.    if .modify then
  3321.       text = text || SHOW_MODIFY_TEXT
  3322.    endif
  3323. compile endif
  3324.    .titletext = text
  3325.  
  3326. /*
  3327. ┌────────────────────────────────────────────────────────────────────────────┐
  3328. │ what's it called: updateringmenu                                           │
  3329. │                                                                            │
  3330. │ what does it do : update ring menu                                         │
  3331. │                                                                            │
  3332. └────────────────────────────────────────────────────────────────────────────┘
  3333. */
  3334. compile if MENU_LIMIT
  3335. defproc updateringmenu()
  3336.    universal activemenu,defaultmenu
  3337.    universal EPM_utility_array_ID
  3338.  
  3339.  compile if 0  -- LAM: Delete this feature; nobody used it, and it slowed things down.
  3340.    do_array 3, EPM_utility_array_ID, 'menu.0', menucount     -- Item 0 is count of menus.
  3341.    if menucount=0 then return; endif
  3342.  compile endif
  3343.    getfileid fid
  3344.    if fid<>'' then
  3345.  compile if 0  -- LAM: Delete this feature; nobody used it, and it slowed things down.
  3346.       showmenu_flag = 0
  3347.       do i=1 to menucount
  3348.          do_array 3, EPM_utility_array_ID, 'menu.'i, menuname   -- Get menuname[i]
  3349.          deletemenu menuname, 5, 0, 1                  -- Delete its ring menu
  3350.          if activemenu=menuname then showmenu_flag = 1; endif
  3351.       end
  3352.  compile else
  3353.       deletemenu defaultmenu, 5, 0, 1                  -- Delete its ring menu
  3354.  compile endif
  3355.  
  3356.       startid = fid
  3357. ;;    len = 1  -- Will be length of buffer required.  Init to 1 for null terminator.
  3358.       do menuid = 500 to 500+MENU_LIMIT     -- Prevent looping forever.
  3359. ;;       len = len + length(.filename) + 7  -- 7 = 1 sep '/' + max 4 for index + 2 blanks
  3360.  compile if 0  -- LAM: Delete this feature; nobody used it, and it slowed things down.
  3361.          do i=1 to menucount
  3362.             do_array 3, EPM_utility_array_ID, 'menu.'i, menuname   -- Get menuname[i]
  3363.             if menuid < 500 + MENU_LIMIT then
  3364.                buildmenuitem menuname, 5, menuid, .filename, 'activatefileid 'fid, 0, 0
  3365.             elseif menuid = 500 + MENU_LIMIT then
  3366.                buildmenuitem menuname, 5, menuid, '~'MORE__MSG'...', 'Ring_More', 0, 0
  3367.             endif
  3368.          end
  3369.  compile else
  3370.          if menuid < 500 + MENU_LIMIT then
  3371.             if .titletext=='' then
  3372.                buildmenuitem defaultmenu, 5, menuid, .filename, 'activatefileid 'fid, 0, 0
  3373.             else
  3374.                buildmenuitem defaultmenu, 5, menuid, .titletext, 'activatefileid 'fid, 0, 0
  3375.             endif
  3376.          elseif menuid = 500 + MENU_LIMIT then
  3377.             buildmenuitem defaultmenu, 5, menuid, '~'MORE__MSG'...', 'Ring_More', 0, 0
  3378.             activatefile startid
  3379.             leave
  3380.          endif
  3381.  compile endif
  3382.          nextfile
  3383.          getfileid fid
  3384.          if fid=startid then leave; endif
  3385.       enddo
  3386. ;;    do_array 2, EPM_utility_array_ID, 'NS', len   -- Item NS is NameSize - size of buffer.
  3387.       if activemenu=defaultmenu  then
  3388. compile if EVERSION < 5.60
  3389.          showmenu activemenu, 5
  3390. compile else
  3391.          showmenu activemenu
  3392. compile endif
  3393.       endif
  3394.    endif
  3395. compile endif
  3396.  
  3397. /*
  3398. ┌────────────────────────────────────────────────────────────────────────────┐
  3399. │ what's it called: WinMessageBox                                            │
  3400. │                                                                            │
  3401. │ what does it do : This routine issues a PM WinMessageBox call, and returns │
  3402. │                   the result.                                              │
  3403. │                                                                            │
  3404. └────────────────────────────────────────────────────────────────────────────┘
  3405. */
  3406. defproc winmessagebox(caption, text)
  3407.  
  3408. ; msgtype = 4096                                        -- must be system modal.
  3409. ; if arg(3) then
  3410. ;    msgtype=arg(3) + 4096 * (1 - (arg(3)%4096 - 2 * (arg(3)%8192)))  -- ensure x'1000' on
  3411. ; endif
  3412.   if arg(3) then
  3413.      msgtype=arg(3)
  3414.   else
  3415.      msgtype = 0
  3416.   endif
  3417.   caption = caption\0
  3418.   text    = text\0
  3419. compile if EPM32
  3420.   return dynalink32( 'PMWIN',
  3421. --                   'WINMESSAGEBOX',
  3422.                    "#789",
  3423.                    atol(1) ||   -- Parent
  3424.                    gethwndc(EPMINFO_EDITFRAME) ||   /* edit frame handle             */
  3425.                    address(text)      ||   -- Text
  3426.                    address(caption)   ||   -- Title
  3427.                    atol(0)            ||   -- Window
  3428.                    atol(msgtype) )         -- Style
  3429. compile else
  3430.   return dynalink( 'PMWIN',
  3431.                    'WINMESSAGEBOX',
  3432.                    atoi(0) || atoi(1) ||   -- Parent
  3433.                    -- atoi(0) || atoi(1) ||   -- Owner
  3434.                    gethwnd(EPMINFO_EDITFRAME) ||   /* edit frame handle             */
  3435.                    address(text)      ||   -- Text
  3436.                    address(caption)   ||   -- Title
  3437.                    atoi(0)            ||   -- Window
  3438.                    atoi(msgtype) )         -- Style
  3439. compile endif  -- EPM32
  3440.  
  3441.  
  3442. /*
  3443. ┌────────────────────────────────────────────────────────────────────────────┐
  3444. │ what's it called: activatefileid                                           │
  3445. │                                                                            │
  3446. │ what does it do : This command is used when a RING menu item is selected   │
  3447. │                   it switches view to the file that was just selected.     │
  3448. │                                                                            │
  3449. └────────────────────────────────────────────────────────────────────────────┘
  3450. */
  3451. compile if MENU_LIMIT
  3452. defc activatefileid
  3453.    fid = arg(1)
  3454.    activatefile fid
  3455. compile endif
  3456.  
  3457. define
  3458. compile if MENU_LIMIT
  3459.    list_col=33                 -- Under 'Ring' on action bar
  3460. compile else
  3461.    list_col=23                 -- Under 'Options' on action bar
  3462. compile endif
  3463. /*
  3464. ┌────────────────────────────────────────────────────────────────────────────┐
  3465. │ what's it called: Ring_More                                                │
  3466. │                                                                            │
  3467. │ what does it do : This command is called when the More... selection on     │
  3468. │                   the ring menu is selected.  (Or by the Ring action bar   │
  3469. │                   item if MENU_LIMIT = 0.)  It generates a listbox         │
  3470. │                   containing all the filenames, and selects the            │
  3471. │                   appropriate fileid if a filename is selected.            │
  3472. │                                                                            │
  3473. └────────────────────────────────────────────────────────────────────────────┘
  3474. */
  3475. defc Ring_More
  3476. compile if EVERSION >= 5.20   -- The new way; easy and fast.
  3477.    if filesinring()=1 then
  3478.       sayerror ONLY_FILE__MSG
  3479.       return
  3480.    endif
  3481.    call windowmessage(0,  getpminfo(APP_HANDLE),
  3482.                       5141,               -- EPM_POPRINGDIALOG
  3483.                       0,
  3484.                       0)
  3485. compile else          -- The old way; slow and complicated.
  3486.    universal EPM_utility_array_ID
  3487.  
  3488.    sayerror LISTING__MSG
  3489.    getfileid fid
  3490.    startid = fid
  3491.  
  3492. ;; do_array 3, EPM_utility_array_ID, 'NS', len    -- Item NS is size of names buffer required
  3493.    len = 1  -- Will be length of buffer required.  Init to 1 for null terminator.
  3494.    tmp_str = ''  -- In case we don't need a buffer
  3495.    longest=0
  3496.    do i = 1 to FilesInRing(2)     -- Prevent looping forever.
  3497.       do_array 2, EPM_utility_array_ID, 'F'i, fid  -- Put fileid into array index [i]
  3498.       if .titletext=='' then
  3499.          fname=.filename
  3500.       else
  3501.          fname=.titletext
  3502.       endif
  3503.       len = len + length(fname) + length(i) + 3  -- 3 = 1 sep '/' + 2 blanks
  3504.       longest=max(longest, length(fname) + length(i) + 2)
  3505.       tmp_str = tmp_str || \1 || i || ' 'substr('. ',(.modify=0)+1,1) || fname
  3506.       nextfile
  3507.       getfileid fid
  3508.       if fid=startid then leave; endif
  3509.    enddo
  3510.    if i=1 then
  3511.       sayerror ONLY_FILE__MSG
  3512.       return
  3513.    endif
  3514.  
  3515.    if length(tmp_str)<MAXCOL then  -- We can use the string; no need to bother with a buffer.
  3516.       filesbuffer = selector(tmp_str)
  3517.       filesbuf_offset = offset(tmp_str)
  3518.       buf_offset = length(tmp_str)
  3519.       tmp_str = tmp_str\0                      -- null terminate
  3520.       free_the_buffer = 0
  3521.    else                         -- Have to allocate and fill a buffer.
  3522.       filesbuffer = "??"                  -- initialize string pointer
  3523.       r =  dynalink('DOSCALLS',           -- dynamic link library name
  3524.                '#34',                     -- DosAllocSeg
  3525.                atoi(min(len+1,65535)) ||  -- Number of Bytes requested
  3526.                address(filesbuffer)   ||  -- string address
  3527.                atoi(0))                   -- Share information
  3528.  
  3529.       if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif
  3530.  
  3531.       filesbufseg = itoa(filesbuffer,10)
  3532.       buf_offset = 0
  3533.       filesbuf_offset = atoi(0)
  3534.  
  3535.       do i = 1 to FilesInRing(2)
  3536. ;;       do_array 2, EPM_utility_array_ID, 'F'i, fid  -- Put fileid into array index [i]
  3537.          if .titletext=='' then
  3538.             fname=.filename
  3539.          else
  3540.             fname=.titletext
  3541.          endif
  3542.          tmp_str = \1 || i || ' 'substr('. ',(.modify=0)+1,1) || fname
  3543.                                                     -- \1 || "1  D:\E_MACROS\STDCTRL.E"
  3544.          if buf_offset+length(tmp_str) >= 65535 then
  3545.             activatefile startid
  3546.             call WinMessageBox(TOO_MANY_FILES__MSG, NOT_FIT__MSG, 16416)
  3547.             leave
  3548.          endif
  3549.          poke filesbufseg,buf_offset,tmp_str
  3550.          buf_offset=buf_offset+length(tmp_str)
  3551.          nextfile
  3552.          getfileid fid
  3553.          if fid=startid then leave; endif
  3554.       enddo
  3555.       poke filesbufseg,buf_offset,\0        -- Null terminate
  3556.       free_the_buffer = 1
  3557.    endif
  3558.  
  3559.    but1=SELECT__MSG\0; but2=CANCEL__MSG\0; but3=\0; but4=\0; but5=\0; but6=\0; but7=\0   /* default butts*/
  3560.  
  3561.    if longest<.windowwidth-LIST_COL then
  3562.       col=LIST_COL           -- Under appropriate pulldown on action bar.
  3563.    else
  3564.       col=0                  -- At left edge of edit window.
  3565.    endif
  3566. ;; row = -2 - querycontrol(7) - querycontrol(8)  -- Allow for status and message line
  3567.  
  3568.    /* null terminate return buffer  */
  3569.    selectbuf = leftstr(\0,255)  -- If this were used for 5.53 or above, would have to change this...
  3570.  
  3571.    rect = '????????????????'     -- Left, Bottom, Right, Top
  3572.    call dynalink( 'PMWIN',
  3573.              'WINQUERYWINDOWRECT',
  3574.               gethwnd(EPMINFO_EDITCLIENT) ||
  3575.               address(rect) )
  3576.  
  3577. ; LAM:  Originally, I placed the listbox more or less below the action bar menu
  3578. ;       title.  But, on some machines, it didn't wind up in the right place.
  3579. ;       Also, it got thrown off if the user had partial text displayed.  So, I
  3580. ;       changed from (a) to (b), which gets the exact position in pels (using
  3581. ;       the WinQueryWindowRect call, above) rather than multiplying an
  3582. ;       approximate character position by the font height.  (c) was an attempt
  3583. ;       to place the list box immediately under the pulldown, by taking into
  3584. ;       account the status line and message line.  I decided that I wanted to
  3585. ;       see the status line (so the "nnn files" wouldn't be covered), so I went
  3586. ;       back to (b).  It's more efficient, and I'm willing to not worry about
  3587. ;       whether or not the message line is covered by the listbox.
  3588.  
  3589.    title=FILES_IN_RING__MSG\0
  3590.  
  3591.    sayerror 0; refresh
  3592.  
  3593.    call dynalink( ERES_DLL,                -- list box control in EDLL dynalink
  3594.              'LISTBOX',                    -- function name
  3595.               gethwnd(EPMINFO_EDITFRAME)||   -- edit frame handle
  3596.               atoi(3)                   ||
  3597.               atoi(.fontwidth * col)    ||   -- coordinates
  3598. ;;  (a)       atoi(.fontheight*(screenheight()+querycontrol(7)+querycontrol(8))) ||
  3599.               substr(rect,13,2)         ||   -- (b)
  3600. ;;  (c)       atoi(itoa(substr(rect,13,2),10)+.fontheight*(querycontrol(7)+querycontrol(8))) ||
  3601.               atoi(min(i,16))           ||   -- height = smaller of # files or 16
  3602.               atoi(0)                   ||   -- width - 0 means as much as needed
  3603.               atoi(2)                   ||   -- Number of buttons
  3604.               address(title)            ||   -- title
  3605.               address(but1)             ||   -- text to appear in buttons
  3606.               address(but2)             ||
  3607.               address(but3)             ||
  3608.               address(but4)             ||
  3609.               address(but5)             ||
  3610.               address(but6)             ||
  3611.               address(but7)             ||
  3612.               atoi(buf_offset)          ||   -- length of list
  3613.               filesbuffer               ||   -- list segment
  3614.               filesbuf_offset           ||   -- list offset
  3615.               address(selectbuf) )           -- return string buffer
  3616.  
  3617.    if free_the_buffer then
  3618.       call dynalink('DOSCALLS',         -- dynamic link library name
  3619.                '#39',                   -- DosFreeSeg
  3620.                filesbuffer)
  3621.    endif
  3622.  
  3623.    EOS = pos(\0,selectbuf)        -- CHR(0) signifies End Of String
  3624.    if EOS = 1 then return; endif
  3625.    parse value selectbuf with idx .
  3626.    if not isnum(idx) then sayerror UNEXPECTED__MSG; return; endif
  3627.    do_array 3, EPM_utility_array_ID, 'F'idx, fileid
  3628.    activatefile fileid
  3629. compile endif         -- The old way; slow and complicated.
  3630.  
  3631. defproc mpfrom2short(mphigh, mplow)
  3632.    return ltoa( atoi(mplow) || atoi(mphigh), 10 )
  3633.  
  3634. /* Returns the edit window handle, as a 4-digit decimal string. */
  3635. defproc gethwnd(w)
  3636. ;  EditHwnd = getpminfo(w)         /* get edit window handle          */
  3637.  
  3638.    /* String handling in E language :                                 */
  3639.    /*    EditHwnd = '1235:1234'   <-  address in string form          */
  3640.    /*    atol(EditHwnd)= '11GF'   <-  four byte pointer, represented  */
  3641.    /*                                 as its ascii character          */
  3642.    /*                                 equivalent.                     */
  3643.    /*    Flipping (substr(...) ) <-  places 4 bytes in correct order. */
  3644.    /*    Note:    2byte vars are converted with atoi   ie.  USHORT    */
  3645.    /*    Note:    4byte vars are converted with atol   ie.  HWND,HAB  */
  3646.  
  3647.                                   /* get edit window handle           */
  3648.                                   /* convert string to string pointer */
  3649.                                   /* interchange upper two bytes with */
  3650.                                   /* lower two bytes. (flip words)    */
  3651.    return atol_swap(getpminfo(w))
  3652.  
  3653.  
  3654. defproc gethwndc(w)
  3655.    return atol(getpminfo(w))
  3656.  
  3657.  
  3658. /*
  3659. ┌────────────────────────────────────────────────────────────────────────────┐
  3660. │ what's it called: dupmark                                                  │
  3661. │                                                                            │
  3662. │ what does it do : This command is used when a Mark menu item is selected   │
  3663. │                                                                            │
  3664. └────────────────────────────────────────────────────────────────────────────┘
  3665. */
  3666. defc dupmark
  3667.    mt = upcase(arg(1))
  3668.    if     mt = 'M' then
  3669. ;     if marktype() then
  3670.          call pmove_mark()
  3671. ;     else                 -- If no mark, look in Shared Text buffer
  3672. ;       'GetSharBuff'      -- See clipbrd.e for details
  3673. ;     endif
  3674.    elseif mt = 'C' then
  3675.       if marktype() then
  3676.          call pcopy_mark()
  3677.       else                 -- If no mark, look in Shared Text buffer
  3678.          'GetSharBuff'     -- See clipbrd.e for details
  3679.       endif
  3680.    elseif mt = 'O' then
  3681.       if marktype() then
  3682. compile if WANT_CHAR_OPS
  3683.          call pcommon_adjust_overlay('O')
  3684. compile else
  3685.          overlay_block
  3686. compile endif
  3687.       else                 -- If no mark, look in Shared Text buffer
  3688.          'GetSharBuff O'   -- See clipbrd.e for details
  3689.       endif
  3690.    elseif mt = 'A' then
  3691. compile if WANT_CHAR_OPS
  3692.       call pcommon_adjust_overlay('A')
  3693. compile else
  3694.       adjustblock
  3695. compile endif
  3696.    elseif mt = 'U' then
  3697.       unmark
  3698.       'ClearSharBuff'
  3699.    elseif mt = 'U2' then  -- Unmark w/o clearing buffer, for drag/drop
  3700.       unmark
  3701.    elseif mt = 'D' then  -- Normal delete mark
  3702. compile if WANT_DM_BUFFER
  3703.       'Copy2DMBuff'        -- See clipbrd.e for details
  3704. compile endif  -- WANT_DM_BUFFER
  3705.       call pdelete_mark()
  3706.       'ClearSharBuff'
  3707.    elseif mt = 'D2' then  -- special for drag/drop; only deletes mark w/o touching buffers
  3708.       call pdelete_mark()
  3709.    elseif mt = 'P' then    -- Print marked area
  3710.       call checkmark()     -- verify there is a marked area,
  3711. ;compile if ENHANCED_PRINT_SUPPORT  -- DUPMARK P is only called if no enhanced print support
  3712. ;      printer=get_printer()
  3713. ;      if printer<>'' then 'print' printer; endif
  3714. ;compile else
  3715.       'print'              -- then print it.
  3716. ;compile endif
  3717.    endif
  3718.  
  3719. /*
  3720. ╔════════════════════════════════════════════════════════════════════════════╗
  3721. ║ MENU support.                                                              ║
  3722. ║      EPM's menu support is achieved through the use of the MENU manager.   ║
  3723. ║      This menu manager is located in EUTIL.DLL in versions prior to 5.20;  ║
  3724. ║      in E.DLL for EPM 5.20 and above.  The menu manager contains powerful  ║
  3725. ║      functions that allow an application to create there own named menus.  ║
  3726. ║      Building Menus with the Menu Manager:                                 ║
  3727. ║        The menu manager provides two fuctions which allow the creating     ║
  3728. ║        or replacing of items in a named menu.                              ║
  3729. ║        Note: A menu is first built and then displayed in the window.       ║
  3730. ║        BUILDSUBMENU  - creates or modifies a sub menu                      ║
  3731. ║        BUILDMENUITEM - create  or modifies a menu item under a sub menu    ║
  3732. ║                                                                            ║
  3733. ║      Showing a named Menu                                                  ║
  3734. ║        SHOWMENU      - show the specified named menu in the specified      ║
  3735. ║                        window frame.                                       ║
  3736. ║                                                                            ║
  3737. ║      Deleting a name menu                                                  ║
  3738. ║        DELETEMENU    - remove a named menu from the internal menory        ║
  3739. ║                        manager.                                            ║
  3740. ╚════════════════════════════════════════════════════════════════════════════╝
  3741. */
  3742.  
  3743. defexit
  3744.    universal defaultmenu
  3745.  
  3746.    deletemenu defaultmenu
  3747.    defaultmenu=''
  3748.  
  3749. /*
  3750. ┌─────────────────────────────────────────────────────────────────────────────┐
  3751. │What's it called  : processcommand                                           │
  3752. │                                                                             │
  3753. │What does it do   : This command is not called by macros.  It is called by   │
  3754. │                    the internal editor message handler.   When a menu       │
  3755. │                    selected messaged is received by the internal message    │
  3756. │                    handler, (WM_COMMAND) this function is called with       │
  3757. │                    the menu id as a parameter.                              │
  3758. │                                                                             │
  3759. │                                                                             │
  3760. │Who and When      : Jerry C.     3/4/89                                      │
  3761. └─────────────────────────────────────────────────────────────────────────────┘
  3762. */
  3763. defc processcommand
  3764.  compile if EVERSION > 5.20
  3765.    universal activeaccel
  3766.  compile endif
  3767.    universal activemenu
  3768.  
  3769.    menuid = arg(1)
  3770.    if menuid='' then
  3771.       sayerror PROCESS_ERROR__MSG
  3772.       return
  3773.    endif
  3774.  
  3775.    -- first test if command was generated by the
  3776.    -- next/prev buttons on the editor frame.
  3777.    if menuid=44 then
  3778.       nextfile
  3779.    elseif menuid=45 then
  3780.       prevfile
  3781. compile if EVERSION >= 5.60
  3782.    elseif menuid=8101 then  -- Temporarily hardcode this
  3783.       'configdlg SYS'
  3784. compile endif
  3785.    else
  3786. compile if EVERSION > 5.20
  3787.       accelstr=queryaccelstring(activeaccel, menuid)
  3788.       if accelstr<>'' then
  3789.          accelstr
  3790.       else
  3791. compile endif
  3792.          if activemenu='' then
  3793. ;;          sayerror MENU_ERROR__MSG '- ProcessCommand' arg(1)
  3794.             return
  3795.          endif
  3796.          -- execute user string, after stripping off null terminating char
  3797.          parse value querymenustring(activemenu,menuid) with command \1 helpstr
  3798.          strip(command,'T',\0)
  3799. compile if EVERSION > 5.20
  3800.       endif
  3801. compile endif
  3802.    endif
  3803.  
  3804. compile if EVERSION >= 5.51 & 0  -- Not used...
  3805. defc processaccel
  3806.    universal activeaccel
  3807.    menuid = arg(1)
  3808.    if menuid='' then
  3809.       sayerror PROCESS_ERROR__MSG
  3810.       return
  3811.    endif
  3812.    queryaccelstring(activeaccel, menuid)
  3813. compile endif
  3814.  
  3815. defc processmenuselect  -- Called when a menu item is activated; used for prompting
  3816. compile if INCLUDE_MENU_SUPPORT
  3817.    universal activemenu
  3818. compile if WANT_DYNAMIC_PROMPTS
  3819.    universal menu_prompt
  3820. compile endif
  3821.  
  3822. compile if EVERSION >= 5.60
  3823.    universal previouslyactivemenu
  3824.    parse arg menutype menuid .
  3825. ;  if menutype = 'A' & previouslyactivemenu<>'' then
  3826.    if menuid < 80 & menuid <> '' & previouslyactivemenu<>'' then  -- Temp kludge
  3827.       activemenu = previouslyactivemenu
  3828.       previouslyactivemenu = ''
  3829.    endif
  3830. compile else
  3831.    menuid = arg(1)
  3832. compile endif
  3833. compile if WANT_DYNAMIC_PROMPTS
  3834.    if menuid='' | activemenu='' | not menu_prompt then
  3835.       sayerror 0
  3836.       return
  3837.    endif
  3838.    parse value querymenustring(activemenu,menuid) with command \1 helpstr
  3839.    if helpstr<>'' then
  3840.  compile if EVERSION >= '5.21'
  3841.       display -8
  3842.  compile endif
  3843.       sayerror helpstr
  3844.  compile if EVERSION >= '5.21'
  3845.       display 8
  3846.  compile endif
  3847.    else
  3848.       sayerror 0
  3849.    endif
  3850. compile else
  3851.    sayerror 0
  3852. compile endif  -- WANT_DYNAMIC_PROMPTS
  3853. compile endif  -- INCLUDE_MENU_SUPPORT
  3854.  
  3855. ; Note:  this routine does *not* get called when Command (menuid 1) is selected.
  3856. defc PROCESSMENUINIT  -- Called when a pulldown or pullright is initialized.
  3857.  compile if INCLUDE_MENU_SUPPORT
  3858.    universal activemenu, defaultmenu
  3859.    universal EPM_utility_array_ID
  3860.  compile if WANT_DYNAMIC_PROMPTS
  3861.    universal menu_prompt
  3862.  compile endif
  3863.    universal lastchangeargs
  3864.  compile if WANT_STACK_CMDS
  3865.    universal mark_stack, position_stack
  3866.   compile if WANT_STACK_CMDS = 'SWITCH'
  3867.    universal stack_cmds
  3868.   compile endif
  3869.  compile endif
  3870.  compile if WANT_CUA_MARKING = 'SWITCH'
  3871.    universal CUA_marking_switch
  3872.  compile endif
  3873.  compile if WANT_STREAM_MODE = 'SWITCH'
  3874.    universal stream_mode
  3875.  compile endif
  3876.  compile if RING_OPTIONAL
  3877.    universal ring_enabled
  3878.  compile endif
  3879.  compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  3880.    universal CUA_MENU_ACCEL
  3881.  compile endif
  3882.  compile if CHECK_FOR_LEXAM
  3883.    universal LEXAM_is_available
  3884.  compile endif
  3885.  
  3886.    if activemenu<>defaultmenu then return; endif
  3887.    menuid = arg(1)
  3888.  compile if EVERSION >= 5.51
  3889.   compile if defined(SITE_MENUINIT)
  3890.       compile if SITE_MENUINIT
  3891.          include SITE_MENUINIT
  3892.       compile endif
  3893.   compile endif
  3894.    if isadefc('menuinit_'menuid) then
  3895. ;  -- Bug?  Above doesn't work...
  3896. ;  tmp = 'menuinit_'menuid
  3897. ;  if isadefc(tmp) then
  3898.       'menuinit_'menuid
  3899.       return
  3900.    endif
  3901.    tryinclude 'mymnuini.e'  -- For user-supplied additions to this routine.
  3902.  compile endif -- EVERSION >= 5.51
  3903.  
  3904. ; The following is individual commands on 5.51+; all part of ProcessMenuInit cmd on earlier versions.
  3905. compile if not defined(STD_MENU_NAME)
  3906.  compile if EVERSION >= 5.51    ------------- Menu id 8 -- Edit -------------------------
  3907.    defc menuinit_8
  3908.   compile if WANT_STACK_CMDS
  3909.    universal mark_stack, position_stack
  3910.    compile if WANT_STACK_CMDS = 'SWITCH'
  3911.    universal stack_cmds
  3912.    compile endif
  3913.   compile endif
  3914.  compile else -- EVERSION >= 5.51
  3915.    if menuid=8 then
  3916.  compile endif -- EVERSION >= 5.51
  3917.  compile if EVERSION < '5.50'
  3918.       getline current
  3919.       undo
  3920.       getline original
  3921.       undo
  3922.       SetMenuAttribute( 816, 16384, original/==current)
  3923.  compile else
  3924.       SetMenuAttribute( 816, 16384, isadirtyline())
  3925.  compile endif
  3926.       undoaction 1, PresentState        -- Do to fix range, not for value.
  3927.       undoaction 6, StateRange               -- query range
  3928.       parse value staterange with oldeststate neweststate .
  3929.       SetMenuAttribute( 818, 16384, oldeststate<>neweststate )  -- Set to 1 if different
  3930.  compile if EVERSION >= '6.03'
  3931.       paste = clipcheck(format) & (format=1024) & not (browse() | .readonly)
  3932.  compile elseif EPM32
  3933.       paste = clipcheck(format) & (format=1024) & browse()=0
  3934.  compile else
  3935.       paste = clipcheck(format) & (format=256) & browse()=0
  3936.  compile endif  -- EPM32
  3937.       SetMenuAttribute( 810, 16384, paste)
  3938.       SetMenuAttribute( 811, 16384, paste)
  3939.       SetMenuAttribute( 812, 16384, paste)
  3940.       on = marktype()<>''
  3941.       buf_flag = 0
  3942.       if not on then                             -- Only check buffer if no mark
  3943.          bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER)
  3944.          if bufhndl then                         -- If the buffer exists, check the
  3945.             buf_flag=itoa(peek(bufhndl,2,2),10)  -- amount of used space in buffer
  3946.             call buffer(FREEBUF, bufhndl)        -- then free it.
  3947.          endif
  3948.       endif
  3949.       SetMenuAttribute( 800, 16384, on | buf_flag)  -- Can copy if mark or buffer has data
  3950.       SetMenuAttribute( 801, 16384, on)
  3951.       SetMenuAttribute( 802, 16384, on | buf_flag)  -- Ditto for Overlay mark
  3952.       SetMenuAttribute( 803, 16384, on)
  3953.       SetMenuAttribute( 805, 16384, on)
  3954.       SetMenuAttribute( 806, 16384, on)
  3955.       SetMenuAttribute( 808, 16384, on)
  3956.       SetMenuAttribute( 809, 16384, on)
  3957.       SetMenuAttribute( 814, 16384, on)
  3958.  compile if WANT_STACK_CMDS
  3959.   compile if WANT_STACK_CMDS = 'SWITCH'
  3960.    if stack_cmds then
  3961.   compile endif
  3962.       SetMenuAttribute( 820, 16384, on)
  3963.       SetMenuAttribute( 821, 16384, mark_stack<>'')
  3964.       SetMenuAttribute( 822, 16384, on & mark_stack<>'')
  3965.       SetMenuAttribute( 824, 16384, position_stack<>'')
  3966.       SetMenuAttribute( 825, 16384, position_stack<>'')
  3967.   compile if WANT_STACK_CMDS = 'SWITCH'
  3968.    endif
  3969.   compile endif
  3970.  compile endif
  3971.  compile if EVERSION < 5.51
  3972.       return
  3973.    endif
  3974.  compile endif -- EVERSION < 5.51
  3975.  
  3976.  compile if EVERSION >= 5.51    ------------- Menu id 4 -- Options ---------------------
  3977.    defc menuinit_4
  3978.   compile if RING_OPTIONAL
  3979.    universal ring_enabled
  3980.   compile endif
  3981.   compile if CHECK_FOR_LEXAM
  3982.    universal LEXAM_is_available
  3983.   compile endif
  3984.  compile else -- EVERSION >= 5.51
  3985.    if menuid=4 then
  3986.  compile endif -- EVERSION >= 5.51
  3987.  compile if RING_OPTIONAL
  3988.       if ring_enabled then
  3989.  compile endif
  3990.          SetMenuAttribute( 410, 16384, filesinring()>1)
  3991.  compile if RING_OPTIONAL
  3992.       endif
  3993.  compile endif
  3994.  compile if SPELL_SUPPORT
  3995.   compile if CHECK_FOR_LEXAM
  3996.     if LEXAM_is_available then
  3997.   compile endif
  3998.       SetMenuAttribute( 450, 8192, .keyset <> 'SPELL_KEYS')
  3999.   compile if CHECK_FOR_LEXAM
  4000.     endif
  4001.   compile endif
  4002.  compile endif  -- SPELL_SUPPORT
  4003.  compile if EVERSION < 5.51
  4004.       return
  4005.    endif
  4006.  compile endif -- EVERSION < 5.51
  4007.  
  4008.  compile if WANT_CUA_MARKING = 'SWITCH' | WANT_STREAM_MODE = 'SWITCH' | RING_OPTIONAL | WANT_STACK_CMDS = 'SWITCH'
  4009.   compile if EVERSION >= 5.51    ------------- Menu id 400 -- Options / Preferences -------
  4010.    defc menuinit_400
  4011.   compile if WANT_STACK_CMDS = 'SWITCH'
  4012.    universal stack_cmds
  4013.   compile endif
  4014.   compile if WANT_CUA_MARKING = 'SWITCH'
  4015.    universal CUA_marking_switch
  4016.   compile endif
  4017.   compile if WANT_STREAM_MODE = 'SWITCH'
  4018.    universal stream_mode
  4019.   compile endif
  4020.   compile if RING_OPTIONAL
  4021.    universal ring_enabled
  4022.   compile endif
  4023.   compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  4024.    universal CUA_MENU_ACCEL
  4025.   compile endif
  4026.   compile else -- EVERSION >= 5.51
  4027.    if menuid=400 then              -- Options / Preferences
  4028.   compile endif -- EVERSION >= 5.51
  4029.   compile if WANT_CUA_MARKING = 'SWITCH'
  4030.       SetMenuAttribute( 441, 8192, CUA_marking_switch)
  4031.   compile endif
  4032.   compile if WANT_STREAM_MODE = 'SWITCH'
  4033.       SetMenuAttribute( 442, 8192, not stream_mode)
  4034.   compile endif
  4035.   compile if RING_OPTIONAL
  4036.       SetMenuAttribute( 443, 8192, not ring_enabled)
  4037.   compile endif
  4038.   compile if WANT_STACK_CMDS = 'SWITCH'
  4039.       SetMenuAttribute( 445, 8192, not stack_cmds)
  4040.   compile endif
  4041.   compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  4042.     SetMenuAttribute( 446, 8192, not CUA_MENU_ACCEL)
  4043.   compile endif
  4044.   compile if EVERSION < 5.51
  4045.       return
  4046.    endif
  4047.   compile endif -- EVERSION < 5.51
  4048.  compile endif  -- WANT_CUA_MARKING, WANT_STREAM_MODE, RING_OPTIONAL, WANT_STACK_CMDS
  4049.  
  4050.  compile if EVERSION >= 5.51    ------------- Menu id 425 -- Options / Frame controls  ---
  4051.    defc menuinit_425
  4052.    universal bitmap_present
  4053.   compile if RING_OPTIONAL
  4054.       universal ring_enabled
  4055.   compile endif
  4056.   compile if WANT_DYNAMIC_PROMPTS
  4057.       universal menu_prompt
  4058.   compile endif
  4059.  compile else -- EVERSION >= 5.51
  4060.    if menuid=425 then              -- Options / Frame controls
  4061.  compile endif -- EVERSION >= 5.51
  4062.  compile if EVERSION >= 5.53
  4063.       SetMenuAttribute( 413, 8192, not queryframecontrol(1) )
  4064.       SetMenuAttribute( 414, 8192, not queryframecontrol(2) )
  4065.       SetMenuAttribute( 415, 8192, not queryframecontrol(16))
  4066.   compile if EVERSION < 5.50  -- File icon not optional in 5.50
  4067.       SetMenuAttribute( 416, 8192, not queryframecontrol(64))
  4068.   compile endif
  4069.  compile else
  4070.       SetMenuAttribute( 413, 8192, not querycontrol(7) )
  4071.       SetMenuAttribute( 414, 8192, not querycontrol(8) )
  4072.       SetMenuAttribute( 415, 8192, not querycontrol(10))
  4073. ;;    SetMenuAttribute( 416, 8192, not querycontrol(15))
  4074.   compile if EVERSION < 5.50  -- File icon not optional in 5.50
  4075.       SetMenuAttribute( 416, 8192, not querycontrol(22))
  4076.   compile endif
  4077.  compile endif
  4078.  compile if RING_OPTIONAL
  4079.       if ring_enabled then
  4080.  compile endif
  4081.  compile if EVERSION >= 5.53
  4082.          SetMenuAttribute( 417, 8192, not queryframecontrol(4))
  4083.   compile if WANT_TOOLBAR
  4084.          SetMenuAttribute( 430, 8192, not queryframecontrol(EFRAMEF_TOOLBAR))
  4085.   compile endif
  4086.          SetMenuAttribute( 437, 8192, not bitmap_present)
  4087.  compile else
  4088.          SetMenuAttribute( 417, 8192, not querycontrol(20))
  4089.  compile endif
  4090.  compile if RING_OPTIONAL
  4091.       else
  4092.          SetMenuAttribute( 417, 16384, 1)  -- Grey out Rotate Buttons if ring not enabled
  4093.       endif
  4094.  compile endif
  4095.  compile if EVERSION >= 5.53
  4096.       SetMenuAttribute( 421, 8192, not queryframecontrol(32))
  4097.  compile else
  4098.       SetMenuAttribute( 421, 8192, not querycontrol(23))
  4099.  compile endif
  4100.  compile if WANT_DYNAMIC_PROMPTS
  4101.       SetMenuAttribute( 422, 8192, not menu_prompt)
  4102.  compile endif
  4103.  compile if EVERSION < 5.51
  4104.       return
  4105.    endif
  4106.  compile endif -- EVERSION < 5.51
  4107.  
  4108.  compile if EVERSION >= 5.51    ------------- Menu id 3 -- Search -----------------------
  4109.    defc menuinit_3
  4110.       universal lastchangeargs
  4111.  compile else -- EVERSION >= 5.51
  4112.    if menuid=3 then              -- Search
  4113.  compile endif -- EVERSION >= 5.51
  4114.       getsearch strng
  4115.       parse value strng with . c .       -- blank, 'c', or 'l'
  4116.       SetMenuAttribute( 302, 16384, c<>'')  -- Find Next OK if not blank
  4117.       SetMenuAttribute( 303, 16384, lastchangeargs<>'')  -- Change Next only if 'c'
  4118.  compile if EVERSION < 5.51
  4119.       return
  4120.    endif
  4121.  compile endif -- EVERSION < 5.51
  4122.  
  4123.  compile if WANT_BOOKMARKS
  4124.   compile if EVERSION >= 5.51    ------------- Menu id 3 -- Search -----------------------
  4125.    defc menuinit_305
  4126.       universal EPM_utility_array_ID
  4127.   compile else -- EVERSION >= 5.51
  4128.    if menuid=305 then              -- Search
  4129.   compile endif -- EVERSION >= 5.51
  4130.       do_array 3, EPM_utility_array_ID, 'bmi.0', bmcount          -- Index says how many bookmarks there are
  4131.   compile if EVERSION >= '6.03'
  4132.       SetMenuAttribute( 306, 16384, not (browse() | .readonly))  -- Set
  4133.   compile else
  4134.       SetMenuAttribute( 306, 16384, browse()=0)  -- Set
  4135.   compile endif
  4136.       SetMenuAttribute( 308, 16384, bmcount>0)   -- List
  4137.       SetMenuAttribute( 311, 16384, bmcount>0)   -- Next
  4138.       SetMenuAttribute( 312, 16384, bmcount>0)   -- Prev
  4139.   compile if EVERSION < 5.51
  4140.       return
  4141.    endif
  4142.   compile endif -- EVERSION < 5.51
  4143.  compile endif  -- WANT_BOOKMARKS
  4144.  
  4145. ; Also will need to handle 204 (Name) on File menu if 5.60 & LaMail...
  4146.  
  4147.  compile if EVERSION < 5.51  -- The old way:
  4148.    compile if defined(SITE_MENUINIT)
  4149.       compile if SITE_MENUINIT
  4150.          include SITE_MENUINIT
  4151.       compile endif
  4152.    compile endif
  4153.    tryinclude 'mymnuini.e'  -- For user-supplied additions to this routine.
  4154.  compile endif -- EVERSION < 5.51
  4155. compile endif -- not defined(STD_MENU_NAME)
  4156. ; The above is all part of ProcessMenuInit cmd on old versions.  -----------------
  4157. compile endif  -- INCLUDE_MENU_SUPPORT
  4158.  
  4159. defproc SetMenuAttribute( menuid, attr, on)
  4160. ;  universal EditMenuHwnd
  4161. ;  if not EditMenuHwnd then
  4162. ;     EditMenuHwnd = getpminfo(EPMINFO_EDITMENUHWND)  -- cache; relatively expensive to obtain.
  4163. ;  endif
  4164.    if not on then
  4165.       attr=mpfrom2short(attr, attr)
  4166.    endif
  4167.    call windowmessage(1,
  4168. ;                     EditMenuHwnd,  -- Doesn't work; EditMenuHwnd changes.
  4169.                       getpminfo(EPMINFO_EDITMENUHWND),
  4170.                       402,
  4171.                       menuid + 65536,
  4172.                       attr)
  4173.  
  4174.  
  4175. defc processname =
  4176.    newname = arg(1)
  4177.    if newname<>'' & newname<>.filename then
  4178. compile if defined(PROCESSNAME_CMD)  -- Let the user override this, if desired.
  4179.       PROCESSNAME_CMD newname
  4180. compile else
  4181.       'name' newname
  4182. compile endif
  4183.    endif
  4184.  
  4185. defc undo = undo
  4186.  
  4187. defc popbook =
  4188. compile if EVERSION >= 5.50 & EPATH<>'LAMPATH'
  4189.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4190.                       13,                   -- WM_ACTIVATE
  4191.                       1,
  4192.                       getpminfo(APP_HANDLE))
  4193. compile elseif EVERSION >= 5.21 & EPATH<>'LAMPATH'
  4194.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4195.                       5142,                   -- EPM_POP_BOOK_ICON
  4196.                       0,
  4197.                       0)
  4198. compile else
  4199.    call dynalink( 'PMWIN',
  4200.              'WINSETWINDOWPOS',
  4201.               gethwnd(EPMINFO_OWNERFRAME) ||
  4202.               atoi(0) || atoi(3)          ||      /* HWND_TOP   */
  4203.               atoi(0)                     ||
  4204.               atoi(0)                     ||
  4205.               atoi(0 )                    ||
  4206.               atoi(0 )                    ||
  4207.               atoi(132 ))                        /* SWP_ACTIVATE + SWP_ZORDER */
  4208. compile endif
  4209.  
  4210.  
  4211. defc printdlg
  4212. compile if EVERSION >= '5.51'
  4213.    call windowmessage(0,
  4214.                       getpminfo(APP_HANDLE),
  4215.                       5144,               -- EPM_PRINTDLG
  4216.                       arg(1)='M',
  4217.                       0)
  4218. compile else
  4219.  compile if EPM_POINTER = 'SWITCH'
  4220.    universal vEPM_POINTER
  4221.  compile endif
  4222.  compile if EVERSION >= '5.50'
  4223.     if arg(1)<>'M' then
  4224.        call windowmessage(0,
  4225.                           getpminfo(APP_HANDLE),
  4226.                           5144,               -- EPM_PRINTDLG
  4227.                           0,
  4228.   compile if EVERSION >= '5.51'  -- I don't know if this was ever used, but it's not
  4229.                           0)     -- used (or freed) in any current version.  LAM
  4230.   compile else
  4231.                           put_in_buffer(.filename))
  4232.   compile endif
  4233.        return
  4234.     endif
  4235.  compile else
  4236.     if arg(1)='M' then
  4237.  compile endif
  4238.        call checkmark()     -- verify there is a marked area,
  4239.  compile if EVERSION < '5.50'
  4240.     endif
  4241.  compile endif
  4242.     App = 'PM_SPOOLER_PRINTER'\0
  4243.     inidata = copies(' ',255)
  4244.  compile if EPM32
  4245.     retlen = \0\0\0\0
  4246.     l = dynalink32('PMSHAPI',
  4247.                    '#115',               -- PRF32QUERYPROFILESTRING
  4248.                    atol(0)           ||  -- HINI_PROFILE
  4249.                    address(App)      ||  -- pointer to application name
  4250.                    atol(0)           ||  -- Key name is NULL; returns all keys
  4251.                    atol(0)           ||  -- Default return string is NULL
  4252.                    address(inidata)  ||  -- pointer to returned string buffer
  4253.                    atol(255)    ||       -- max length of returned string
  4254.                    address(retlen), 2)         -- length of returned string
  4255.  compile else
  4256.     l =  dynalink( 'PMSHAPI',
  4257.                    'PRFQUERYPROFILESTRING',
  4258.                    atol(0)          ||  -- HINI_PROFILE
  4259.                    address(App)     ||  -- pointer to application name
  4260.                    atol(0)          ||  -- Key name is NULL; returns all keys
  4261.                    atol(0)          ||  -- Default return string is NULL
  4262.                    address(inidata) ||  -- pointer to returned string buffer
  4263.                    atol_swap(255), 2)        -- max length of returned string
  4264.  compile endif
  4265.  
  4266.     if not l then sayerror NO_PRINTERS__MSG; return; endif
  4267.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER', 'PRINTER') with default_printername ';'
  4268.     inidata=leftstr(inidata,l)
  4269.     getfileid startfid
  4270.     'xcom e /c /q tempfile'
  4271.     if rc<>-282 then  -- sayerror('New file')
  4272.        sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  4273.        return
  4274.     endif
  4275.     .autosave = 0
  4276.     browse_mode = browse()     -- query current state
  4277.     if browse_mode then call browse(0); endif
  4278. ;;; deleteline 1
  4279. ;;compile if EVERSION < 5.50
  4280.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER_DESCR', default_printername) with descr ';'
  4281.     insertline default_printername '('descr')', .last+1    -- Place default first.
  4282. ;;compile else
  4283. ;;   default_entry = 1
  4284. ;;compile endif
  4285.     do while inidata<>''
  4286.        parse value inidata with printername \0 inidata
  4287.        if printername=default_printername then
  4288. ;;compile if EVERSION < 5.50
  4289.           iterate
  4290. ;;compile else
  4291. ;;         default_entry = .last
  4292. ;;compile endif
  4293.        endif
  4294.        parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER_DESCR', printername) with descr ';'
  4295.        insertline printername '('descr')', .last+1
  4296.     enddo
  4297.     if browse_mode then call browse(1); endif  -- restore browse state
  4298.     if listbox_buffer_from_file(startfid, bufhndl, noflines, usedsize) then return; endif
  4299.  compile if EVERSION < 5.50
  4300.     ret = listbox(SELECT_PRINTER__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32),'',1,5)
  4301.  compile else
  4302.   compile if 0 -- POWERPC
  4303.     parse value listbox(PRINT__MSG, \0 || atol(usedsize) || atol(bufhndl+32),
  4304.   compile elseif EPM32
  4305.     parse value listbox(PRINT__MSG, \0 || atol(usedsize) || atoi(32) || atoi(bufhndl),
  4306.   compile else
  4307.     parse value listbox(PRINT__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32),
  4308.   compile endif
  4309.                         '/'DRAFT__MSG'/'WYSIWYG__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0,
  4310.   compile if EVERSION >= 5.60
  4311.                         gethwndc(APP_HANDLE) || atoi(1/*default_entry*/) || atoi(1) || atoi(6060) ||
  4312.   compile else
  4313.                         atoi(1/*default_entry*/) || atoi(1) || atoi(6060) || gethwndc(APP_HANDLE) ||
  4314.   compile endif
  4315.                         SELECT_PRINTER__MSG) with button 2 printername ' (' \0
  4316.  compile endif
  4317.     call buffer(FREEBUF, bufhndl)
  4318.  compile if EVERSION < 5.50
  4319.     if ret='' then return; endif
  4320.     parse value ret with printername ' ('
  4321.  compile else
  4322.     if button<>\1 & button<>\2 then return; endif
  4323.  compile endif
  4324.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER', printername) with dev ';' . ';' queue ';'
  4325.  compile if EVERSION >= 5.50
  4326.     if button=\1 then  -- Draft
  4327.  compile endif
  4328.        if dev='' then
  4329.           sayerror PRINTER__MSG printername NO_DEVICE__MSG
  4330.        else
  4331.           if arg(1)='M' then
  4332.              'print' dev   -- PRINT command will print the marked area
  4333.           else
  4334.  compile if EVERSION < '5.50'
  4335.              'xcom save' dev  -- Save the file to the printer
  4336.  compile else
  4337.              'xcom save /ne' dev  -- Save the file to the printer
  4338.  compile endif
  4339.           endif
  4340.        endif
  4341.  compile if EVERSION >= 5.50
  4342.     elseif button=\2 then  -- WYSIWYG
  4343.        if queue='' then
  4344.           sayerror PRINTER__MSG printername NO_QUEUE__MSG
  4345.        else
  4346.           if arg(1)='M' then
  4347.              getmark firstline,lastline,firstcol,lastcol,markfileid
  4348.              getfileid fileid
  4349.              mt=marktype()
  4350.              'xcom e /n'             /*  Create a temporary no-name file. */
  4351.              if rc=-282 then  -- sayerror("New file")
  4352.                 if browse_mode then call browse(0); endif  -- Turn off browse state
  4353.                 if mt='LINE' then deleteline endif
  4354.              elseif rc then
  4355.                 stop
  4356.              endif
  4357.              getfileid tempofid
  4358.              .levelofattributesupport = markfileid.levelofattributesupport
  4359.              .font = markfileid.font
  4360.              call pcopy_mark()
  4361.              if browse_mode then call browse(1); endif  -- restore browse state
  4362.              if rc then stop endif
  4363.              call pset_mark(firstline,lastline,firstcol,lastcol,mt,markfileid)
  4364.              activatefile tempofid
  4365.              sayerror PRINTING_MARK__MSG
  4366.           else
  4367.              sayerror PRINTING__MSG .filename
  4368.           endif
  4369.           mouse_setpointer WAIT_POINTER
  4370. ;;;       qprint queue
  4371.           qprint printername
  4372.           if arg(1)='M' then .modify=0; 'xcom q' endif
  4373.   compile if EPM_POINTER = 'SWITCH'
  4374.           mouse_setpointer vEPM_POINTER
  4375.   compile else
  4376.           mouse_setpointer EPM_POINTER
  4377.   compile endif
  4378.           sayerror 0    /* clear 'printing' message */
  4379.        endif  -- have queue
  4380.     endif  -- button 2
  4381.  compile endif
  4382. compile endif -- >= 5.51
  4383.  
  4384. defc printfile
  4385.    if arg(1)<>'' then
  4386. compile if EVERSION < '5.50'
  4387.       'xcom save' arg(1)  -- Save the file to the printer
  4388. compile else
  4389.       'xcom save /s /ne' arg(1)  -- Save the file to the printer
  4390. compile endif
  4391.    endif
  4392.  
  4393. compile if EVERSION >= 5.51
  4394. defc process_qprint
  4395.  compile if EPM_POINTER = 'SWITCH'
  4396.    universal vEPM_POINTER
  4397.  compile endif
  4398.    if arg(1)='' then
  4399.       sayerror PRINTER__MSG /*printername*/ NO_QUEUE__MSG
  4400.    else
  4401.       mouse_setpointer WAIT_POINTER
  4402.       qprint arg(1)
  4403.  compile if EPM_POINTER = 'SWITCH'
  4404.       mouse_setpointer vEPM_POINTER
  4405.  compile else
  4406.       mouse_setpointer EPM_POINTER
  4407.  compile endif
  4408.    endif
  4409.  
  4410. ; Flags
  4411. ;  F    = File
  4412. ;  M  1 = marked area (default = entire file)
  4413. ;  !  2 = print immediately; don't wait for print dialog's OK
  4414. ;     4 = queue name given
  4415. ;     8 = PRINTOPTS structure given (binary structure; can't be done via this cmd)
  4416. ;         (6.03a or above, only)
  4417. defc qprint
  4418.    parse arg what queue_name
  4419.    w = wordpos(upcase(what), 'M M! F F! !')
  4420.    if w then
  4421.       flags =           word('1 3  0 2  2', w)
  4422.    else                   -- Not a flag;
  4423.       queue_name = arg(1)  -- assume part of the queue name
  4424.       flags = 0            -- and use default options.
  4425.    endif
  4426.    if queue_name <> '' then flags = flags + 4; endif
  4427.    call windowmessage(0,
  4428.                       getpminfo(APP_HANDLE),
  4429.                       5144,               -- EPM_PRINTDLG
  4430.                       flags,
  4431.                       put_in_buffer(queue_name) )
  4432.  
  4433. compile elseif EVERSION >= 5.50
  4434.  
  4435. defc qprint
  4436.  compile if EPM_POINTER = 'SWITCH'
  4437.    universal vEPM_POINTER
  4438.  compile endif
  4439.    if arg(1)='' then
  4440.       sayerror PRINTER__MSG /*printername*/ NO_QUEUE__MSG
  4441.    else
  4442.       mouse_setpointer WAIT_POINTER
  4443.       qprint arg(1)
  4444.  compile if EPM_POINTER = 'SWITCH'
  4445.       mouse_setpointer vEPM_POINTER
  4446.  compile else
  4447.       mouse_setpointer EPM_POINTER
  4448.  compile endif
  4449.    endif
  4450. compile endif
  4451.  
  4452. compile if WANT_CUA_MARKING = 'SWITCH'
  4453. defc CUA_mark_toggle
  4454.    universal CUA_marking_switch
  4455.    CUA_marking_switch = not CUA_marking_switch
  4456.    'togglecontrol 25' CUA_marking_switch
  4457.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  4458.    SetMenuAttribute( 441, 8192, CUA_marking_switch)
  4459.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  4460.    call MH_set_mouse()
  4461. compile endif
  4462.  
  4463. compile if WANT_STREAM_MODE = 'SWITCH'
  4464. defc stream_toggle
  4465.    universal stream_mode
  4466.    stream_mode = not stream_mode
  4467.    'togglecontrol 24' stream_mode
  4468.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  4469.    SetMenuAttribute( 442, 8192, not stream_mode)
  4470.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  4471. compile endif
  4472.  
  4473. compile if RING_OPTIONAL
  4474. defc ring_toggle
  4475.    universal ring_enabled
  4476.    universal activemenu, defaultmenu
  4477.    ring_enabled = not ring_enabled
  4478.  compile if EVERSION < 5.53
  4479.    'togglecontrol 20' ring_enabled
  4480.  compile else
  4481.    'toggleframe 4' ring_enabled
  4482.  compile endif
  4483.  compile if INCLUDE_STD_MENUS
  4484.   compile if not defined(STD_MENU_NAME)
  4485.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the file menu
  4486.    call add_file_menu(defaultmenu)
  4487.    deletemenu defaultmenu, 4, 0, 1                  -- Delete the options menu
  4488.    call add_options_menu(defaultmenu, dos_version()>=1020)
  4489.    call maybe_show_menu()
  4490.   compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4491.    deletemenu defaultmenu, 1, 0, 1                  -- Delete the file menu
  4492.    call add_file_menu(defaultmenu)
  4493.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the view menu
  4494.    call add_view_menu(defaultmenu)
  4495.    call maybe_show_menu()
  4496.   compile endif
  4497. ; compile if WANT_NODISMISS_MENUS & EVERSION < 5.60
  4498. ;  SetMenuAttribute( 443, 8192, not ring_enabled)  -- We're rebuilding this menu; give it up.
  4499. ; compile endif  -- WANT_NODISMISS_MENUS
  4500.  compile endif  -- INCLUDE_STD_MENUS
  4501. compile endif
  4502.  
  4503. compile if WANT_STACK_CMDS = 'SWITCH'
  4504. defc stack_toggle
  4505.    universal stack_cmds
  4506.    universal activemenu, defaultmenu
  4507.    stack_cmds = not stack_cmds
  4508.  compile if INCLUDE_STD_MENUS
  4509.   compile if not defined(STD_MENU_NAME)
  4510.    deletemenu defaultmenu, 8, 0, 1                  -- Delete the edit menu
  4511.    call add_edit_menu(defaultmenu)
  4512.    call maybe_show_menu()
  4513.   compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4514.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the view menu
  4515.    call add_view_menu(defaultmenu)
  4516.    deletemenu defaultmenu, 3, 0, 1                  -- Delete the selected menu
  4517.    call add_selected_menu(defaultmenu)
  4518.    call maybe_show_menu()
  4519.   compile endif
  4520. ; compile if WANT_NODISMISS_MENUS & EVERSION < 5.60
  4521. ;  SetMenuAttribute( 445, 8192, not stack_cmds)
  4522. ; compile endif  -- WANT_NODISMISS_MENUS
  4523.  compile endif  -- INCLUDE_STD_MENUS
  4524. compile endif
  4525.  
  4526. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH' & INCLUDE_STD_MENUS
  4527. defc accel_toggle
  4528.    universal CUA_MENU_ACCEL
  4529.    universal activemenu, defaultmenu
  4530.    CUA_MENU_ACCEL = not CUA_MENU_ACCEL
  4531.    deleteaccel 'defaccel'
  4532.    'loadaccel'
  4533.  compile if not defined(STD_MENU_NAME)
  4534.    deletemenu defaultmenu, 8, 0, 1                  -- Delete the edit menu
  4535.    call add_edit_menu(defaultmenu)
  4536.    if activemenu=defaultmenu  then
  4537.   compile if 0   -- Don't need to actually show the menu; can just update the affected text.
  4538.       showmenu activemenu
  4539.   compile else
  4540.       call update_edit_menu_text()
  4541.   compile endif
  4542.    endif
  4543.  compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4544.    deletemenu defaultmenu, 3, 0, 1                  -- Delete the selected menu
  4545.    call add_selected_menu(defaultmenu)
  4546.    if activemenu=defaultmenu  then
  4547.   compile if 0   -- Don't need to actually show the menu; can just update the affected text.
  4548.       showmenu activemenu
  4549.   compile else
  4550.       call update_edit_menu_text()
  4551.   compile endif
  4552.    endif
  4553.  compile endif
  4554.  compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  4555.    SetMenuAttribute( 446, 8192, not CUA_MENU_ACCEL)
  4556.  compile endif  -- WANT_NODISMISS_MENUS
  4557. compile endif
  4558.  
  4559. compile if WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21
  4560. ; This will be moved into the notebook control, so no NLS translation for the temporary macro code.
  4561. defc config_enter
  4562.  compile if EPATH = 'LAMPATH'
  4563.    call dynalink( 'LAMRES',
  4564.                   'LAMRESENTERKEYDIALOG',
  4565.                   gethwnd(EPMINFO_EDITFRAME) ||
  4566.                   gethwnd(EPMINFO_EDITFRAME) )
  4567.  compile else
  4568.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  4569.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  4570.   compile if WANT_STREAM_MODE = 'SWITCH'
  4571.    universal stream_mode
  4572.   compile endif
  4573.    k = listbox('Select a key to configure','/1.  Enter/2.  Alt+Enter/3.  Ctrl+Enter/4.  Shift+Enter/5.  PadEnter/6.  Alt+PadEnter/7.  Ctrl+PadEnter/8.  Shift+PadEnter/');
  4574.    if k=='' then
  4575.       return
  4576.    endif
  4577.    parse value k with k '.  ' keyname
  4578.    select = listbox('Select an action for the' keyname 'key:',
  4579.  '/1.  Add a new line after cursor/2.  Move to beginning of next line/3.  Like (2), but add a line if at end of file/4.  Add a line if in insert mode, else move to next line/5.  Like (4), but always add a line if on last line/6.  Split line at cursor/')
  4580.    if select=='' then
  4581.       return
  4582.    endif
  4583.    parse value select with select '.'
  4584.    if k=1 then     enterkey=      select
  4585.    elseif k=2 then a_enterkey=    select
  4586.    elseif k=3 then c_enterkey=    select
  4587.    elseif k=4 then s_enterkey=    select
  4588.    elseif k=5 then padenterkey=   select
  4589.    elseif k=6 then a_padenterkey= select
  4590.    elseif k=7 then c_padenterkey= select
  4591.    else            s_padenterkey= select
  4592.    endif
  4593.   compile if WANT_STREAM_MODE = 'SWITCH'
  4594.    if stream_mode then
  4595.       call winmessagebox('Stream mode active','Key change will not be visible until stream mode is turned off.', 16432) -- MB_OK + MB_INFORMATION + MB_MOVEABLE
  4596.    endif
  4597.   compile endif
  4598.  compile endif  -- LAMPATH
  4599. compile endif  -- WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21
  4600.  
  4601. defc helpmenu   -- send EPM icon window a help message.
  4602.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4603.                       5133,      -- EPM_HelpMgrPanel
  4604.                       arg(1),    -- mp1 = 0=Help for help, 1=index; 2=TOC; 256... =panel #
  4605.                       0)         -- mp2 = NULL
  4606.  
  4607.  
  4608. defc ibmmsg
  4609.    ever = EVERSION
  4610.    if \0 = rightstr(EVERSION,1) then
  4611.       ever=leftstr(EVERSION,length(eversion)-1)
  4612.    endif
  4613. compile if EPATH = 'LAMPATH'
  4614.    call WinMessageBox("LaMail", LAMAIL_VER__MSG "2.3"\13EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384)
  4615. ;;compile elseif EVERSION >= 5.51 & NLS_LANGUAGE = 'ENGLISH'
  4616. compile elseif EVERSION >= 5.51 & EDITOR__MSG = "EPM Editor - Product Information"
  4617.    -- verstr = EDITOR_VER__MSG ver(0)\0
  4618.    verstr = EDITOR_VER__MSG ver(0)\0MACROS_VER__MSG ever
  4619.    call windowmessage(0, getpminfo(APP_HANDLE),
  4620.                       5146,               -- EPM_POPABBOUTBOX
  4621.                       0,
  4622.                       put_in_buffer(verstr) )
  4623. compile else
  4624.    call WinMessageBox(EDITOR__MSG, EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384)
  4625. compile endif
  4626.  
  4627.  
  4628. defproc LoadVersionString(var buff)
  4629. compile if EPM32
  4630.    hmodule = \0\0\0\0
  4631. compile else
  4632.    hmodule = \0\0
  4633. compile endif
  4634.  
  4635.    if arg(2) then
  4636.       modname = arg(2)\0
  4637. compile if EPM32
  4638.       rc = dynalink32('DOSCALLS',
  4639.                       '#318',  -- Dos32LoadModule
  4640.                       atol(0) ||  -- Buffer address
  4641.                       atol(0) ||  -- Buffer length
  4642.                       address(modname) ||
  4643.                       address(hmodule))
  4644. compile else
  4645.       rc=  dynalink('DOSCALLS',            -- dynamic link library name
  4646.                '#44',                      -- DosLoadModule
  4647.                atol(0)                ||   -- Buffer address
  4648.                atoi(0)                ||   -- Buffer length
  4649.                address(modname)       ||   -- Module we're loading
  4650.                address(hmodule) )          -- Address of handle to be returned
  4651. compile endif
  4652.    endif
  4653.  
  4654.    buff = copies(\0, 255)
  4655. compile if EPM32
  4656.    res= dynalink32('PMWIN',
  4657.                    '#781',  -- Win32LoadString
  4658.                    gethwndc(EPMINFO_HAB)  ||
  4659.                    hmodule                ||  -- NULLHANDLE
  4660.                    atol(65535)            ||  -- IDD_BUILDDATE
  4661.                    atol(length(buff))     ||
  4662.                    address(buff), 2 )
  4663. compile else
  4664.    res= dynalink( 'PMWIN',
  4665.                   'WINLOADSTRING',
  4666.                   gethwnd(EPMINFO_HAB)   ||
  4667.                   hmodule                ||  -- NULLHANDLE
  4668.                   atoi(65535)            ||  -- IDD_BUILDDATE
  4669.                   atoi(length(buff))     ||
  4670.                   address(buff) )
  4671. compile endif
  4672.    buff = leftstr(buff, res)
  4673.  
  4674.    if arg(2) then
  4675. compile if EPM32
  4676.       call dynalink32('DOSCALLS',
  4677.                       '#322',  -- Dos32FreeModule
  4678.                       hmodule)
  4679. compile else
  4680.       call dynalink('DOSCALLS',         -- dynamic link library name
  4681.                     '#46',                   -- DosFreeModule
  4682.                     hmodule)
  4683. compile endif
  4684.    endif
  4685.  
  4686.  
  4687. defc versioncheck =
  4688. ;                   Get EPM.EXE build date
  4689.    LoadVersionString(buff)
  4690.  
  4691. ;                   Get ETKEnnn.DLL build date
  4692.    LoadVersionString(buffe, E_DLL)
  4693.  
  4694. ;                   Get ETKRnnn.DLL build date
  4695.    LoadVersionString(buffr, ERES2_DLL)
  4696.  
  4697. compile if EVERSION >= 6.03
  4698. ;                   Get ETKRnnn.DLL build date
  4699.    LoadVersionString(buffc, ERES_DLL)
  4700. compile endif
  4701.  
  4702. compile if EVERSION >= 6.03
  4703.    call WinMessageBox("EPM Build", EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG EVERSION\13\13'EPM.EXE' buff\13E_DLL'.DLL' buffe\13ERES2_DLL'.DLL' buffr\13ERES_DLL'.DLL' buffc\13\13COPYRIGHT__MSG, 16384)
  4704. compile else
  4705.    call WinMessageBox("EPM Build", EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG EVERSION\13\13'EPM.EXE' buff\13E_DLL'.DLL' buffe\13ERES2_DLL'.DLL' buffr\13\13COPYRIGHT__MSG, 16384)
  4706. compile endif
  4707.  
  4708. compile if EVERSION < 5.50  -- Not used in later versions; don't bother including
  4709.                             -- unless someone screams.  (If anyone needs it, we must
  4710.                             -- add a 32-bit version.)
  4711. defproc screenxysize( cxcy )     -- syntax :   retvalue =screenxysize( 'Y' or 'X' )
  4712.    return dynalink( 'PMWIN',
  4713.                     'WINQUERYSYSVALUE',
  4714.                      atoi(0) || atoi(1)      ||
  4715.                      atoi(20 + (upcase(cxcy)='Y')))
  4716. compile endif
  4717.  
  4718.  
  4719. defproc put_in_buffer(string)
  4720.    if string='' then                   -- Was a string given?
  4721.       return 0                         -- If not, return a null pointer.
  4722.    endif
  4723. compile if POWERPC  -- Temp. kludge because they don't support tiled memory
  4724.   if arg(2)='' then
  4725.      strbuffer = atol(dynalink32(E_DLL,
  4726.                                   'mymalloc',
  4727.                                   atol(length(string)+1), 2))
  4728.      r = -270 * (strbuffer = 0)
  4729.   else
  4730. compile endif
  4731. compile if EPM32
  4732.    if arg(2)='' then share=83;  -- PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE
  4733.    else share=arg(2); endif
  4734.    strbuffer = "????"                  -- Initialize string pointer.
  4735.    r =  dynalink32('DOSCALLS',          -- Dynamic link library name
  4736.             '#299',                    -- Dos32AllocMem
  4737.             address(strbuffer)     ||
  4738.             atol(length(string)+1) ||  -- Number of bytes requested
  4739.             atol(share))               -- Share information
  4740.  compile if POWERPC  -- Temp. kludge because they don't support tiled memory
  4741.   endif
  4742.  compile endif
  4743. compile else
  4744.    if arg(2)='' then share=0; else share=arg(2); endif
  4745.    strbuffer = "??"                    -- Initialize string pointer.
  4746.    r =  dynalink('DOSCALLS',           -- Dynamic link library name
  4747.             '#34',                     -- DosAllocSeg
  4748.             atoi(length(string)+1) ||  -- Number of bytes requested
  4749.             address(strbuffer)     ||
  4750.             atoi(share))               -- Share information
  4751. compile endif  -- EPM32
  4752.  
  4753.    if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif
  4754. compile if 0 -- POWERPC
  4755.    -- Leave strbuffer as a long
  4756.    strbuffer = ltoa(strbuffer,10)
  4757. compile elseif EPM32
  4758.    strbuffer = itoa(substr(strbuffer,3,2),10)
  4759. compile else
  4760.    strbuffer = itoa(strbuffer,10)
  4761. compile endif  -- EPM32
  4762. compile if 0 -- POWERPC
  4763.    poke32 strbuffer, 0, string    -- Copy string to new allocated buf
  4764.    poke32 strbuffer, length(string), \0  -- Add a null at the end
  4765.    return strbuffer    -- Return a long pointer to buffer
  4766. compile else
  4767.    poke strbuffer,0,string    -- Copy string to new allocated buf
  4768.    poke strbuffer,length(string),\0  -- Add a null at the end
  4769.    return mpfrom2short(strbuffer,0)    -- Return a long pointer to buffer
  4770. compile endif
  4771.  
  4772.  
  4773. compile if EVERSION > 5.20
  4774. defc loadaccel
  4775.    universal activeaccel
  4776.    activeaccel='defaccel'
  4777.  compile if INCLUDE_MENU_SUPPORT & INCLUDE_STD_MENUS
  4778.                        -- Help key
  4779. ;; buildacceltable activeaccel, 'helpmenu 4000', AF_VIRTUALKEY, VK_F1, 1000
  4780.    buildacceltable activeaccel, 'dokey s+F1', AF_VIRTUALKEY+AF_SHIFT, VK_F1, 1000
  4781.  
  4782.    call build_menu_accelerators(activeaccel)  -- Moved to menu-specific file
  4783.  compile endif -- INCLUDE_MENU_SUPPORT & INCLUDE_STD_MENUS
  4784.  
  4785.    buildacceltable activeaccel, 'Alt_enter 1', AF_VIRTUALKEY+AF_ALT,  VK_NEWLINE, 1080  -- Alt+Enter
  4786.    buildacceltable activeaccel, 'Alt_enter 2', AF_VIRTUALKEY+AF_ALT,    VK_ENTER, 1081  -- Alt+PadEnter
  4787.    buildacceltable activeaccel, 'Alt_enter 3', AF_VIRTUALKEY+AF_SHIFT,VK_NEWLINE, 1082  -- Shift+Enter
  4788.    buildacceltable activeaccel, 'Alt_enter 4', AF_VIRTUALKEY+AF_SHIFT,  VK_ENTER, 1083  -- Shift+PadEnter
  4789.  
  4790.  compile if defined(BLOCK_ALT_KEY)
  4791.    buildacceltable activeaccel, 'beep 2000 50', AF_VIRTUALKEY+AF_LONEKEY, VK_ALT, 1020
  4792.    buildacceltable activeaccel, 'beep 2000 50', AF_VIRTUALKEY+AF_LONEKEY, VK_ALTGRAF, 1021
  4793.  compile endif
  4794.  
  4795.    activateacceltable activeaccel
  4796.  
  4797.  compile if defined(BLOCK_ALT_KEY)
  4798. defc beep = a=arg(1); do while a<>''; parse value a with pitch duration a; call beep(pitch, duration); enddo
  4799.  compile endif
  4800.  
  4801. defc alt_enter =
  4802.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  -- define each key separately
  4803.    universal a_enterkey, a_padenterkey, s_enterkey, s_padenterkey
  4804.    call enter_common(substr(a_enterkey||a_padenterkey||s_enterkey||s_padenterkey,arg(1),1))
  4805.  compile else
  4806.    executekey enter
  4807.  compile endif
  4808.  
  4809. defc dokey
  4810.    executekey resolve_key(arg(1))
  4811.  
  4812. defc keyin
  4813.    keyin arg(1)
  4814.  
  4815. compile endif -- EVERSION >= 5.20  (Started above loadaccel command)  ---------
  4816.  
  4817. defc rename
  4818.    name = .filename
  4819.    if name=UNNAMED_FILE_NAME then name=''; endif
  4820. compile if EVERSION >= 5.21
  4821.    parse value entrybox(RENAME__MSG, '', name, 0, 240,
  4822. ;         atoi(1) || atoi(0) || gethwndc(APP_HANDLE) ||
  4823.           atoi(1) || atoi(0) || atol(0) ||
  4824.           RENAME_PROMPT__MSG '<' directory() '>') with button 2 name \0
  4825.    if button=\1 & name<>'' then 'name' name; endif
  4826. compile else
  4827.    name = entrybox(RENAME__MSG, '', name)
  4828.    if name<>'' then 'name' name; endif
  4829. compile endif
  4830.  
  4831. defc maybe_reflow_ALL
  4832.    do i = 1 to .last
  4833.       if textline(i)<>'' then  -- Only ask if there's text in the file.
  4834.          if askyesno(REFLOW_ALL__MSG,1) = YES_CHAR then
  4835.             'reflow_all'
  4836.          endif
  4837.          leave
  4838.       endif
  4839.    enddo
  4840.  
  4841. compile if EVERSION >= 5.51
  4842. defc edit_list =
  4843.    getfileid startfid
  4844.    firstloaded = startfid
  4845.    parse arg list_sel list_ofs .
  4846.    orig_ofs = list_ofs
  4847.    do forever
  4848.       list_ptr = peek(list_sel, list_ofs, 4)
  4849.       if list_ptr == \0\0\0\0 then leave; endif
  4850.       fn = peekz(list_ptr)
  4851.       if pos(' ', fn) then
  4852.          fn = '"'fn'"'
  4853.       endif
  4854.       'e' fn
  4855.       list_ofs = list_ofs + 4
  4856.       if startfid = firstloaded then
  4857.          getfileid firstloaded
  4858.       endif
  4859.    enddo
  4860.  compile if 1  -- Now, the macros free the buffer.
  4861.    call buffer(FREEBUF, list_sel)
  4862.  compile else
  4863.    call windowmessage(1,  getpminfo(EPMINFO_OWNERCLIENT),   -- Send message to owner client
  4864.                       5486,               -- Tell it to free the buffer.
  4865.                       mpfrom2short(list_sel, orig_ofs),
  4866.                       0)
  4867.  compile endif
  4868.    activatefile firstloaded
  4869. compile endif
  4870.  
  4871. compile if EVERSION >= 5.21
  4872. ; Called with a string to set the statusline text to that string; with no argument
  4873. ; to just set the statusline color.
  4874. defc setstatusline
  4875.    universal vSTATUSCOLOR, current_status_template
  4876.    if arg(1) then
  4877.       current_status_template = arg(1)
  4878. compile if EVERSION >= 5.53
  4879.          template=atoi(length(current_status_template)) || current_status_template
  4880. compile else
  4881.          template=chr(length(current_status_template)) || current_status_template
  4882. compile endif
  4883.       template_ptr=put_in_buffer(template)
  4884.    else
  4885.       template_ptr=0
  4886.    endif
  4887.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  4888.                       5431,      -- EPM_FRAME_STATUSLINE
  4889.                       template_ptr,
  4890.                       vSTATUSCOLOR)
  4891.  
  4892. ; Called with a string to set the messageline text to that string; with no argument
  4893. ; to just set the messageline color.
  4894. defc setmessageline
  4895.    universal vMESSAGECOLOR
  4896.    if arg(1) then
  4897. compile if EVERSION >= 5.53
  4898.       template=atoi(length(arg(1))) || arg(1)
  4899. compile else
  4900.       template=chr(length(arg(1))) || arg(1)
  4901. compile endif
  4902.       template_ptr=put_in_buffer(template)
  4903.    else
  4904.       template_ptr=0
  4905.    endif
  4906.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  4907.                       5432,      -- EPM_FRAME_MESSAGELINE
  4908.                       template_ptr,
  4909.                       vMESSAGECOLOR)
  4910. compile endif
  4911.  
  4912. defc new
  4913.    getfileid startfid
  4914.    'xcom e /n'
  4915.    if rc<>-282 then return; endif  -- sayerror 'New file'
  4916.    getfileid newfid
  4917.    activatefile startfid
  4918.    temp = startfid  -- temp fix for some bug
  4919.    'quit'
  4920.    getfileid curfid
  4921.    activatefile newfid
  4922.    if curfid=startfid then  -- Wasn't quit; user must have said Cancel to Quit dlg
  4923.       'xcom quit'
  4924.    endif
  4925.  
  4926. compile if SUPPORT_USERS_GUIDE | SUPPORT_TECHREF
  4927. defc viewword  -- arg(1) is name of .inf file
  4928.    if find_token(startcol, endcol) then
  4929.       'view' arg(1) substr(textline(.line), startcol, (endcol-startcol)+1)
  4930.    endif
  4931. compile endif
  4932.  
  4933. defc cascade_menu
  4934.    parse arg menuid defmenuid .
  4935. ; if dos_version()>=2000 then
  4936.    menuitem = copies(\0, 16)  -- 2 bytes ea. pos'n, style, attribute, identity; 4 bytes submenu hwnd, long item
  4937.    if not windowmessage(1,
  4938.                         getpminfo(EPMINFO_EDITMENUHWND),
  4939.                         386,                  -- x182, MM_QueryItem
  4940.                         menuid + 65536,
  4941.                         ltoa(offset(menuitem) || selector(menuitem), 10) )
  4942.    then return; endif
  4943.    hwnd = substr(menuitem, 9, 4)
  4944.  
  4945. compile if EPM32
  4946.    call dynalink32('PMWIN',
  4947.                    '#874',     -- Win32SetWindowBits
  4948.                     hwnd          ||
  4949.                     atol(-2)      ||  -- QWL_STYLE
  4950.                     atol(64)      ||  -- MS_CONDITIONALCASCADE
  4951.                     atol(64) )        -- MS_CONDITIONALCASCADE
  4952. compile else
  4953.    call dynalink('PMWIN',
  4954.                  '#278',     -- WinSetWindowBits
  4955.                   substr(hwnd,3) || leftstr(hwnd,2) ||
  4956.                   atoi(-2)      ||  -- QWL_STYLE
  4957.                   atol_swap(64) ||  -- MS_CONDITIONALCASCADE
  4958.                   atol_swap(64) )   -- MS_CONDITIONALCASCADE
  4959. compile endif
  4960.    if defmenuid<>'' then  -- Default menu item
  4961.       call windowmessage(1,
  4962.                          ltoa(hwnd,10),
  4963.                          1074,                  -- x432, MM_SETDEFAULTITEMID
  4964.                          defmenuid, 0)  -- Make arg(2) the default menu item
  4965.    endif
  4966. ; endif
  4967.  
  4968. compile if 0
  4969. defc QueryHLP = sayerror '"'QueryCurrentHLPFiles()'"'
  4970. defproc QueryCurrentHLPFiles()
  4971.    universal CurrentHLPFiles;
  4972.    return CurrentHLPFiles;
  4973.  
  4974. defc setHLP = sayerror '"'SetCurrentHLPFiles(arg(1))'"'
  4975. defproc SetCurrentHLPFiles(newlist)
  4976.    universal CurrentHLPFiles;
  4977.    hwndHelpInst = windowmessage(1,  getpminfo(APP_HANDLE),
  4978.  compile if EPM32
  4979.                       5429,      -- EPM_Edit_Query_Help_Instance
  4980.  compile else
  4981.                       5139,      -- EPM_QueryHelpInstance
  4982.  compile endif -- EPM32
  4983.                       0,
  4984.                       0)
  4985.    if hwndHelpInst==0 then
  4986.       -- there isn't a help instance deal with.
  4987.       return "No Help Instance";
  4988.    endif
  4989.  
  4990.    newlist2 = newlist || chr(0);
  4991.    retval = windowmessage(1,  hwndHelpInst,
  4992.                        557,    -- HM_SET_HELP_LIBRARY_NAME
  4993.                        ltoa(offset(newlist2) || selector(newlist2), 10),
  4994.                        0)
  4995.    if retval==0 then
  4996.       -- it worked, now remember what you told it.
  4997.       CurrentHLPFiles = newlist;
  4998.    else
  4999.       -- failed for some reason, anyway, we had better revert to
  5000.       --   the previous version of the HLP list.
  5001.       if CurrentHLPFiles=="" then
  5002.          CurrentHLPFiles = " ";
  5003.       endif
  5004.       newlist2 = CurrentHLPFiles || chr(0);
  5005.       retval2 = windowmessage(1,  hwndHelpInst,
  5006.                           557,    -- HM_SET_HELP_LIBRARY_NAME
  5007.                           ltoa(offset(newlist2) || selector(newlist2), 10),
  5008.                           0)
  5009.       if retval2==0 then
  5010.          -- whew, we were able to revert to the old list
  5011.          return retval;
  5012.       else
  5013.          return "two errors" retval retval2;
  5014.       endif
  5015.    endif
  5016.  
  5017. compile endif
  5018.  
  5019. compile if KEEP_CURSOR_ON_SCREEN & EVERSION >= 5.60
  5020. -- This should move the cursor at the end of every scroll bar action.  The
  5021. -- position to which it is moved should correspond to the location of the
  5022. -- cursor (relative to the window) at the time when the scroll began.
  5023.  
  5024. defc processendscroll
  5025.    universal beginscroll_x, beginscroll_y;
  5026.    .cursorx = beginscroll_x;
  5027.    .cursory = beginscroll_y;
  5028.    if not .line & .last then .lineg=1; endif
  5029.  
  5030. defc processbeginscroll
  5031.    universal beginscroll_x, beginscroll_y;
  5032.    beginscroll_x = .cursorx;
  5033.    beginscroll_y = .cursory;
  5034. compile endif  -- KEEP_CURSOR_ON_SCREEN & EVERSION >= 5.60
  5035.  
  5036. compile if EVERSION >= 5.60
  5037. defc setpresparam
  5038.    universal statfont, msgfont
  5039.    universal vSTATUSCOLOR, vMESSAGECOLOR, vDESKTOPColor
  5040.    parse value arg(1) with whichctrl " hwnd="hwnd " x="x "y="y rest
  5041.    if (whichctrl=="STATFONTSIZENAME") or (whichctrl=="MSGFONTSIZENAME") then
  5042.       parse value rest with "string="psize"."facename"."attr
  5043.       -- psize is pointsize, facename is facename, attr is "Bold" etc
  5044.       "setstatface" hwnd facename
  5045.       "setstatptsize" hwnd psize
  5046.       if leftstr(whichctrl,1)='S' then  -- "STATFONTSIZENAME"
  5047.          statfont = substr(rest,8)
  5048.       else                              -- "MSGFONTSIZENAME"
  5049.          msgfont = substr(rest,8)
  5050.          sayerror MESSAGELINE_FONT__MSG
  5051.       endif
  5052.    elseif (whichctrl=="STATFGCOLOR") or (whichctrl=="MSGFGCOLOR") then
  5053.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5054.       call windowmessage(0,  hwnd,
  5055.                          4099,      -- STATWNDM_SETCOLOR
  5056.                          clrattr,
  5057.                          oldbgattr)
  5058.       if leftstr(whichctrl,1)='M' then
  5059.          sayerror MESSAGELINE_FGCOLOR__MSG
  5060.          vMESSAGECOLOR = clrattr + 16 * oldbgattr
  5061.       else
  5062.          vSTATUSCOLOR = clrattr  + 16 * oldbgattr
  5063.       endif
  5064.    elseif (whichctrl=="STATBGCOLOR") or (whichctrl=="MSGBGCOLOR") then
  5065.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5066.       call windowmessage(0,  hwnd,
  5067.                          4099,      -- STATWNDM_SETCOLOR
  5068.                          oldfgattr,
  5069.                          clrattr)
  5070.       if leftstr(whichctrl,1)='M' then
  5071.          sayerror MESSAGELINE_BGCOLOR__MSG
  5072.          vMESSAGECOLOR = clrattr * 16 + oldfgattr
  5073.       else
  5074.          vSTATUSCOLOR = clrattr  * 16 + oldfgattr
  5075.       endif
  5076.    elseif (whichctrl=="EDITBGCOLOR") then
  5077.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5078.       map_point 5, x, y, off, comment;  -- map screen to line
  5079.       if x<1 | x>.last then
  5080.          vDESKTOPColor = clrattr
  5081.          call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 5497, clrattr, 0)
  5082.       else
  5083.          .textcolor = (.textcolor // 16) + 16 * clrattr;
  5084.       endif
  5085.    elseif (whichctrl=="EDITFGCOLOR") then
  5086.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5087.       .textcolor = .textcolor - (.textcolor // 16) + clrattr;
  5088.    elseif whichctrl=="EDITFONTSIZENAME" then
  5089.       parse value rest with "string="psize"."facename"."attr
  5090.       -- psize is pointsize, facename is facename, attr is "Bold" etc
  5091.       fontsel = 0
  5092.       do while attr<>''
  5093.          parse value attr with thisattr '.' attr
  5094.          if     thisattr='Italic'     then fontsel = fontsel + 1
  5095.          elseif thisattr='Underscore' then fontsel = fontsel + 2
  5096.          elseif thisattr='Outline'    then fontsel = fontsel + 8
  5097.          elseif thisattr='Strikeout'  then fontsel = fontsel + 16
  5098.          elseif thisattr='Bold'       then fontsel = fontsel + 32
  5099.          endif
  5100.       enddo
  5101.       .font = registerfont(facename ,psize, fontsel)
  5102.    else
  5103.       sayerror UNKNOWN_PRESPARAM__MSG  whichctrl
  5104.       return;
  5105.    endif
  5106. ;   sayerror "set presparm with" hwnd " as the window" arg(1);
  5107.  
  5108. defc setstatface
  5109.    parse value arg(1) with hwnd face
  5110.    return windowmessage(0,  hwnd /*getpminfo(EPMINFO_EDITFRAME)*/,   -- Post message to edit client
  5111.                         4104,        -- STATWNDM_PREFFONTFACE
  5112.                         put_in_buffer(face),
  5113.                         1);  -- COMMAND_FREESEL
  5114.  
  5115. defc setstatptsize
  5116.    parse value arg(1) with hwnd ptsize
  5117.    if leftstr(ptsize, 1) = 'D' then  -- Decipoints
  5118.       parse value ptsize with 'DD' ptsize 'HH'
  5119.       parse value ptsize with ptsize 'WW'
  5120.       ptsize = ptsize % 10   -- convert decipoints to points
  5121.    endif
  5122.    return windowmessage(0,  hwnd /*getpminfo(EPMINFO_EDITFRAME)*/,   -- Post message to edit client
  5123.                         4106,        -- STATWNDM_PREFFONTPTSIZE
  5124.                         ptsize,
  5125.                         0);
  5126.  
  5127. compile endif  -- EVERSION >= 5.60
  5128.  
  5129. compile if EPM32
  5130. defproc Thunk(pointer)
  5131.   return atol_swap(dynalink32(E_DLL,
  5132.                               'FlatToSel',
  5133.                               pointer, 2) )
  5134. compile endif -- EPM32
  5135.  
  5136. compile if not EXTRA_EX
  5137. include 'EPM_EA.E'
  5138. compile endif
  5139.  
  5140. defc echoback
  5141.    parse arg postorsend hwnd messageid mp1 mp2 .
  5142.    call windowmessage(postorsend,
  5143.                       hwnd,
  5144.                       messageid,
  5145.                       mp1,
  5146.                       mp2)
  5147.  
  5148. compile if WANT_TOOLBAR
  5149. ;  load_actions
  5150. ;     This defc is called by the etke*.dll to generate the list of actions
  5151. ;     for UCMENUS in the hidden file called actlist.
  5152. ;     If called with a pointer parameter a buffer is create in which
  5153. ;     the list of actions are placed. If called without any parameter
  5154. ;     the actlist file is generated.
  5155. ;     John Ponzo 8/93
  5156. ;     Optimized by LAM
  5157.  
  5158. defc load_actions
  5159.    universal ActionsList_FileID
  5160.  
  5161. ;Keep track of the active file
  5162.    getfileid ActiveFileID
  5163.  
  5164. ;See if the actlist file is already loaded, if not load it
  5165. ;; getfileid ActionsList_FileID, 'actlist'
  5166.  
  5167.    if ActionsList_FileID <> '' then  -- Make sure it's still loaded.
  5168.       rc = 0
  5169.       display -2
  5170.       activatefile ActionsList_FileID
  5171.       display 2
  5172.       if rc=-260 then ActionsList_FileID = ''; endif
  5173.    endif
  5174.  
  5175.    if ActionsList_FileID == '' then  -- Must create
  5176.       'xcom e /c actlist'
  5177.       if rc<>-282 then  -- sayerror('New file')
  5178.          sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  5179.          return
  5180.       endif
  5181.       getfileid ActionsList_FileID
  5182.       .visible = 0
  5183.  
  5184. ;load the actions.lst file which contain the names of all the EX modules
  5185. ;that have UCMENU actions defined.
  5186.       getfileid ActionsEXModuleList_FileID, 'actions.lst'
  5187.  
  5188.       if ActionsEXModuleList_FileID == '' then
  5189.          findfile destfilename, 'actions.lst', '','D'
  5190.          if rc=-2 then  -- "File not found"
  5191.             'xcom e /c actions.lst'
  5192.             deleteline 1
  5193.             .modify = 0
  5194.          else
  5195.             'e' destfilename
  5196.             if rc then
  5197.                sayerror ERROR__MSG rc '"'destfilename'"' sayerrortext(rc)
  5198.                return
  5199.             endif
  5200.          endif
  5201.          getfileid ActionsEXModuleList_FileID
  5202. ;;       ActionsEXModuleList_FileID.visible = 0
  5203.          quit_list = 1
  5204.       else
  5205.          quit_list = 0
  5206.       endif
  5207. ;load all the EX Modules in actlist.lst, and call EX modules
  5208. ;actionlist defc.
  5209.       for i = 1 to ActionsEXModuleList_FileID.last
  5210.          getline  exmodule, i, ActionsEXModuleList_FileID
  5211.          not_linked = linked(exmodule) < 0
  5212.          if not_linked then
  5213.             link exmodule
  5214.             if rc<0 then
  5215.                sayerror 'Load_Actions:  'sayerrortext(rc) '-' exmodule
  5216.                not_linked = 0  -- Don't try to unlink it.
  5217.             endif
  5218.          endif
  5219.          exmodule'_actionlist'
  5220.          if not_linked then
  5221.             'unlink' exmodule
  5222.          endif
  5223.       endfor
  5224.       if quit_list then
  5225.          activatefile ActionsEXModuleList_FileID
  5226.          'quit'
  5227.       endif
  5228.    endif  -- ActionsList_FileID == ''
  5229.  
  5230. ;if called with a parameter send EFRAME_ACTIONSLIST message to the frame
  5231. ;of the edit window. mp1 is a buffer containing all of the actions loaded
  5232. ;in the hidden file actlist.
  5233.    if arg(1)  then
  5234.       activatefile ActionsList_FileID
  5235.       buflen = filesize() + .last + 1
  5236.       bufhandle = buffer(CREATEBUF, '', buflen, 1)
  5237.       if not bufhandle then sayerror 'CREATEBUF' ERROR_NUMBER__MSG RC; return; endif
  5238.       call buffer(PUTBUF, bufhandle, 1, ActionsList_FileID.last, NOHEADER+FINALNULL+APPENDCR)
  5239.       if word(arg(1),1) <> 'ITEMCHANGED' then
  5240.          windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5913, bufhandle, arg(1))
  5241.       else
  5242.          windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5918, bufhandle, subword(arg(1),2))
  5243.       endif
  5244.    endif
  5245.    activatefile ActiveFileID
  5246.  
  5247. ;  ExecuteAction
  5248. ;     This defc is called to resolve UCMENU actions.
  5249. ;     It is called with the first parameter being the action name,
  5250. ;     and the second parameter being an action sub-op.
  5251. ;     If the action (Which is a Defc) is not defined the actions list
  5252. ;     is generated in order to try resolving the defc.
  5253.  
  5254. defc ExecuteAction
  5255.    universal ActionsList_FileID
  5256.    parse arg DefcModule DefcName DefcParameter
  5257. ;sayerror 'executeaction: "'arg(1)'"'
  5258.  
  5259.    if DefcName='*' then
  5260.       DefcParameter
  5261.    else
  5262.       if defcmodule<>'*' then
  5263.          if linked(defcmodule) < 0 then
  5264.             link defcmodule
  5265.          endif
  5266.       endif
  5267.       if isadefc(DefcName) then
  5268. ;sayerror 'executeaction: executing cmd "'DefcName'" with parm "'DefcParameter'"'
  5269.          DefcName DefcParameter
  5270.       else
  5271.         sayerror UNKNOWN_ACTION__MSG DefcName
  5272.       endif
  5273.    endif
  5274.  
  5275. compile if 0 -- No longer used
  5276. defc load_toolbar
  5277.    call list_toolbars(LOAD_TOOLBAR__MSG, SELECT_TOOLBAR__MSG, 7000, 5916)
  5278.  
  5279. defproc list_toolbars(list_title, list_prompt, help_panel, msgid)
  5280.    universal app_hini, toolbar_loaded
  5281.  compile if EPM32
  5282. ;  l = dynalink32('PMSHAPI',
  5283. ;                 '#115',               -- PRF32QUERYPROFILESTRING
  5284. ;                 atol(app_hini)    ||  -- HINI_PROFILE
  5285. ;                 address(App)      ||  -- pointer to application name
  5286. ;                 atol(0)           ||  -- Key name is NULL; returns all keys
  5287. ;                 atol(0)           ||  -- Default return string is NULL
  5288. ;                 address(inidata)  ||  -- pointer to returned string buffer
  5289. ;                 atol(1600), 2)        -- max length of returned string
  5290.    inidata = queryprofile(app_hini, INI_UCMENU_APP, '')
  5291.    l = length(inidata)
  5292.  compile else
  5293.    App = INI_UCMENU_APP\0
  5294.    inidata = copies(' ',1600)
  5295.    l =  dynalink( 'PMSHAPI',
  5296.                   'PRFQUERYPROFILESTRING',
  5297.                   atol_swap(app_hini) ||  -- HINI_PROFILE
  5298.                   address(App)        ||  -- pointer to application name
  5299.                   atol(0)             ||  -- Key name is NULL; returns all keys
  5300.                   atol(0)             ||  -- Default return string is NULL
  5301.                   address(inidata)    ||  -- pointer to returned string buffer
  5302.                   atol_swap(1600))        -- max length of returned string
  5303.    inidata=leftstr(inidata,l)
  5304.  compile endif
  5305.  
  5306.    if not l then sayerror NO_TOOLBARS__MSG; return; endif
  5307.    getfileid startfid
  5308.    'xcom e /c /q tempfile'
  5309.    if rc<>-282 then  -- sayerror('New file')
  5310.       sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  5311.       return
  5312.    endif
  5313.    .autosave = 0
  5314.    browse_mode = browse()     -- query current state
  5315.    if browse_mode then call browse(0); endif
  5316.    do while inidata<>''
  5317.       parse value inidata with menuname \0 inidata
  5318.       insertline menuname, .last+1
  5319.    enddo
  5320.    if browse_mode then call browse(1); endif  -- restore browse state
  5321.    if listbox_buffer_from_file(startfid, bufhndl, noflines, usedsize) then return; endif
  5322. ;compile if POWERPC
  5323. ;  parse value listbox(list_title, \0 || atol(usedsize) || atol(bufhndl+32),
  5324. ;compile else
  5325.    parse value listbox(list_title, \0 || atol(usedsize) || atoi(32) || atoi(bufhndl),
  5326. ;compile endif
  5327.                        '/'OK__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0,
  5328.                        gethwndc(APP_HANDLE) || atoi(1) || atoi(1) || atoi(help_panel) ||
  5329.                        list_prompt) with button 2 menuname \0
  5330.    call buffer(FREEBUF, bufhndl)
  5331.    if button<>\1 then return; endif
  5332.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), msgid, app_hini, put_in_buffer(menuname))
  5333.    if msgid = 5916 then
  5334.       toolbar_loaded = menuname
  5335.    endif
  5336.  
  5337. defc delete_toolbar
  5338.    call list_toolbars(DELETE_TOOLBAR__MSG, SELECT_TOOLBAR__MSG, 7001, 5919)
  5339. compile endif
  5340.  
  5341. defc save_toolbar
  5342.    universal app_hini, appname
  5343.    universal toolbar_loaded
  5344.    tb = toolbar_loaded
  5345.    if tb=\1 then
  5346.       tb=''
  5347.    endif
  5348.    parse value entrybox(SAVEBAR__MSG,'/'SAVE__MSG'/'Cancel__MSG'/'Help__MSG'/',tb,'',200,
  5349.           atoi(1) || atoi(7010) || gethwndc(APP_HANDLE) ||
  5350.           SAVEBAR_PROMPT__MSG) with button 2 menuname \0
  5351.    if button <> \1 then return; endif
  5352.    if menuname='' then
  5353.       sayerror NOTHING_ENTERED__MSG
  5354.       return
  5355. ;     menuname = 'Default'
  5356. ;     call setprofile(app_hini, appname, INI_DEF_TOOLBAR, '')
  5357.    endif
  5358.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5915, app_hini, put_in_buffer(menuname))
  5359.    toolbar_loaded = menuname
  5360.  
  5361. defc loaddefaulttoolbar
  5362.    universal activeucmenu, toolbar_loaded
  5363.    if activeucmenu = 'Toolbar' then  -- Already used, delete it to be safe.
  5364.       deletemenu activeucmenu
  5365.    else
  5366.       activeucmenu = 'Toolbar'
  5367.    endif
  5368.  compile if defined(MY_DEFAULT_TOOLBAR_FILE)  -- Primarily for NLS support...
  5369.    include MY_DEFAULT_TOOLBAR_FILE  -- Should contain only lines like the following:
  5370.  compile elseif WANT_TINY_ICONS
  5371. ;                             # Button text # Button bitmap # command # parameters # .ex file
  5372.    buildsubmenu activeucmenu,  1, "#Add File#1131#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5373.    buildsubmenu activeucmenu,  2, "#Save#1130#a_save##sampactn", '', 0, 0
  5374.    buildsubmenu activeucmenu,  3, "#Print#1133#a_print##sampactn", '', 0, 0  -- print.bmp
  5375.    buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5376.    buildsubmenu activeucmenu,  5, "#MonoFont#1151#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5377.    buildsubmenu activeucmenu,  6, "#Style#1147#apply_style##stylebut", '', 0, 0  -- style.bmp
  5378.    buildsubmenu activeucmenu,  7, "#UnStyle#1148#remove_style##stylebut", '', 0, 0  -- style.bmp
  5379.    buildsubmenu activeucmenu,  8, "#Attribs#1152#fonts_attribs##fonts", '', 0, 0  -- attribs.bmp
  5380.    buildmenuitem activeucmenu,  8, 80, "#Bold#1124#fonts_bold##fonts", '', 0, 0  -- bold.bmp
  5381.    buildmenuitem activeucmenu,  8, 81, "#Italic#1123#fonts_italic##fonts", '', 0, 0  -- italic.bmp
  5382.    buildmenuitem activeucmenu,  8, 82, "#Under#1122#fonts_underline##fonts", '', 0, 0  -- undrline.bmp
  5383.    buildmenuitem activeucmenu,  8, 83, "#Strike#1121#fonts_strikeout##fonts", '', 0, 0  -- strikout.bmp
  5384.    buildmenuitem activeucmenu,  8, 84, "#Outline#1120#fonts_outline##fonts", '', 0, 0  -- outline.bmp
  5385.    buildsubmenu activeucmenu,  9, '', '', 16401, 0  -- MIS_SPACER
  5386.    buildsubmenu activeucmenu, 10, "#Search#1138#a_SearchDlg##sampactn", '', 0, 0  -- search.bmp
  5387.    buildsubmenu activeucmenu, 11, "#Undo#1134#a_UndoDlg##sampactn", '', 0, 0  -- undo.bmp
  5388.    buildsubmenu activeucmenu, 12, '', '', 16401, 0  -- MIS_SPACER
  5389.    buildsubmenu activeucmenu, 13, "#Shell#1153#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5390.  compile else
  5391. ;                             # Button text # Button bitmap # command # parameters # .ex file
  5392.    buildsubmenu activeucmenu,  1, "#Add File#1116#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5393.    buildsubmenu activeucmenu,  2, "#Save#1117#a_save##sampactn", '', 0, 0
  5394.    buildsubmenu activeucmenu,  3, "#Print#1113#a_print##sampactn", '', 0, 0  -- print.bmp
  5395.    buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5396.    buildsubmenu activeucmenu,  5, "#MonoFont#1106#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5397.    buildsubmenu activeucmenu,  6, "#Style#1112#apply_style##stylebut", '', 0, 0  -- style.bmp
  5398.    buildsubmenu activeucmenu,  7, "#UnStyle#1128#remove_style##stylebut", '', 0, 0  -- style.bmp
  5399.    buildsubmenu activeucmenu,  8, "#Attribs#1119#fonts_attribs##fonts", '', 0, 0  -- attribs.bmp
  5400.    buildmenuitem activeucmenu,  8, 80, "#Bold#1124#fonts_bold##fonts", '', 0, 0  -- bold.bmp
  5401.    buildmenuitem activeucmenu,  8, 81, "#Italic#1123#fonts_italic##fonts", '', 0, 0  -- italic.bmp
  5402.    buildmenuitem activeucmenu,  8, 82, "#Under#1122#fonts_underline##fonts", '', 0, 0  -- undrline.bmp
  5403.    buildmenuitem activeucmenu,  8, 83, "#Strike#1121#fonts_strikeout##fonts", '', 0, 0  -- strikout.bmp
  5404.    buildmenuitem activeucmenu,  8, 84, "#Outline#1120#fonts_outline##fonts", '', 0, 0  -- outline.bmp
  5405.    buildsubmenu activeucmenu,  9, '', '', 16401, 0  -- MIS_SPACER
  5406.    buildsubmenu activeucmenu, 10, "#Search#1115#a_SearchDlg##sampactn", '', 0, 0  -- search.bmp
  5407.    buildsubmenu activeucmenu, 11, "#Undo#1114#a_UndoDlg##sampactn", '', 0, 0  -- undo.bmp
  5408.    buildsubmenu activeucmenu, 12, '', '', 16401, 0  -- MIS_SPACER
  5409.    buildsubmenu activeucmenu, 13, "#Shell#1118#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5410.  compile endif -- WANT_TINY_ICONS
  5411.  
  5412. ; buildsubmenu activeucmenu,  1, "#Open#1102#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5413. ; buildsubmenu activeucmenu,  2, "#Print#1113#a_print##sampactn", '', 0, 0
  5414. ; buildsubmenu activeucmenu,  3, "#Shell#1109#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5415. ; buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5416. ; buildsubmenu activeucmenu,  5, "#Style#1112#apply_style##stylebut", '', 0, 0  -- style.bmp
  5417. ; buildsubmenu activeucmenu,  6, "#MonoFont#1106#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5418. ; buildsubmenu activeucmenu,  7, "#Reflow#1107#reflow_prompt##reflow", '', 0, 0  -- reflow.bmp
  5419. ; buildsubmenu activeucmenu,  8, '', '', 16401, 0  -- MIS_SPACER
  5420. ; buildsubmenu activeucmenu,  9, "#Msgs#1100#a_Messages##sampactn", '', 0, 0  -- info.bmp
  5421. ; buildsubmenu activeucmenu, 10, "#List Ring#1110#a_List_Ring##sampactn", '', 0, 0  -- ringlist.bmp
  5422.  
  5423. ;;buildsubmenu activeucmenu, 11, "#Add New#1101#a_Add_New##sampactn", '', 0, 0  -- EPMadd.bmp
  5424. ;;buildsubmenu activeucmenu, 12, "#NewWind#1103#a_NewWindow##sampactn", '', 0, 0  -- newwindw.bmp
  5425. ;;buildsubmenu activeucmenu, 13, "#Settings#1104#a_Settings##sampactn", '', 0, 0  -- settings.bmp
  5426. ;;buildsubmenu activeucmenu, 14, "#Time#1105#a_Time##sampactn", '', 0, 0  -- clock.bmp
  5427. ;;buildsubmenu activeucmenu, 15, "#Jot#1108#jot_a_note##jot", '', 0, 0  -- idea.bmp
  5428. ;;buildsubmenu activeucmenu, 16, "#Tree#1111#tree_action##tree", '', 0, 0  -- tree.bmp
  5429. ;;buildsubmenu activeucmenu, 17, "#KwdHilit#kwdhilit.bmp#a_togl_hilit##sampactn", '', 0, 0
  5430.  
  5431.   showmenu activeucmenu, 3
  5432.   toolbar_loaded = \1
  5433.  
  5434. defc deletetemplate
  5435.    universal app_hini
  5436.    parse arg template_name
  5437. ;  if template_name='' then
  5438. ;     template_name = 'Default'
  5439. ;  endif
  5440.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5919, app_hini, put_in_buffer(template_name))
  5441.  
  5442.  compile if INCLUDE_STD_MENUS
  5443. defc toggle_toolbar
  5444.    universal toolbar_loaded
  5445.   compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  5446.    fon = queryframecontrol(EFRAMEF_TOOLBAR)  -- Query now, since toggling is asynch.
  5447.   compile endif  -- WANT_NODISMISS_MENUS
  5448.    'toggleframe' EFRAMEF_TOOLBAR
  5449.   compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  5450.    SetMenuAttribute( 430, 8192, fon)
  5451.   compile endif  -- WANT_NODISMISS_MENUS
  5452.    if not toolbar_loaded then
  5453.       'default_toolbar'
  5454.    endif
  5455.  compile endif  -- INCLUDE_STD_MENUS
  5456.  
  5457. defc default_toolbar
  5458.    universal app_hini, appname, toolbar_loaded
  5459.  compile if WPS_SUPPORT
  5460.    universal wpshell_handle
  5461.    if wpshell_handle then
  5462.       newtoolbar = peekz(peek32(wpshell_handle, 80, 4))
  5463.       if newtoolbar='' then
  5464.          newtoolbar = \1
  5465.       endif
  5466.       if toolbar_loaded <> newtoolbar then
  5467.          toolbar_loaded = newtoolbar
  5468.          if toolbar_loaded = \1 then
  5469.             'loaddefaulttoolbar'
  5470.          else
  5471.             call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(toolbar_loaded))
  5472.          endif
  5473.       else  -- Else we're already set up; make sure toolbar is turned on
  5474.          'toggleframe' EFRAMEF_TOOLBAR 1
  5475.       endif
  5476.    else
  5477.  compile endif
  5478.       def_tb = queryprofile(app_hini, appname, INI_DEF_TOOLBAR)
  5479. ;     if def_tb = '' then def_tb = 'Default'; endif
  5480.       if def_tb <> '' then
  5481.          newcmd= queryprofile(app_hini, INI_UCMENU_APP, def_tb)
  5482.       else
  5483.          newcmd = ''
  5484.       endif
  5485.       if newcmd<>'' then
  5486.          toolbar_loaded = def_tb
  5487.          call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(toolbar_loaded))
  5488.       else
  5489.          'loaddefaulttoolbar'
  5490.       endif
  5491.  compile if WPS_SUPPORT
  5492.    endif
  5493.  compile endif
  5494. compile endif -- WANT_TOOLBAR
  5495.  
  5496. compile if EPM32
  5497. defc toggle_parse
  5498.    parse arg parseon kwfilename
  5499.    if parseon & .levelofattributesupport//2=0  then  -- the first bit of .levelofattributesupport is for color attributes
  5500.       call attribute_on(1) -- toggles color attributes mode
  5501.    endif
  5502.    if kwfilename='' then
  5503.       kwfilename = 'epmkwds.c'
  5504.    endif
  5505.    if parseon then
  5506.       findfile destfilename, kwfilename, 'EPMPATH'
  5507.       if rc then
  5508.          sayerror FILE_NOT_FOUND__MSG '-' kwfilename
  5509.          return
  5510.       endif
  5511.    endif
  5512.    getfileid fid
  5513.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),
  5514.                    5502,               -- EPM_EDIT_TOGGLEPARSE
  5515.                    parseon,
  5516.                    put_in_buffer(fid kwfilename))
  5517.  compile if 0
  5518. defc qparse =
  5519.    c =  windowmessage(1,  getpminfo(EPMINFO_EDITFRAME),
  5520.                    5505,               -- EPM_EDIT_KW_QUERYPARSE
  5521.                    0,
  5522.                    0)
  5523.    sayerror 'Keyword parsing is' word(OFF__MSG ON__MSG, 2 - (not c))  -- Use as boolean
  5524.  compile endif
  5525.  
  5526. defc dyna_cmd =
  5527.    parse arg library entrypoint cmdargs
  5528.    if entrypoint='' then
  5529.       sayerror -257  -- "Invalid number of parameters"
  5530.       return
  5531.    endif
  5532.    rc = 0
  5533.    cmdargs = cmdargs\0
  5534.    dynarc = dynalink32(library,
  5535.                        entrypoint,
  5536.                        gethwndc(EPMINFO_EDITCLIENT) ||
  5537.                        address(cmdargs),
  5538.                        2)
  5539.  
  5540. defc dynafree =
  5541.    res = dynafree(arg(1))
  5542.    if res then
  5543.       sayerror ERROR__MSG res
  5544.    endif
  5545. compile endif  -- EPM32
  5546.