home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / STDCTRL.E < prev    next >
Text File  |  1996-02-09  |  242KB  |  5,616 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 >= 100) & menuid <> '' & previouslyactivemenu<>'' then  -- Temp kludge
  3827.    if menuid < 80 & menuid <> '' & previouslyactivemenu<>'' then  -- Temp kludge
  3828.       activemenu = previouslyactivemenu
  3829.       previouslyactivemenu = ''
  3830.    endif
  3831. compile else
  3832.    menuid = arg(1)
  3833. compile endif
  3834. compile if WANT_DYNAMIC_PROMPTS
  3835.    if menuid='' | activemenu='' | not menu_prompt then
  3836.       sayerror 0
  3837.       return
  3838.    endif
  3839.    parse value querymenustring(activemenu,menuid) with command \1 helpstr
  3840.    if helpstr<>'' then
  3841.  compile if EVERSION >= '5.21'
  3842.       display -8
  3843.  compile endif
  3844.       sayerror helpstr
  3845.  compile if EVERSION >= '5.21'
  3846.       display 8
  3847.  compile endif
  3848.    else
  3849.       sayerror 0
  3850.    endif
  3851. compile else
  3852.    sayerror 0
  3853. compile endif  -- WANT_DYNAMIC_PROMPTS
  3854. compile endif  -- INCLUDE_MENU_SUPPORT
  3855.  
  3856. ; Note:  this routine does *not* get called when Command (menuid 1) is selected.
  3857. defc PROCESSMENUINIT  -- Called when a pulldown or pullright is initialized.
  3858.  compile if INCLUDE_MENU_SUPPORT
  3859.    universal activemenu, defaultmenu
  3860.    universal EPM_utility_array_ID
  3861.  compile if WANT_DYNAMIC_PROMPTS
  3862.    universal menu_prompt
  3863.  compile endif
  3864.    universal lastchangeargs
  3865.  compile if WANT_STACK_CMDS
  3866.    universal mark_stack, position_stack
  3867.   compile if WANT_STACK_CMDS = 'SWITCH'
  3868.    universal stack_cmds
  3869.   compile endif
  3870.  compile endif
  3871.  compile if WANT_CUA_MARKING = 'SWITCH'
  3872.    universal CUA_marking_switch
  3873.  compile endif
  3874.  compile if WANT_STREAM_MODE = 'SWITCH'
  3875.    universal stream_mode
  3876.  compile endif
  3877.  compile if RING_OPTIONAL
  3878.    universal ring_enabled
  3879.  compile endif
  3880.  compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  3881.    universal CUA_MENU_ACCEL
  3882.  compile endif
  3883.  compile if CHECK_FOR_LEXAM
  3884.    universal LEXAM_is_available
  3885.  compile endif
  3886.  
  3887.    if activemenu<>defaultmenu then return; endif
  3888.    menuid = arg(1)
  3889.  compile if EVERSION >= 5.51
  3890.   compile if defined(SITE_MENUINIT) & not VANILLA
  3891.       compile if SITE_MENUINIT
  3892.          include SITE_MENUINIT
  3893.       compile endif
  3894.   compile endif
  3895.    if isadefc('menuinit_'menuid) then
  3896. ;  -- Bug?  Above doesn't work...
  3897. ;  tmp = 'menuinit_'menuid
  3898. ;  if isadefc(tmp) then
  3899.       'menuinit_'menuid
  3900.       return
  3901.    endif
  3902.   compile if not VANILLA
  3903.    tryinclude 'mymnuini.e'  -- For user-supplied additions to this routine.
  3904.   compile endif
  3905.  compile endif -- EVERSION >= 5.51
  3906.  
  3907. ; The following is individual commands on 5.51+; all part of ProcessMenuInit cmd on earlier versions.
  3908. compile if not defined(STD_MENU_NAME)
  3909.  compile if EVERSION >= 5.51    ------------- Menu id 8 -- Edit -------------------------
  3910.    defc menuinit_8
  3911.   compile if WANT_STACK_CMDS
  3912.    universal mark_stack, position_stack
  3913.    compile if WANT_STACK_CMDS = 'SWITCH'
  3914.    universal stack_cmds
  3915.    compile endif
  3916.   compile endif
  3917.  compile else -- EVERSION >= 5.51
  3918.    if menuid=8 then
  3919.  compile endif -- EVERSION >= 5.51
  3920.  compile if EVERSION < '5.50'
  3921.       getline current
  3922.       undo
  3923.       getline original
  3924.       undo
  3925.       SetMenuAttribute( 816, 16384, original/==current)
  3926.  compile else
  3927.       SetMenuAttribute( 816, 16384, isadirtyline())
  3928.  compile endif
  3929.       undoaction 1, PresentState        -- Do to fix range, not for value.
  3930.       undoaction 6, StateRange               -- query range
  3931.       parse value staterange with oldeststate neweststate .
  3932.       SetMenuAttribute( 818, 16384, oldeststate<>neweststate )  -- Set to 1 if different
  3933.  compile if EVERSION >= '6.03'
  3934.       paste = clipcheck(format) & (format=1024) & not (browse() | .readonly)
  3935.  compile elseif EPM32
  3936.       paste = clipcheck(format) & (format=1024) & browse()=0
  3937.  compile else
  3938.       paste = clipcheck(format) & (format=256) & browse()=0
  3939.  compile endif  -- EPM32
  3940.       SetMenuAttribute( 810, 16384, paste)
  3941.       SetMenuAttribute( 811, 16384, paste)
  3942.       SetMenuAttribute( 812, 16384, paste)
  3943.       on = marktype()<>''
  3944.       buf_flag = 0
  3945.       if not on then                             -- Only check buffer if no mark
  3946.          bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER)
  3947.          if bufhndl then                         -- If the buffer exists, check the
  3948.             buf_flag=itoa(peek(bufhndl,2,2),10)  -- amount of used space in buffer
  3949.             call buffer(FREEBUF, bufhndl)        -- then free it.
  3950.          endif
  3951.       endif
  3952.       SetMenuAttribute( 800, 16384, on | buf_flag)  -- Can copy if mark or buffer has data
  3953.       SetMenuAttribute( 801, 16384, on)
  3954.       SetMenuAttribute( 802, 16384, on | buf_flag)  -- Ditto for Overlay mark
  3955.       SetMenuAttribute( 803, 16384, on)
  3956.       SetMenuAttribute( 805, 16384, on)
  3957.       SetMenuAttribute( 806, 16384, on)
  3958.       SetMenuAttribute( 808, 16384, on)
  3959.       SetMenuAttribute( 809, 16384, on)
  3960.       SetMenuAttribute( 814, 16384, on)
  3961.  compile if WANT_STACK_CMDS
  3962.   compile if WANT_STACK_CMDS = 'SWITCH'
  3963.    if stack_cmds then
  3964.   compile endif
  3965.       SetMenuAttribute( 820, 16384, on)
  3966.       SetMenuAttribute( 821, 16384, mark_stack<>'')
  3967.       SetMenuAttribute( 822, 16384, on & mark_stack<>'')
  3968.       SetMenuAttribute( 824, 16384, position_stack<>'')
  3969.       SetMenuAttribute( 825, 16384, position_stack<>'')
  3970.   compile if WANT_STACK_CMDS = 'SWITCH'
  3971.    endif
  3972.   compile endif
  3973.  compile endif
  3974.  compile if EVERSION < 5.51
  3975.       return
  3976.    endif
  3977.  compile endif -- EVERSION < 5.51
  3978.  
  3979.  compile if EVERSION >= 5.51    ------------- Menu id 4 -- Options ---------------------
  3980.    defc menuinit_4
  3981.   compile if RING_OPTIONAL
  3982.    universal ring_enabled
  3983.   compile endif
  3984.   compile if CHECK_FOR_LEXAM
  3985.    universal LEXAM_is_available
  3986.   compile endif
  3987.  compile else -- EVERSION >= 5.51
  3988.    if menuid=4 then
  3989.  compile endif -- EVERSION >= 5.51
  3990.  compile if RING_OPTIONAL
  3991.       if ring_enabled then
  3992.  compile endif
  3993.          SetMenuAttribute( 410, 16384, filesinring()>1)
  3994.  compile if RING_OPTIONAL
  3995.       endif
  3996.  compile endif
  3997.  compile if SPELL_SUPPORT
  3998.   compile if CHECK_FOR_LEXAM
  3999.     if LEXAM_is_available then
  4000.   compile endif
  4001.       SetMenuAttribute( 450, 8192, .keyset <> 'SPELL_KEYS')
  4002.   compile if CHECK_FOR_LEXAM
  4003.     endif
  4004.   compile endif
  4005.  compile endif  -- SPELL_SUPPORT
  4006.  compile if EVERSION < 5.51
  4007.       return
  4008.    endif
  4009.  compile endif -- EVERSION < 5.51
  4010.  
  4011.  compile if WANT_CUA_MARKING = 'SWITCH' | WANT_STREAM_MODE = 'SWITCH' | RING_OPTIONAL | WANT_STACK_CMDS = 'SWITCH'
  4012.   compile if EVERSION >= 5.51    ------------- Menu id 400 -- Options / Preferences -------
  4013.    defc menuinit_400
  4014.   compile if WANT_STACK_CMDS = 'SWITCH'
  4015.    universal stack_cmds
  4016.   compile endif
  4017.   compile if WANT_CUA_MARKING = 'SWITCH'
  4018.    universal CUA_marking_switch
  4019.   compile endif
  4020.   compile if WANT_STREAM_MODE = 'SWITCH'
  4021.    universal stream_mode
  4022.   compile endif
  4023.   compile if RING_OPTIONAL
  4024.    universal ring_enabled
  4025.   compile endif
  4026.   compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  4027.    universal CUA_MENU_ACCEL
  4028.   compile endif
  4029.   compile else -- EVERSION >= 5.51
  4030.    if menuid=400 then              -- Options / Preferences
  4031.   compile endif -- EVERSION >= 5.51
  4032.   compile if WANT_CUA_MARKING = 'SWITCH'
  4033.       SetMenuAttribute( 441, 8192, CUA_marking_switch)
  4034.   compile endif
  4035.   compile if WANT_STREAM_MODE = 'SWITCH'
  4036.       SetMenuAttribute( 442, 8192, not stream_mode)
  4037.   compile endif
  4038.   compile if RING_OPTIONAL
  4039.       SetMenuAttribute( 443, 8192, not ring_enabled)
  4040.   compile endif
  4041.   compile if WANT_STACK_CMDS = 'SWITCH'
  4042.       SetMenuAttribute( 445, 8192, not stack_cmds)
  4043.   compile endif
  4044.   compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH'
  4045.     SetMenuAttribute( 446, 8192, not CUA_MENU_ACCEL)
  4046.   compile endif
  4047.   compile if EVERSION < 5.51
  4048.       return
  4049.    endif
  4050.   compile endif -- EVERSION < 5.51
  4051.  compile endif  -- WANT_CUA_MARKING, WANT_STREAM_MODE, RING_OPTIONAL, WANT_STACK_CMDS
  4052.  
  4053.  compile if EVERSION >= 5.51    ------------- Menu id 425 -- Options / Frame controls  ---
  4054.    defc menuinit_425
  4055.    universal bitmap_present
  4056.   compile if RING_OPTIONAL
  4057.       universal ring_enabled
  4058.   compile endif
  4059.   compile if WANT_DYNAMIC_PROMPTS
  4060.       universal menu_prompt
  4061.   compile endif
  4062.  compile else -- EVERSION >= 5.51
  4063.    if menuid=425 then              -- Options / Frame controls
  4064.  compile endif -- EVERSION >= 5.51
  4065.  compile if EVERSION >= 5.53
  4066.       SetMenuAttribute( 413, 8192, not queryframecontrol(1) )
  4067.       SetMenuAttribute( 414, 8192, not queryframecontrol(2) )
  4068.       SetMenuAttribute( 415, 8192, not queryframecontrol(16))
  4069.   compile if EVERSION < 5.50  -- File icon not optional in 5.50
  4070.       SetMenuAttribute( 416, 8192, not queryframecontrol(64))
  4071.   compile endif
  4072.  compile else
  4073.       SetMenuAttribute( 413, 8192, not querycontrol(7) )
  4074.       SetMenuAttribute( 414, 8192, not querycontrol(8) )
  4075.       SetMenuAttribute( 415, 8192, not querycontrol(10))
  4076. ;;    SetMenuAttribute( 416, 8192, not querycontrol(15))
  4077.   compile if EVERSION < 5.50  -- File icon not optional in 5.50
  4078.       SetMenuAttribute( 416, 8192, not querycontrol(22))
  4079.   compile endif
  4080.  compile endif
  4081.  compile if RING_OPTIONAL
  4082.       if ring_enabled then
  4083.  compile endif
  4084.  compile if EVERSION >= 5.53
  4085.          SetMenuAttribute( 417, 8192, not queryframecontrol(4))
  4086.   compile if WANT_TOOLBAR
  4087.          SetMenuAttribute( 430, 8192, not queryframecontrol(EFRAMEF_TOOLBAR))
  4088.   compile endif
  4089.          SetMenuAttribute( 437, 8192, not bitmap_present)
  4090.  compile else
  4091.          SetMenuAttribute( 417, 8192, not querycontrol(20))
  4092.  compile endif
  4093.  compile if RING_OPTIONAL
  4094.       else
  4095.          SetMenuAttribute( 417, 16384, 1)  -- Grey out Rotate Buttons if ring not enabled
  4096.       endif
  4097.  compile endif
  4098.  compile if EVERSION >= 5.53
  4099.       SetMenuAttribute( 421, 8192, not queryframecontrol(32))
  4100.  compile else
  4101.       SetMenuAttribute( 421, 8192, not querycontrol(23))
  4102.  compile endif
  4103.  compile if WANT_DYNAMIC_PROMPTS
  4104.       SetMenuAttribute( 422, 8192, not menu_prompt)
  4105.  compile endif
  4106.  compile if EVERSION < 5.51
  4107.       return
  4108.    endif
  4109.  compile endif -- EVERSION < 5.51
  4110.  
  4111.  compile if EVERSION >= 5.51    ------------- Menu id 3 -- Search -----------------------
  4112.    defc menuinit_3
  4113.       universal lastchangeargs
  4114.  compile else -- EVERSION >= 5.51
  4115.    if menuid=3 then              -- Search
  4116.  compile endif -- EVERSION >= 5.51
  4117.       getsearch strng
  4118.       parse value strng with . c .       -- blank, 'c', or 'l'
  4119.       SetMenuAttribute( 302, 16384, c<>'')  -- Find Next OK if not blank
  4120.       SetMenuAttribute( 303, 16384, lastchangeargs<>'')  -- Change Next only if 'c'
  4121.  compile if EVERSION < 5.51
  4122.       return
  4123.    endif
  4124.  compile endif -- EVERSION < 5.51
  4125.  
  4126.  compile if WANT_BOOKMARKS
  4127.   compile if EVERSION >= 5.51    ------------- Menu id 3 -- Search -----------------------
  4128.    defc menuinit_305
  4129.       universal EPM_utility_array_ID
  4130.   compile else -- EVERSION >= 5.51
  4131.    if menuid=305 then              -- Search
  4132.   compile endif -- EVERSION >= 5.51
  4133.       do_array 3, EPM_utility_array_ID, 'bmi.0', bmcount          -- Index says how many bookmarks there are
  4134.   compile if EVERSION >= '6.03'
  4135.       SetMenuAttribute( 306, 16384, not (browse() | .readonly))  -- Set
  4136.   compile else
  4137.       SetMenuAttribute( 306, 16384, browse()=0)  -- Set
  4138.   compile endif
  4139.       SetMenuAttribute( 308, 16384, bmcount>0)   -- List
  4140.       SetMenuAttribute( 311, 16384, bmcount>0)   -- Next
  4141.       SetMenuAttribute( 312, 16384, bmcount>0)   -- Prev
  4142.   compile if EVERSION < 5.51
  4143.       return
  4144.    endif
  4145.   compile endif -- EVERSION < 5.51
  4146.  compile endif  -- WANT_BOOKMARKS
  4147.  
  4148. ; Also will need to handle 204 (Name) on File menu if 5.60 & LaMail...
  4149.  
  4150.  compile if EVERSION < 5.51  -- The old way:
  4151.    compile if defined(SITE_MENUINIT) & not VANILLA
  4152.       compile if SITE_MENUINIT
  4153.          include SITE_MENUINIT
  4154.       compile endif
  4155.    compile endif
  4156.   compile if not VANILLA
  4157.    tryinclude 'mymnuini.e'  -- For user-supplied additions to this routine.
  4158.   compile endif
  4159.  compile endif -- EVERSION < 5.51
  4160. compile endif -- not defined(STD_MENU_NAME)
  4161. ; The above is all part of ProcessMenuInit cmd on old versions.  -----------------
  4162. compile endif  -- INCLUDE_MENU_SUPPORT
  4163.  
  4164. defproc SetMenuAttribute( menuid, attr, on)
  4165. ;  universal EditMenuHwnd
  4166. ;  if not EditMenuHwnd then
  4167. ;     EditMenuHwnd = getpminfo(EPMINFO_EDITMENUHWND)  -- cache; relatively expensive to obtain.
  4168. ;  endif
  4169.    if not on then
  4170.       attr=mpfrom2short(attr, attr)
  4171.    endif
  4172.    call windowmessage(1,
  4173. ;                     EditMenuHwnd,  -- Doesn't work; EditMenuHwnd changes.
  4174.                       getpminfo(EPMINFO_EDITMENUHWND),
  4175.                       402,
  4176.                       menuid + 65536,
  4177.                       attr)
  4178.  
  4179.  
  4180. defc processname =
  4181.    newname = arg(1)
  4182.    if newname<>'' & newname<>.filename then
  4183. compile if defined(PROCESSNAME_CMD)  -- Let the user override this, if desired.
  4184.       PROCESSNAME_CMD newname
  4185. compile else
  4186.       'name' newname
  4187. compile endif
  4188.    endif
  4189.  
  4190. defc undo = undo
  4191.  
  4192. defc popbook =
  4193. compile if EVERSION >= 5.50 & EPATH<>'LAMPATH'
  4194.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4195.                       13,                   -- WM_ACTIVATE
  4196.                       1,
  4197.                       getpminfo(APP_HANDLE))
  4198. compile elseif EVERSION >= 5.21 & EPATH<>'LAMPATH'
  4199.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4200.                       5142,                   -- EPM_POP_BOOK_ICON
  4201.                       0,
  4202.                       0)
  4203. compile else
  4204.    call dynalink( 'PMWIN',
  4205.              'WINSETWINDOWPOS',
  4206.               gethwnd(EPMINFO_OWNERFRAME) ||
  4207.               atoi(0) || atoi(3)          ||      /* HWND_TOP   */
  4208.               atoi(0)                     ||
  4209.               atoi(0)                     ||
  4210.               atoi(0 )                    ||
  4211.               atoi(0 )                    ||
  4212.               atoi(132 ))                        /* SWP_ACTIVATE + SWP_ZORDER */
  4213. compile endif
  4214.  
  4215.  
  4216. defc printdlg
  4217. compile if EVERSION >= '5.51'
  4218.    call windowmessage(0,
  4219.                       getpminfo(APP_HANDLE),
  4220.                       5144,               -- EPM_PRINTDLG
  4221.                       arg(1)='M',
  4222.                       0)
  4223. compile else
  4224.  compile if EPM_POINTER = 'SWITCH'
  4225.    universal vEPM_POINTER
  4226.  compile endif
  4227.  compile if EVERSION >= '5.50'
  4228.     if arg(1)<>'M' then
  4229.        call windowmessage(0,
  4230.                           getpminfo(APP_HANDLE),
  4231.                           5144,               -- EPM_PRINTDLG
  4232.                           0,
  4233.   compile if EVERSION >= '5.51'  -- I don't know if this was ever used, but it's not
  4234.                           0)     -- used (or freed) in any current version.  LAM
  4235.   compile else
  4236.                           put_in_buffer(.filename))
  4237.   compile endif
  4238.        return
  4239.     endif
  4240.  compile else
  4241.     if arg(1)='M' then
  4242.  compile endif
  4243.        call checkmark()     -- verify there is a marked area,
  4244.  compile if EVERSION < '5.50'
  4245.     endif
  4246.  compile endif
  4247.     App = 'PM_SPOOLER_PRINTER'\0
  4248.     inidata = copies(' ',255)
  4249.  compile if EPM32
  4250.     retlen = \0\0\0\0
  4251.     l = dynalink32('PMSHAPI',
  4252.                    '#115',               -- PRF32QUERYPROFILESTRING
  4253.                    atol(0)           ||  -- HINI_PROFILE
  4254.                    address(App)      ||  -- pointer to application name
  4255.                    atol(0)           ||  -- Key name is NULL; returns all keys
  4256.                    atol(0)           ||  -- Default return string is NULL
  4257.                    address(inidata)  ||  -- pointer to returned string buffer
  4258.                    atol(255)    ||       -- max length of returned string
  4259.                    address(retlen), 2)         -- length of returned string
  4260.  compile else
  4261.     l =  dynalink( 'PMSHAPI',
  4262.                    'PRFQUERYPROFILESTRING',
  4263.                    atol(0)          ||  -- HINI_PROFILE
  4264.                    address(App)     ||  -- pointer to application name
  4265.                    atol(0)          ||  -- Key name is NULL; returns all keys
  4266.                    atol(0)          ||  -- Default return string is NULL
  4267.                    address(inidata) ||  -- pointer to returned string buffer
  4268.                    atol_swap(255), 2)        -- max length of returned string
  4269.  compile endif
  4270.  
  4271.     if not l then sayerror NO_PRINTERS__MSG; return; endif
  4272.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER', 'PRINTER') with default_printername ';'
  4273.     inidata=leftstr(inidata,l)
  4274.     getfileid startfid
  4275.     'xcom e /c /q tempfile'
  4276.     if rc<>-282 then  -- sayerror('New file')
  4277.        sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  4278.        return
  4279.     endif
  4280.     .autosave = 0
  4281.     browse_mode = browse()     -- query current state
  4282.     if browse_mode then call browse(0); endif
  4283. ;;; deleteline 1
  4284. ;;compile if EVERSION < 5.50
  4285.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER_DESCR', default_printername) with descr ';'
  4286.     insertline default_printername '('descr')', .last+1    -- Place default first.
  4287. ;;compile else
  4288. ;;   default_entry = 1
  4289. ;;compile endif
  4290.     do while inidata<>''
  4291.        parse value inidata with printername \0 inidata
  4292.        if printername=default_printername then
  4293. ;;compile if EVERSION < 5.50
  4294.           iterate
  4295. ;;compile else
  4296. ;;         default_entry = .last
  4297. ;;compile endif
  4298.        endif
  4299.        parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER_DESCR', printername) with descr ';'
  4300.        insertline printername '('descr')', .last+1
  4301.     enddo
  4302.     if browse_mode then call browse(1); endif  -- restore browse state
  4303.     if listbox_buffer_from_file(startfid, bufhndl, noflines, usedsize) then return; endif
  4304.  compile if EVERSION < 5.50
  4305.     ret = listbox(SELECT_PRINTER__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32),'',1,5)
  4306.  compile else
  4307.   compile if 0 -- POWERPC
  4308.     parse value listbox(PRINT__MSG, \0 || atol(usedsize) || atol(bufhndl+32),
  4309.   compile elseif EPM32
  4310.     parse value listbox(PRINT__MSG, \0 || atol(usedsize) || atoi(32) || atoi(bufhndl),
  4311.   compile else
  4312.     parse value listbox(PRINT__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32),
  4313.   compile endif
  4314.                         '/'DRAFT__MSG'/'WYSIWYG__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0,
  4315.   compile if EVERSION >= 5.60
  4316.                         gethwndc(APP_HANDLE) || atoi(1/*default_entry*/) || atoi(1) || atoi(6060) ||
  4317.   compile else
  4318.                         atoi(1/*default_entry*/) || atoi(1) || atoi(6060) || gethwndc(APP_HANDLE) ||
  4319.   compile endif
  4320.                         SELECT_PRINTER__MSG) with button 2 printername ' (' \0
  4321.  compile endif
  4322.     call buffer(FREEBUF, bufhndl)
  4323.  compile if EVERSION < 5.50
  4324.     if ret='' then return; endif
  4325.     parse value ret with printername ' ('
  4326.  compile else
  4327.     if button<>\1 & button<>\2 then return; endif
  4328.  compile endif
  4329.     parse value queryprofile(HINI_PROFILE, 'PM_SPOOLER_PRINTER', printername) with dev ';' . ';' queue ';'
  4330.  compile if EVERSION >= 5.50
  4331.     if button=\1 then  -- Draft
  4332.  compile endif
  4333.        if dev='' then
  4334.           sayerror PRINTER__MSG printername NO_DEVICE__MSG
  4335.        else
  4336.           if arg(1)='M' then
  4337.              'print' dev   -- PRINT command will print the marked area
  4338.           else
  4339.  compile if EVERSION < '5.50'
  4340.              'xcom save' dev  -- Save the file to the printer
  4341.  compile else
  4342.              'xcom save /ne' dev  -- Save the file to the printer
  4343.  compile endif
  4344.           endif
  4345.        endif
  4346.  compile if EVERSION >= 5.50
  4347.     elseif button=\2 then  -- WYSIWYG
  4348.        if queue='' then
  4349.           sayerror PRINTER__MSG printername NO_QUEUE__MSG
  4350.        else
  4351.           if arg(1)='M' then
  4352.              getmark firstline,lastline,firstcol,lastcol,markfileid
  4353.              getfileid fileid
  4354.              mt=marktype()
  4355.              'xcom e /n'             /*  Create a temporary no-name file. */
  4356.              if rc=-282 then  -- sayerror("New file")
  4357.                 if browse_mode then call browse(0); endif  -- Turn off browse state
  4358.                 if mt='LINE' then deleteline endif
  4359.              elseif rc then
  4360.                 stop
  4361.              endif
  4362.              getfileid tempofid
  4363.              .levelofattributesupport = markfileid.levelofattributesupport
  4364.              .font = markfileid.font
  4365.              call pcopy_mark()
  4366.              if browse_mode then call browse(1); endif  -- restore browse state
  4367.              if rc then stop endif
  4368.              call pset_mark(firstline,lastline,firstcol,lastcol,mt,markfileid)
  4369.              activatefile tempofid
  4370.              sayerror PRINTING_MARK__MSG
  4371.           else
  4372.              sayerror PRINTING__MSG .filename
  4373.           endif
  4374.           mouse_setpointer WAIT_POINTER
  4375. ;;;       qprint queue
  4376.           qprint printername
  4377.           if arg(1)='M' then .modify=0; 'xcom q' endif
  4378.   compile if EPM_POINTER = 'SWITCH'
  4379.           mouse_setpointer vEPM_POINTER
  4380.   compile else
  4381.           mouse_setpointer EPM_POINTER
  4382.   compile endif
  4383.           sayerror 0    /* clear 'printing' message */
  4384.        endif  -- have queue
  4385.     endif  -- button 2
  4386.  compile endif
  4387. compile endif -- >= 5.51
  4388.  
  4389. defc printfile
  4390.    if arg(1)<>'' then
  4391. compile if EVERSION < '5.50'
  4392.       'xcom save' arg(1)  -- Save the file to the printer
  4393. compile else
  4394.       'xcom save /s /ne' arg(1)  -- Save the file to the printer
  4395. compile endif
  4396.    endif
  4397.  
  4398. compile if EVERSION >= 5.51
  4399. defc process_qprint
  4400.  compile if EPM_POINTER = 'SWITCH'
  4401.    universal vEPM_POINTER
  4402.  compile endif
  4403.    if arg(1)='' then
  4404.       sayerror PRINTER__MSG /*printername*/ NO_QUEUE__MSG
  4405.    else
  4406.       mouse_setpointer WAIT_POINTER
  4407.       qprint arg(1)
  4408.  compile if EPM_POINTER = 'SWITCH'
  4409.       mouse_setpointer vEPM_POINTER
  4410.  compile else
  4411.       mouse_setpointer EPM_POINTER
  4412.  compile endif
  4413.    endif
  4414.  
  4415. ; Flags
  4416. ;  F    = File
  4417. ;  M  1 = marked area (default = entire file)
  4418. ;  !  2 = print immediately; don't wait for print dialog's OK
  4419. ;     4 = queue name given
  4420. ;     8 = PRINTOPTS structure given (binary structure; can't be done via this cmd)
  4421. ;         (6.03a or above, only)
  4422. defc qprint
  4423.    parse arg what queue_name
  4424.    w = wordpos(upcase(what), 'M M! F F! !')
  4425.    if w then
  4426.       flags =           word('1 3  0 2  2', w)
  4427.    else                   -- Not a flag;
  4428.       queue_name = arg(1)  -- assume part of the queue name
  4429.       flags = 0            -- and use default options.
  4430.    endif
  4431.    if queue_name <> '' then flags = flags + 4; endif
  4432.    call windowmessage(0,
  4433.                       getpminfo(APP_HANDLE),
  4434.                       5144,               -- EPM_PRINTDLG
  4435.                       flags,
  4436.                       put_in_buffer(queue_name) )
  4437.  
  4438. compile elseif EVERSION >= 5.50
  4439.  
  4440. defc qprint
  4441.  compile if EPM_POINTER = 'SWITCH'
  4442.    universal vEPM_POINTER
  4443.  compile endif
  4444.    if arg(1)='' then
  4445.       sayerror PRINTER__MSG /*printername*/ NO_QUEUE__MSG
  4446.    else
  4447.       mouse_setpointer WAIT_POINTER
  4448.       qprint arg(1)
  4449.  compile if EPM_POINTER = 'SWITCH'
  4450.       mouse_setpointer vEPM_POINTER
  4451.  compile else
  4452.       mouse_setpointer EPM_POINTER
  4453.  compile endif
  4454.    endif
  4455. compile endif
  4456.  
  4457. compile if WANT_CUA_MARKING = 'SWITCH'
  4458. defc CUA_mark_toggle
  4459.    universal CUA_marking_switch
  4460.    CUA_marking_switch = not CUA_marking_switch
  4461.    'togglecontrol 25' CUA_marking_switch
  4462.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  4463.    SetMenuAttribute( 441, 8192, CUA_marking_switch)
  4464.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  4465.    call MH_set_mouse()
  4466. compile endif
  4467.  
  4468. compile if WANT_STREAM_MODE = 'SWITCH'
  4469. defc stream_toggle
  4470.    universal stream_mode
  4471.    stream_mode = not stream_mode
  4472.    'togglecontrol 24' stream_mode
  4473.  compile if WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS & not defined(STD_MENU_NAME)
  4474.    SetMenuAttribute( 442, 8192, not stream_mode)
  4475.  compile endif  -- WANT_NODISMISS_MENUS & INCLUDE_STD_MENUS
  4476. compile endif
  4477.  
  4478. compile if RING_OPTIONAL
  4479. defc ring_toggle
  4480.    universal ring_enabled
  4481.    universal activemenu, defaultmenu
  4482.    ring_enabled = not ring_enabled
  4483.  compile if EVERSION < 5.53
  4484.    'togglecontrol 20' ring_enabled
  4485.  compile else
  4486.    'toggleframe 4' ring_enabled
  4487.  compile endif
  4488.  compile if INCLUDE_STD_MENUS
  4489.   compile if not defined(STD_MENU_NAME)
  4490.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the file menu
  4491.    call add_file_menu(defaultmenu)
  4492.    deletemenu defaultmenu, 4, 0, 1                  -- Delete the options menu
  4493.    call add_options_menu(defaultmenu, dos_version()>=1020)
  4494.    call maybe_show_menu()
  4495.   compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4496.    deletemenu defaultmenu, 1, 0, 1                  -- Delete the file menu
  4497.    call add_file_menu(defaultmenu)
  4498.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the view menu
  4499.    call add_view_menu(defaultmenu)
  4500.    call maybe_show_menu()
  4501.   compile endif
  4502. ; compile if WANT_NODISMISS_MENUS & EVERSION < 5.60
  4503. ;  SetMenuAttribute( 443, 8192, not ring_enabled)  -- We're rebuilding this menu; give it up.
  4504. ; compile endif  -- WANT_NODISMISS_MENUS
  4505.  compile endif  -- INCLUDE_STD_MENUS
  4506. compile endif
  4507.  
  4508. compile if WANT_STACK_CMDS = 'SWITCH'
  4509. defc stack_toggle
  4510.    universal stack_cmds
  4511.    universal activemenu, defaultmenu
  4512.    stack_cmds = not stack_cmds
  4513.  compile if INCLUDE_STD_MENUS
  4514.   compile if not defined(STD_MENU_NAME)
  4515.    deletemenu defaultmenu, 8, 0, 1                  -- Delete the edit menu
  4516.    call add_edit_menu(defaultmenu)
  4517.    call maybe_show_menu()
  4518.   compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4519.    deletemenu defaultmenu, 2, 0, 1                  -- Delete the view menu
  4520.    call add_view_menu(defaultmenu)
  4521.    deletemenu defaultmenu, 3, 0, 1                  -- Delete the selected menu
  4522.    call add_selected_menu(defaultmenu)
  4523.    call maybe_show_menu()
  4524.   compile endif
  4525. ; compile if WANT_NODISMISS_MENUS & EVERSION < 5.60
  4526. ;  SetMenuAttribute( 445, 8192, not stack_cmds)
  4527. ; compile endif  -- WANT_NODISMISS_MENUS
  4528.  compile endif  -- INCLUDE_STD_MENUS
  4529. compile endif
  4530.  
  4531. compile if BLOCK_ACTIONBAR_ACCELERATORS = 'SWITCH' & INCLUDE_STD_MENUS
  4532. defc accel_toggle
  4533.    universal CUA_MENU_ACCEL
  4534.    universal activemenu, defaultmenu
  4535.    CUA_MENU_ACCEL = not CUA_MENU_ACCEL
  4536.    deleteaccel 'defaccel'
  4537.    'loadaccel'
  4538.  compile if not defined(STD_MENU_NAME)
  4539.    deletemenu defaultmenu, 8, 0, 1                  -- Delete the edit menu
  4540.    call add_edit_menu(defaultmenu)
  4541.    if activemenu=defaultmenu  then
  4542.   compile if 0   -- Don't need to actually show the menu; can just update the affected text.
  4543.       showmenu activemenu
  4544.   compile else
  4545.       call update_edit_menu_text()
  4546.   compile endif
  4547.    endif
  4548.  compile elseif STD_MENU_NAME = 'ovshmenu.e'
  4549.    deletemenu defaultmenu, 3, 0, 1                  -- Delete the selected menu
  4550.    call add_selected_menu(defaultmenu)
  4551.    if activemenu=defaultmenu  then
  4552.   compile if 0   -- Don't need to actually show the menu; can just update the affected text.
  4553.       showmenu activemenu
  4554.   compile else
  4555.       call update_edit_menu_text()
  4556.   compile endif
  4557.    endif
  4558.  compile endif
  4559.  compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  4560.    SetMenuAttribute( 446, 8192, not CUA_MENU_ACCEL)
  4561.  compile endif  -- WANT_NODISMISS_MENUS
  4562. compile endif
  4563.  
  4564. compile if WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21
  4565. ; This will be moved into the notebook control, so no NLS translation for the temporary macro code.
  4566. defc config_enter
  4567.  compile if EPATH = 'LAMPATH'
  4568.    call dynalink( 'LAMRES',
  4569.                   'LAMRESENTERKEYDIALOG',
  4570.                   gethwnd(EPMINFO_EDITFRAME) ||
  4571.                   gethwnd(EPMINFO_EDITFRAME) )
  4572.  compile else
  4573.    universal enterkey, a_enterkey, c_enterkey, s_enterkey
  4574.    universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey
  4575.   compile if WANT_STREAM_MODE = 'SWITCH'
  4576.    universal stream_mode
  4577.   compile endif
  4578.    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/');
  4579.    if k=='' then
  4580.       return
  4581.    endif
  4582.    parse value k with k '.  ' keyname
  4583.    select = listbox('Select an action for the' keyname 'key:',
  4584.  '/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/')
  4585.    if select=='' then
  4586.       return
  4587.    endif
  4588.    parse value select with select '.'
  4589.    if k=1 then     enterkey=      select
  4590.    elseif k=2 then a_enterkey=    select
  4591.    elseif k=3 then c_enterkey=    select
  4592.    elseif k=4 then s_enterkey=    select
  4593.    elseif k=5 then padenterkey=   select
  4594.    elseif k=6 then a_padenterkey= select
  4595.    elseif k=7 then c_padenterkey= select
  4596.    else            s_padenterkey= select
  4597.    endif
  4598.   compile if WANT_STREAM_MODE = 'SWITCH'
  4599.    if stream_mode then
  4600.       call winmessagebox('Stream mode active','Key change will not be visible until stream mode is turned off.', 16432) -- MB_OK + MB_INFORMATION + MB_MOVEABLE
  4601.    endif
  4602.   compile endif
  4603.  compile endif  -- LAMPATH
  4604. compile endif  -- WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21
  4605.  
  4606. defc helpmenu   -- send EPM icon window a help message.
  4607.    call windowmessage(0,  getpminfo(APP_HANDLE),
  4608.                       5133,      -- EPM_HelpMgrPanel
  4609.                       arg(1),    -- mp1 = 0=Help for help, 1=index; 2=TOC; 256... =panel #
  4610.                       0)         -- mp2 = NULL
  4611.  
  4612.  
  4613. defc ibmmsg
  4614.    ever = EVERSION
  4615.    if \0 = rightstr(EVERSION,1) then
  4616.       ever=leftstr(EVERSION,length(eversion)-1)
  4617.    endif
  4618. compile if EPATH = 'LAMPATH'
  4619.    call WinMessageBox("LaMail", LAMAIL_VER__MSG "2.3"\13EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384)
  4620. ;;compile elseif EVERSION >= 5.51 & NLS_LANGUAGE = 'ENGLISH'
  4621. compile elseif EVERSION >= 5.51 & EDITOR__MSG = "EPM Editor - Product Information"
  4622.    -- verstr = EDITOR_VER__MSG ver(0)\0
  4623.    verstr = EDITOR_VER__MSG ver(0)\0MACROS_VER__MSG ever
  4624.    call windowmessage(0, getpminfo(APP_HANDLE),
  4625.                       5146,               -- EPM_POPABBOUTBOX
  4626.                       0,
  4627.                       put_in_buffer(verstr) )
  4628. compile else
  4629.    call WinMessageBox(EDITOR__MSG, EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384)
  4630. compile endif
  4631.  
  4632.  
  4633. defproc LoadVersionString(var buff, var modname)
  4634. compile if EPM32
  4635.    hmodule = \0\0\0\0
  4636. compile else
  4637.    hmodule = \0\0
  4638. compile endif
  4639.  
  4640.    if arg(3) then
  4641.       modname = arg(3)\0
  4642. compile if EPM32
  4643.       rc = dynalink32('DOSCALLS',
  4644.                       '#318',  -- Dos32LoadModule
  4645.                       atol(0) ||  -- Buffer address
  4646.                       atol(0) ||  -- Buffer length
  4647.                       address(modname) ||
  4648.                       address(hmodule))
  4649. compile else
  4650.       rc=  dynalink('DOSCALLS',            -- dynamic link library name
  4651.                '#44',                      -- DosLoadModule
  4652.                atol(0)                ||   -- Buffer address
  4653.                atoi(0)                ||   -- Buffer length
  4654.                address(modname)       ||   -- Module we're loading
  4655.                address(hmodule) )          -- Address of handle to be returned
  4656. compile endif
  4657.    endif
  4658.  
  4659.    buff = copies(\0, 255)
  4660. compile if EPM32
  4661.    res= dynalink32('PMWIN',
  4662.                    '#781',  -- Win32LoadString
  4663.                    gethwndc(EPMINFO_HAB)  ||
  4664.                    hmodule                ||  -- NULLHANDLE
  4665.                    atol(65535)            ||  -- IDD_BUILDDATE
  4666.                    atol(length(buff))     ||
  4667.                    address(buff), 2 )
  4668. compile else
  4669.    res= dynalink( 'PMWIN',
  4670.                   'WINLOADSTRING',
  4671.                   gethwnd(EPMINFO_HAB)   ||
  4672.                   hmodule                ||  -- NULLHANDLE
  4673.                   atoi(65535)            ||  -- IDD_BUILDDATE
  4674.                   atoi(length(buff))     ||
  4675.                   address(buff) )
  4676. compile endif
  4677.    buff = leftstr(buff, res)
  4678.  
  4679.    if arg(3) then
  4680.       modname = copies(\0, 260)
  4681. compile if EPM32
  4682.       call dynalink32('DOSCALLS',         -- dynamic link library name
  4683.                       '#320',                    -- DosQueryModuleName
  4684.                       hmodule               ||   -- module handle
  4685.                       atol(length(modname)) ||   -- Buffer length
  4686.                       address(modname) )         -- Module we've loading
  4687.       call dynalink32('DOSCALLS',
  4688.                       '#322',  -- Dos32FreeModule
  4689.                       hmodule)
  4690. compile else
  4691.       call dynalink('DOSCALLS',         -- dynamic link library name
  4692.                     '#48',                     -- DosGetModName
  4693.                     hmodule               ||   -- module handle
  4694.                     atoi(length(modname)) ||   -- Buffer length
  4695.                     address(modname) )         -- Module we've loading
  4696.       call dynalink('DOSCALLS',         -- dynamic link library name
  4697.                     '#46',                   -- DosFreeModule
  4698.                     hmodule)
  4699. compile endif
  4700.       parse value modname with modname \0
  4701.    endif
  4702.  
  4703.  
  4704. defc versioncheck =
  4705. ;                   Get EPM.EXE build date
  4706.    LoadVersionString(buff, modname)
  4707.  
  4708. ;                   Get ETKEnnn.DLL build date
  4709.    LoadVersionString(buffe, modname, E_DLL)
  4710.  
  4711. ;                   Get ETKRnnn.DLL build date
  4712.    LoadVersionString(buffr, modname, ERES2_DLL)
  4713.  
  4714. compile if EVERSION >= 6.03
  4715. ;                   Get ETKRnnn.DLL build date
  4716.    LoadVersionString(buffc, modname, ERES_DLL)
  4717. compile endif
  4718.  
  4719. compile if EVERSION >= 6.03
  4720.    call WinMessageBox("EPM Build", EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG EVERSION\13'('wheredefc('versioncheck')')'\13\13'EPM.EXE' buff\13E_DLL'.DLL' buffe\13ERES2_DLL'.DLL' buffr\13ERES_DLL'.DLL' buffc\13\13COPYRIGHT__MSG, 16384)
  4721. compile else
  4722.    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)
  4723. compile endif
  4724.  
  4725. defc versioncheck_file =
  4726.    'xcom e /c /q tempfile'
  4727.    if rc<>-282 then  -- sayerror('New file')
  4728.       sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  4729.       return
  4730.    endif
  4731.    .autosave = 0
  4732.    .filename = "EPM Build"
  4733.    browse_mode = browse()     -- query current state
  4734.    if browse_mode then call browse(0); endif
  4735.    insertline EDITOR_VER__MSG ver(0), 1
  4736.    insertline MACROS_VER__MSG EVERSION, 2
  4737. compile if EVERSION >= 6.03
  4738.    insertline '('wheredefc('versioncheck')')', 3
  4739. compile endif
  4740.    LoadVersionString(buff, modname)
  4741.    insertline 'EPM.EXE    ' buff '('find_epm_exec()')', .last+1
  4742.    LoadVersionString(buff, modname, E_DLL)
  4743.    insertline E_DLL'.DLL' buff '('modname')', .last+1
  4744.    LoadVersionString(buff, modname, ERES2_DLL)
  4745.    insertline ERES2_DLL'.DLL' buff '('modname')', .last+1
  4746. compile if EVERSION >= 6.03
  4747.    LoadVersionString(buff, modname, ERES_DLL)
  4748.    insertline ERES_DLL'.DLL' buff '('modname')', .last+1
  4749. compile endif
  4750.    .modify = 0
  4751.    if browse_mode then call browse(1); endif
  4752.  
  4753. defproc find_epm_exec =
  4754. compile if EVERSION < 6
  4755.       seg_ptr = 1234
  4756.       cmd_ptr = 1234
  4757.       call dynalink('DOSCALLS',           -- dynamic link library name
  4758.                     '#91',                -- ordinal value for DOSGETENV
  4759.                     address(seg_ptr) ||   -- pointer to env. segment
  4760.                     address(cmd_ptr) )    -- pointer to offset after COMSPEC
  4761.       return peekz(itoa(seg_ptr,10), itoa(cmd_ptr,10))
  4762. compile else
  4763.    pib = 1234
  4764.    tid = 1234
  4765.  
  4766.    call dynalink32('DOSCALLS',      -- dynamic link library name
  4767.                    '#312',          -- ordinal value for DOS32GETINFOBLOCKS
  4768.                    address(tid) ||
  4769.                    address(pib), 2)
  4770.    return peekz(peek32(ltoa(pib, 10), 12, 4))
  4771. compile endif
  4772.  
  4773. compile if EVERSION < 5.50  -- Not used in later versions; don't bother including
  4774.                             -- unless someone screams.  (If anyone needs it, we must
  4775.                             -- add a 32-bit version.)
  4776. defproc screenxysize( cxcy )     -- syntax :   retvalue =screenxysize( 'Y' or 'X' )
  4777.    return dynalink( 'PMWIN',
  4778.                     'WINQUERYSYSVALUE',
  4779.                      atoi(0) || atoi(1)      ||
  4780.                      atoi(20 + (upcase(cxcy)='Y')))
  4781. compile endif
  4782.  
  4783.  
  4784. defproc put_in_buffer(string)
  4785.    if string='' then                   -- Was a string given?
  4786.       return 0                         -- If not, return a null pointer.
  4787.    endif
  4788. compile if POWERPC  -- Temp. kludge because they don't support tiled memory
  4789.   if arg(2)='' then
  4790.      strbuffer = atol(dynalink32(E_DLL,
  4791.                                   'mymalloc',
  4792.                                   atol(length(string)+1), 2))
  4793.      r = -270 * (strbuffer = 0)
  4794.   else
  4795. compile endif
  4796. compile if EPM32
  4797.    if arg(2)='' then share=83;  -- PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE
  4798.    else share=arg(2); endif
  4799.    strbuffer = "????"                  -- Initialize string pointer.
  4800.    r =  dynalink32('DOSCALLS',          -- Dynamic link library name
  4801.             '#299',                    -- Dos32AllocMem
  4802.             address(strbuffer)     ||
  4803.             atol(length(string)+1) ||  -- Number of bytes requested
  4804.             atol(share))               -- Share information
  4805.  compile if POWERPC  -- Temp. kludge because they don't support tiled memory
  4806.   endif
  4807.  compile endif
  4808. compile else
  4809.    if arg(2)='' then share=0; else share=arg(2); endif
  4810.    strbuffer = "??"                    -- Initialize string pointer.
  4811.    r =  dynalink('DOSCALLS',           -- Dynamic link library name
  4812.             '#34',                     -- DosAllocSeg
  4813.             atoi(length(string)+1) ||  -- Number of bytes requested
  4814.             address(strbuffer)     ||
  4815.             atoi(share))               -- Share information
  4816. compile endif  -- EPM32
  4817.  
  4818.    if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif
  4819. compile if 0 -- POWERPC
  4820.    -- Leave strbuffer as a long
  4821.    strbuffer = ltoa(strbuffer,10)
  4822. compile elseif EPM32
  4823.    strbuffer = itoa(substr(strbuffer,3,2),10)
  4824. compile else
  4825.    strbuffer = itoa(strbuffer,10)
  4826. compile endif  -- EPM32
  4827. compile if 0 -- POWERPC
  4828.    poke32 strbuffer, 0, string    -- Copy string to new allocated buf
  4829.    poke32 strbuffer, length(string), \0  -- Add a null at the end
  4830.    return strbuffer    -- Return a long pointer to buffer
  4831. compile else
  4832.    poke strbuffer,0,string    -- Copy string to new allocated buf
  4833.    poke strbuffer,length(string),\0  -- Add a null at the end
  4834.    return mpfrom2short(strbuffer,0)    -- Return a long pointer to buffer
  4835. compile endif
  4836.  
  4837.  
  4838. compile if EVERSION > 5.20
  4839. defc loadaccel
  4840.    universal activeaccel
  4841.    activeaccel='defaccel'
  4842.  compile if INCLUDE_MENU_SUPPORT & INCLUDE_STD_MENUS
  4843.                        -- Help key
  4844. ;; buildacceltable activeaccel, 'helpmenu 4000', AF_VIRTUALKEY, VK_F1, 1000
  4845.    buildacceltable activeaccel, 'dokey s+F1', AF_VIRTUALKEY+AF_SHIFT, VK_F1, 1000
  4846.  
  4847.    call build_menu_accelerators(activeaccel)  -- Moved to menu-specific file
  4848.  compile endif -- INCLUDE_MENU_SUPPORT & INCLUDE_STD_MENUS
  4849.  
  4850.    buildacceltable activeaccel, 'Alt_enter 1', AF_VIRTUALKEY+AF_ALT,  VK_NEWLINE, 1080  -- Alt+Enter
  4851.    buildacceltable activeaccel, 'Alt_enter 2', AF_VIRTUALKEY+AF_ALT,    VK_ENTER, 1081  -- Alt+PadEnter
  4852.    buildacceltable activeaccel, 'Alt_enter 3', AF_VIRTUALKEY+AF_SHIFT,VK_NEWLINE, 1082  -- Shift+Enter
  4853.    buildacceltable activeaccel, 'Alt_enter 4', AF_VIRTUALKEY+AF_SHIFT,  VK_ENTER, 1083  -- Shift+PadEnter
  4854.  
  4855.  compile if defined(BLOCK_ALT_KEY)
  4856.    buildacceltable activeaccel, 'beep 2000 50', AF_VIRTUALKEY+AF_LONEKEY, VK_ALT, 1020
  4857.    buildacceltable activeaccel, 'beep 2000 50', AF_VIRTUALKEY+AF_LONEKEY, VK_ALTGRAF, 1021
  4858.  compile endif
  4859.  
  4860.    activateacceltable activeaccel
  4861.  
  4862.  compile if defined(BLOCK_ALT_KEY)
  4863. defc beep = a=arg(1); do while a<>''; parse value a with pitch duration a; call beep(pitch, duration); enddo
  4864.  compile endif
  4865.  
  4866. defc alt_enter =
  4867.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  -- define each key separately
  4868.    universal a_enterkey, a_padenterkey, s_enterkey, s_padenterkey
  4869.    call enter_common(substr(a_enterkey||a_padenterkey||s_enterkey||s_padenterkey,arg(1),1))
  4870.  compile else
  4871.    executekey enter
  4872.  compile endif
  4873.  
  4874. defc dokey
  4875.    executekey resolve_key(arg(1))
  4876.  
  4877. defc keyin
  4878.    keyin arg(1)
  4879.  
  4880. compile endif -- EVERSION >= 5.20  (Started above loadaccel command)  ---------
  4881.  
  4882. defc rename
  4883.    name = .filename
  4884.    if name=UNNAMED_FILE_NAME then name=''; endif
  4885. compile if EVERSION >= 5.21
  4886.    parse value entrybox(RENAME__MSG, '', name, 0, 240,
  4887. ;         atoi(1) || atoi(0) || gethwndc(APP_HANDLE) ||
  4888.           atoi(1) || atoi(0) || atol(0) ||
  4889.           RENAME_PROMPT__MSG '<' directory() '>') with button 2 name \0
  4890.    if button=\1 & name<>'' then 'name' name; endif
  4891. compile else
  4892.    name = entrybox(RENAME__MSG, '', name)
  4893.    if name<>'' then 'name' name; endif
  4894. compile endif
  4895.  
  4896. defc maybe_reflow_ALL
  4897.    do i = 1 to .last
  4898.       if textline(i)<>'' then  -- Only ask if there's text in the file.
  4899.          if askyesno(REFLOW_ALL__MSG,1) = YES_CHAR then
  4900.             'reflow_all'
  4901.          endif
  4902.          leave
  4903.       endif
  4904.    enddo
  4905.  
  4906. compile if EVERSION >= 5.51
  4907. defc edit_list =
  4908.    getfileid startfid
  4909.    firstloaded = startfid
  4910.    parse arg list_sel list_ofs .
  4911.    orig_ofs = list_ofs
  4912.    do forever
  4913.       list_ptr = peek(list_sel, list_ofs, 4)
  4914.       if list_ptr == \0\0\0\0 then leave; endif
  4915.       fn = peekz(list_ptr)
  4916.       if pos(' ', fn) then
  4917.          fn = '"'fn'"'
  4918.       endif
  4919.       'e' fn
  4920.       list_ofs = list_ofs + 4
  4921.       if startfid = firstloaded then
  4922.          getfileid firstloaded
  4923.       endif
  4924.    enddo
  4925.  compile if 1  -- Now, the macros free the buffer.
  4926.    call buffer(FREEBUF, list_sel)
  4927.  compile else
  4928.    call windowmessage(1,  getpminfo(EPMINFO_OWNERCLIENT),   -- Send message to owner client
  4929.                       5486,               -- Tell it to free the buffer.
  4930.                       mpfrom2short(list_sel, orig_ofs),
  4931.                       0)
  4932.  compile endif
  4933.    activatefile firstloaded
  4934. compile endif
  4935.  
  4936. compile if EVERSION >= 5.21
  4937. ; Called with a string to set the statusline text to that string; with no argument
  4938. ; to just set the statusline color.
  4939. defc setstatusline
  4940.    universal vSTATUSCOLOR, current_status_template
  4941.    if arg(1) then
  4942.       current_status_template = arg(1)
  4943. compile if EVERSION >= 5.53
  4944.          template=atoi(length(current_status_template)) || current_status_template
  4945. compile else
  4946.          template=chr(length(current_status_template)) || current_status_template
  4947. compile endif
  4948.       template_ptr=put_in_buffer(template)
  4949.    else
  4950.       template_ptr=0
  4951.    endif
  4952.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  4953.                       5431,      -- EPM_FRAME_STATUSLINE
  4954.                       template_ptr,
  4955.                       vSTATUSCOLOR)
  4956.  
  4957. ; Called with a string to set the messageline text to that string; with no argument
  4958. ; to just set the messageline color.
  4959. defc setmessageline
  4960.    universal vMESSAGECOLOR
  4961.    if arg(1) then
  4962. compile if EVERSION >= 5.53
  4963.       template=atoi(length(arg(1))) || arg(1)
  4964. compile else
  4965.       template=chr(length(arg(1))) || arg(1)
  4966. compile endif
  4967.       template_ptr=put_in_buffer(template)
  4968.    else
  4969.       template_ptr=0
  4970.    endif
  4971.    call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  4972.                       5432,      -- EPM_FRAME_MESSAGELINE
  4973.                       template_ptr,
  4974.                       vMESSAGECOLOR)
  4975. compile endif
  4976.  
  4977. defc new
  4978.    getfileid startfid
  4979.    'xcom e /n'
  4980.    if rc<>-282 then return; endif  -- sayerror 'New file'
  4981.    getfileid newfid
  4982.    activatefile startfid
  4983.    temp = startfid  -- temp fix for some bug
  4984.    'quit'
  4985.    getfileid curfid
  4986.    activatefile newfid
  4987.    if curfid=startfid then  -- Wasn't quit; user must have said Cancel to Quit dlg
  4988.       'xcom quit'
  4989.    endif
  4990.  
  4991. compile if SUPPORT_USERS_GUIDE | SUPPORT_TECHREF
  4992. defc viewword  -- arg(1) is name of .inf file
  4993.    if find_token(startcol, endcol) then
  4994.       findfile fully_qualified, arg(1)'.inf', 'BOOKSHELF'
  4995.       if rc then
  4996.          sayerror FILE_NOT_FOUND__MSG '"'arg(1)'.inf"'
  4997.          return
  4998.       endif
  4999.       'view' arg(1) substr(textline(.line), startcol, (endcol-startcol)+1)
  5000.    endif
  5001. compile endif
  5002.  
  5003. defc cascade_menu
  5004.    parse arg menuid defmenuid .
  5005. ; if dos_version()>=2000 then
  5006.    menuitem = copies(\0, 16)  -- 2 bytes ea. pos'n, style, attribute, identity; 4 bytes submenu hwnd, long item
  5007.    if not windowmessage(1,
  5008.                         getpminfo(EPMINFO_EDITMENUHWND),
  5009.                         386,                  -- x182, MM_QueryItem
  5010.                         menuid + 65536,
  5011.                         ltoa(offset(menuitem) || selector(menuitem), 10) )
  5012.    then return; endif
  5013.    hwnd = substr(menuitem, 9, 4)
  5014.  
  5015. compile if EPM32
  5016.    call dynalink32('PMWIN',
  5017.                    '#874',     -- Win32SetWindowBits
  5018.                     hwnd          ||
  5019.                     atol(-2)      ||  -- QWL_STYLE
  5020.                     atol(64)      ||  -- MS_CONDITIONALCASCADE
  5021.                     atol(64) )        -- MS_CONDITIONALCASCADE
  5022. compile else
  5023.    call dynalink('PMWIN',
  5024.                  '#278',     -- WinSetWindowBits
  5025.                   substr(hwnd,3) || leftstr(hwnd,2) ||
  5026.                   atoi(-2)      ||  -- QWL_STYLE
  5027.                   atol_swap(64) ||  -- MS_CONDITIONALCASCADE
  5028.                   atol_swap(64) )   -- MS_CONDITIONALCASCADE
  5029. compile endif
  5030.    if defmenuid<>'' then  -- Default menu item
  5031.       call windowmessage(1,
  5032.                          ltoa(hwnd,10),
  5033.                          1074,                  -- x432, MM_SETDEFAULTITEMID
  5034.                          defmenuid, 0)  -- Make arg(2) the default menu item
  5035.    endif
  5036. ; endif
  5037.  
  5038. compile if 0
  5039. defc QueryHLP = sayerror '"'QueryCurrentHLPFiles()'"'
  5040. defproc QueryCurrentHLPFiles()
  5041.    universal CurrentHLPFiles;
  5042.    return CurrentHLPFiles;
  5043.  
  5044. defc setHLP = sayerror '"'SetCurrentHLPFiles(arg(1))'"'
  5045. defproc SetCurrentHLPFiles(newlist)
  5046.    universal CurrentHLPFiles;
  5047.    hwndHelpInst = windowmessage(1,  getpminfo(APP_HANDLE),
  5048.  compile if EPM32
  5049.                       5429,      -- EPM_Edit_Query_Help_Instance
  5050.  compile else
  5051.                       5139,      -- EPM_QueryHelpInstance
  5052.  compile endif -- EPM32
  5053.                       0,
  5054.                       0)
  5055.    if hwndHelpInst==0 then
  5056.       -- there isn't a help instance deal with.
  5057.       return "No Help Instance";
  5058.    endif
  5059.  
  5060.    newlist2 = newlist || chr(0);
  5061.    retval = windowmessage(1,  hwndHelpInst,
  5062.                        557,    -- HM_SET_HELP_LIBRARY_NAME
  5063.                        ltoa(offset(newlist2) || selector(newlist2), 10),
  5064.                        0)
  5065.    if retval==0 then
  5066.       -- it worked, now remember what you told it.
  5067.       CurrentHLPFiles = newlist;
  5068.    else
  5069.       -- failed for some reason, anyway, we had better revert to
  5070.       --   the previous version of the HLP list.
  5071.       if CurrentHLPFiles=="" then
  5072.          CurrentHLPFiles = " ";
  5073.       endif
  5074.       newlist2 = CurrentHLPFiles || chr(0);
  5075.       retval2 = windowmessage(1,  hwndHelpInst,
  5076.                           557,    -- HM_SET_HELP_LIBRARY_NAME
  5077.                           ltoa(offset(newlist2) || selector(newlist2), 10),
  5078.                           0)
  5079.       if retval2==0 then
  5080.          -- whew, we were able to revert to the old list
  5081.          return retval;
  5082.       else
  5083.          return "two errors" retval retval2;
  5084.       endif
  5085.    endif
  5086.  
  5087. compile endif
  5088.  
  5089. compile if KEEP_CURSOR_ON_SCREEN & EVERSION >= 5.60
  5090. -- This should move the cursor at the end of every scroll bar action.  The
  5091. -- position to which it is moved should correspond to the location of the
  5092. -- cursor (relative to the window) at the time when the scroll began.
  5093.  
  5094. defc processendscroll
  5095.    universal beginscroll_x, beginscroll_y;
  5096.    .cursorx = beginscroll_x;
  5097.    .cursory = beginscroll_y;
  5098.    if not .line & .last then .lineg=1; endif
  5099.  
  5100. defc processbeginscroll
  5101.    universal beginscroll_x, beginscroll_y;
  5102.    beginscroll_x = .cursorx;
  5103.    beginscroll_y = .cursory;
  5104. compile endif  -- KEEP_CURSOR_ON_SCREEN & EVERSION >= 5.60
  5105.  
  5106. compile if EVERSION >= 5.60
  5107. defc setpresparam
  5108.    universal statfont, msgfont
  5109.    universal vSTATUSCOLOR, vMESSAGECOLOR, vDESKTOPColor
  5110.    parse value arg(1) with whichctrl " hwnd="hwnd " x="x "y="y rest
  5111.    if (whichctrl=="STATFONTSIZENAME") or (whichctrl=="MSGFONTSIZENAME") then
  5112.       parse value rest with "string="psize"."facename"."attr
  5113.       -- psize is pointsize, facename is facename, attr is "Bold" etc
  5114.       "setstatface" hwnd facename
  5115.       "setstatptsize" hwnd psize
  5116.       if leftstr(whichctrl,1)='S' then  -- "STATFONTSIZENAME"
  5117.          statfont = substr(rest,8)
  5118.       else                              -- "MSGFONTSIZENAME"
  5119.          msgfont = substr(rest,8)
  5120.          sayerror MESSAGELINE_FONT__MSG
  5121.       endif
  5122.    elseif (whichctrl=="STATFGCOLOR") or (whichctrl=="MSGFGCOLOR") then
  5123.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5124.       call windowmessage(0,  hwnd,
  5125.                          4099,      -- STATWNDM_SETCOLOR
  5126.                          clrattr,
  5127.                          oldbgattr)
  5128.       if leftstr(whichctrl,1)='M' then
  5129.          sayerror MESSAGELINE_FGCOLOR__MSG
  5130.          vMESSAGECOLOR = clrattr + 16 * oldbgattr
  5131.       else
  5132.          vSTATUSCOLOR = clrattr  + 16 * oldbgattr
  5133.       endif
  5134.    elseif (whichctrl=="STATBGCOLOR") or (whichctrl=="MSGBGCOLOR") then
  5135.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5136.       call windowmessage(0,  hwnd,
  5137.                          4099,      -- STATWNDM_SETCOLOR
  5138.                          oldfgattr,
  5139.                          clrattr)
  5140.       if leftstr(whichctrl,1)='M' then
  5141.          sayerror MESSAGELINE_BGCOLOR__MSG
  5142.          vMESSAGECOLOR = clrattr * 16 + oldfgattr
  5143.       else
  5144.          vSTATUSCOLOR = clrattr  * 16 + oldfgattr
  5145.       endif
  5146.    elseif (whichctrl=="EDITBGCOLOR") then
  5147.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5148.       map_point 5, x, y, off, comment;  -- map screen to line
  5149.       if x<1 | x>.last then
  5150.          vDESKTOPColor = clrattr
  5151.          call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 5497, clrattr, 0)
  5152.       else
  5153.          .textcolor = (.textcolor // 16) + 16 * clrattr;
  5154.       endif
  5155.    elseif (whichctrl=="EDITFGCOLOR") then
  5156.       parse value rest with "rgb="rgb "clrattr="clrattr "oldfgattr="oldfgattr "oldbgattr="oldbgattr
  5157.       .textcolor = .textcolor - (.textcolor // 16) + clrattr;
  5158.    elseif whichctrl=="EDITFONTSIZENAME" then
  5159.       parse value rest with "string="psize"."facename"."attr
  5160.       -- psize is pointsize, facename is facename, attr is "Bold" etc
  5161.       fontsel = 0
  5162.       do while attr<>''
  5163.          parse value attr with thisattr '.' attr
  5164.          if     thisattr='Italic'     then fontsel = fontsel + 1
  5165.          elseif thisattr='Underscore' then fontsel = fontsel + 2
  5166.          elseif thisattr='Outline'    then fontsel = fontsel + 8
  5167.          elseif thisattr='Strikeout'  then fontsel = fontsel + 16
  5168.          elseif thisattr='Bold'       then fontsel = fontsel + 32
  5169.          endif
  5170.       enddo
  5171.       .font = registerfont(facename ,psize, fontsel)
  5172.    else
  5173.       sayerror UNKNOWN_PRESPARAM__MSG  whichctrl
  5174.       return;
  5175.    endif
  5176. ;   sayerror "set presparm with" hwnd " as the window" arg(1);
  5177.  
  5178. defc setstatface
  5179.    parse value arg(1) with hwnd face
  5180.    return windowmessage(0,  hwnd /*getpminfo(EPMINFO_EDITFRAME)*/,   -- Post message to edit client
  5181.                         4104,        -- STATWNDM_PREFFONTFACE
  5182.                         put_in_buffer(face),
  5183.                         1);  -- COMMAND_FREESEL
  5184.  
  5185. defc setstatptsize
  5186.    parse value arg(1) with hwnd ptsize
  5187.    if leftstr(ptsize, 1) = 'D' then  -- Decipoints
  5188.       parse value ptsize with 'DD' ptsize 'HH'
  5189.       parse value ptsize with ptsize 'WW'
  5190.       ptsize = ptsize % 10   -- convert decipoints to points
  5191.    endif
  5192.    return windowmessage(0,  hwnd /*getpminfo(EPMINFO_EDITFRAME)*/,   -- Post message to edit client
  5193.                         4106,        -- STATWNDM_PREFFONTPTSIZE
  5194.                         ptsize,
  5195.                         0);
  5196.  
  5197. compile endif  -- EVERSION >= 5.60
  5198.  
  5199. compile if EPM32
  5200. defproc Thunk(pointer)
  5201.   return atol_swap(dynalink32(E_DLL,
  5202.                               'FlatToSel',
  5203.                               pointer, 2) )
  5204. compile endif -- EPM32
  5205.  
  5206. compile if not EXTRA_EX
  5207. include 'EPM_EA.E'
  5208. compile endif
  5209.  
  5210. defc echoback
  5211.    parse arg postorsend hwnd messageid mp1 mp2 .
  5212.    call windowmessage(postorsend,
  5213.                       hwnd,
  5214.                       messageid,
  5215.                       mp1,
  5216.                       mp2)
  5217.  
  5218. compile if WANT_TOOLBAR
  5219. ;  load_actions
  5220. ;     This defc is called by the etke*.dll to generate the list of actions
  5221. ;     for UCMENUS in the hidden file called actlist.
  5222. ;     If called with a pointer parameter a buffer is create in which
  5223. ;     the list of actions are placed. If called without any parameter
  5224. ;     the actlist file is generated.
  5225. ;     John Ponzo 8/93
  5226. ;     Optimized by LAM
  5227.  
  5228. defc load_actions
  5229.    universal ActionsList_FileID
  5230.  
  5231. ;Keep track of the active file
  5232.    getfileid ActiveFileID
  5233.  
  5234. ;See if the actlist file is already loaded, if not load it
  5235. ;; getfileid ActionsList_FileID, 'actlist'
  5236.  
  5237.    if ActionsList_FileID <> '' then  -- Make sure it's still loaded.
  5238.       rc = 0
  5239.       display -2
  5240.       activatefile ActionsList_FileID
  5241.       display 2
  5242.       if rc=-260 then ActionsList_FileID = ''; endif
  5243.    endif
  5244.  
  5245.    if ActionsList_FileID == '' then  -- Must create
  5246.       'xcom e /c actlist'
  5247.       if rc<>-282 then  -- sayerror('New file')
  5248.          sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  5249.          return
  5250.       endif
  5251.       getfileid ActionsList_FileID
  5252.       .visible = 0
  5253.  
  5254. ;load the actions.lst file which contain the names of all the EX modules
  5255. ;that have UCMENU actions defined.
  5256.       getfileid ActionsEXModuleList_FileID, 'actions.lst'
  5257.  
  5258.       if ActionsEXModuleList_FileID == '' then
  5259.          findfile destfilename, 'actions.lst', '','D'
  5260.          if rc=-2 then  -- "File not found"
  5261.             'xcom e /c actions.lst'
  5262.             deleteline 1
  5263.             .modify = 0
  5264.          else
  5265.             'e' destfilename
  5266.             if rc then
  5267.                sayerror ERROR__MSG rc '"'destfilename'"' sayerrortext(rc)
  5268.                return
  5269.             endif
  5270.          endif
  5271.          getfileid ActionsEXModuleList_FileID
  5272. ;;       ActionsEXModuleList_FileID.visible = 0
  5273.          quit_list = 1
  5274.       else
  5275.          quit_list = 0
  5276.       endif
  5277. ;load all the EX Modules in actlist.lst, and call EX modules
  5278. ;actionlist defc.
  5279.       for i = 1 to ActionsEXModuleList_FileID.last
  5280.          getline  exmodule, i, ActionsEXModuleList_FileID
  5281.          not_linked = linked(exmodule) < 0
  5282.          if not_linked then
  5283.             link exmodule
  5284.             if rc<0 then
  5285.                sayerror 'Load_Actions:  'sayerrortext(rc) '-' exmodule
  5286.                not_linked = 0  -- Don't try to unlink it.
  5287.             endif
  5288.          endif
  5289.          exmodule'_actionlist'
  5290.          if not_linked then
  5291.             'unlink' exmodule
  5292.          endif
  5293.       endfor
  5294.       if quit_list then
  5295.          activatefile ActionsEXModuleList_FileID
  5296.          'quit'
  5297.       endif
  5298.    endif  -- ActionsList_FileID == ''
  5299.  
  5300. ;if called with a parameter send EFRAME_ACTIONSLIST message to the frame
  5301. ;of the edit window. mp1 is a buffer containing all of the actions loaded
  5302. ;in the hidden file actlist.
  5303.    if arg(1)  then
  5304.       activatefile ActionsList_FileID
  5305.       buflen = filesize() + .last + 1
  5306.       bufhandle = buffer(CREATEBUF, '', buflen, 1)
  5307.       if not bufhandle then sayerror 'CREATEBUF' ERROR_NUMBER__MSG RC; return; endif
  5308.       call buffer(PUTBUF, bufhandle, 1, ActionsList_FileID.last, NOHEADER+FINALNULL+APPENDCR)
  5309.       if word(arg(1),1) <> 'ITEMCHANGED' then
  5310.          windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5913, bufhandle, arg(1))
  5311.       else
  5312.          windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5918, bufhandle, subword(arg(1),2))
  5313.       endif
  5314.    endif
  5315.    activatefile ActiveFileID
  5316.  
  5317. ;  ExecuteAction
  5318. ;     This defc is called to resolve UCMENU actions.
  5319. ;     It is called with the first parameter being the action name,
  5320. ;     and the second parameter being an action sub-op.
  5321. ;     If the action (Which is a Defc) is not defined the actions list
  5322. ;     is generated in order to try resolving the defc.
  5323.  
  5324. defc ExecuteAction
  5325.    universal ActionsList_FileID
  5326.    parse arg DefcModule DefcName DefcParameter
  5327. ;sayerror 'executeaction: "'arg(1)'"'
  5328.  
  5329.    if DefcName='*' then
  5330.       DefcParameter
  5331.    else
  5332.       if defcmodule<>'*' then
  5333.          if linked(defcmodule) < 0 then
  5334.             link defcmodule
  5335.          endif
  5336.       endif
  5337.       if isadefc(DefcName) then
  5338. ;sayerror 'executeaction: executing cmd "'DefcName'" with parm "'DefcParameter'"'
  5339.          DefcName DefcParameter
  5340.       else
  5341.         sayerror UNKNOWN_ACTION__MSG DefcName
  5342.       endif
  5343.    endif
  5344.  
  5345. compile if 0 -- No longer used
  5346. defc load_toolbar
  5347.    call list_toolbars(LOAD_TOOLBAR__MSG, SELECT_TOOLBAR__MSG, 7000, 5916)
  5348.  
  5349. defproc list_toolbars(list_title, list_prompt, help_panel, msgid)
  5350.    universal app_hini, toolbar_loaded
  5351.  compile if EPM32
  5352. ;  l = dynalink32('PMSHAPI',
  5353. ;                 '#115',               -- PRF32QUERYPROFILESTRING
  5354. ;                 atol(app_hini)    ||  -- HINI_PROFILE
  5355. ;                 address(App)      ||  -- pointer to application name
  5356. ;                 atol(0)           ||  -- Key name is NULL; returns all keys
  5357. ;                 atol(0)           ||  -- Default return string is NULL
  5358. ;                 address(inidata)  ||  -- pointer to returned string buffer
  5359. ;                 atol(1600), 2)        -- max length of returned string
  5360.    inidata = queryprofile(app_hini, INI_UCMENU_APP, '')
  5361.    l = length(inidata)
  5362.  compile else
  5363.    App = INI_UCMENU_APP\0
  5364.    inidata = copies(' ',1600)
  5365.    l =  dynalink( 'PMSHAPI',
  5366.                   'PRFQUERYPROFILESTRING',
  5367.                   atol_swap(app_hini) ||  -- HINI_PROFILE
  5368.                   address(App)        ||  -- pointer to application name
  5369.                   atol(0)             ||  -- Key name is NULL; returns all keys
  5370.                   atol(0)             ||  -- Default return string is NULL
  5371.                   address(inidata)    ||  -- pointer to returned string buffer
  5372.                   atol_swap(1600))        -- max length of returned string
  5373.    inidata=leftstr(inidata,l)
  5374.  compile endif
  5375.  
  5376.    if not l then sayerror NO_TOOLBARS__MSG; return; endif
  5377.    getfileid startfid
  5378.    'xcom e /c /q tempfile'
  5379.    if rc<>-282 then  -- sayerror('New file')
  5380.       sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  5381.       return
  5382.    endif
  5383.    .autosave = 0
  5384.    browse_mode = browse()     -- query current state
  5385.    if browse_mode then call browse(0); endif
  5386.    do while inidata<>''
  5387.       parse value inidata with menuname \0 inidata
  5388.       insertline menuname, .last+1
  5389.    enddo
  5390.    if browse_mode then call browse(1); endif  -- restore browse state
  5391.    if listbox_buffer_from_file(startfid, bufhndl, noflines, usedsize) then return; endif
  5392. ;compile if POWERPC
  5393. ;  parse value listbox(list_title, \0 || atol(usedsize) || atol(bufhndl+32),
  5394. ;compile else
  5395.    parse value listbox(list_title, \0 || atol(usedsize) || atoi(32) || atoi(bufhndl),
  5396. ;compile endif
  5397.                        '/'OK__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0,
  5398.                        gethwndc(APP_HANDLE) || atoi(1) || atoi(1) || atoi(help_panel) ||
  5399.                        list_prompt) with button 2 menuname \0
  5400.    call buffer(FREEBUF, bufhndl)
  5401.    if button<>\1 then return; endif
  5402.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), msgid, app_hini, put_in_buffer(menuname))
  5403.    if msgid = 5916 then
  5404.       toolbar_loaded = menuname
  5405.    endif
  5406.  
  5407. defc delete_toolbar
  5408.    call list_toolbars(DELETE_TOOLBAR__MSG, SELECT_TOOLBAR__MSG, 7001, 5919)
  5409. compile endif
  5410.  
  5411. defc save_toolbar
  5412.    universal app_hini, appname
  5413.    universal toolbar_loaded
  5414.    tb = toolbar_loaded
  5415.    if tb=\1 then
  5416.       tb=''
  5417.    endif
  5418.    parse value entrybox(SAVEBAR__MSG,'/'SAVE__MSG'/'Cancel__MSG'/'Help__MSG'/',tb,'',200,
  5419.           atoi(1) || atoi(7010) || gethwndc(APP_HANDLE) ||
  5420.           SAVEBAR_PROMPT__MSG) with button 2 menuname \0
  5421.    if button <> \1 then return; endif
  5422.    if menuname='' then
  5423.       sayerror NOTHING_ENTERED__MSG
  5424.       return
  5425. ;     menuname = 'Default'
  5426. ;     call setprofile(app_hini, appname, INI_DEF_TOOLBAR, '')
  5427.    endif
  5428.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5915, app_hini, put_in_buffer(menuname))
  5429.    toolbar_loaded = menuname
  5430.  
  5431. defc loaddefaulttoolbar
  5432.    universal activeucmenu, toolbar_loaded
  5433.    if activeucmenu = 'Toolbar' then  -- Already used, delete it to be safe.
  5434.       deletemenu activeucmenu
  5435.    else
  5436.       activeucmenu = 'Toolbar'
  5437.    endif
  5438.  compile if defined(MY_DEFAULT_TOOLBAR_FILE) & not VANILLA -- Primarily for NLS support...
  5439.    include MY_DEFAULT_TOOLBAR_FILE  -- Should contain only lines like the following:
  5440.  compile elseif WANT_TINY_ICONS
  5441. ;                             # Button text # Button bitmap # command # parameters # .ex file
  5442.    buildsubmenu activeucmenu,  1, "#Add File#1131#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5443.    buildsubmenu activeucmenu,  2, "#Save#1130#a_save##sampactn", '', 0, 0
  5444.    buildsubmenu activeucmenu,  3, "#Print#1133#a_print##sampactn", '', 0, 0  -- print.bmp
  5445.    buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5446.    buildsubmenu activeucmenu,  5, "#MonoFont#1151#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5447.    buildsubmenu activeucmenu,  6, "#Style#1147#apply_style##stylebut", '', 0, 0  -- style.bmp
  5448.    buildsubmenu activeucmenu,  7, "#UnStyle#1148#remove_style##stylebut", '', 0, 0  -- style.bmp
  5449.    buildsubmenu activeucmenu,  8, "#Attribs#1152#fonts_attribs##fonts", '', 0, 0  -- attribs.bmp
  5450.    buildmenuitem activeucmenu,  8, 80, "#Bold#1124#fonts_bold##fonts", '', 0, 0  -- bold.bmp
  5451.    buildmenuitem activeucmenu,  8, 81, "#Italic#1123#fonts_italic##fonts", '', 0, 0  -- italic.bmp
  5452.    buildmenuitem activeucmenu,  8, 82, "#Under#1122#fonts_underline##fonts", '', 0, 0  -- undrline.bmp
  5453.    buildmenuitem activeucmenu,  8, 83, "#Strike#1121#fonts_strikeout##fonts", '', 0, 0  -- strikout.bmp
  5454.    buildmenuitem activeucmenu,  8, 84, "#Outline#1120#fonts_outline##fonts", '', 0, 0  -- outline.bmp
  5455.    buildsubmenu activeucmenu,  9, '', '', 16401, 0  -- MIS_SPACER
  5456.    buildsubmenu activeucmenu, 10, "#Search#1138#a_SearchDlg##sampactn", '', 0, 0  -- search.bmp
  5457.    buildsubmenu activeucmenu, 11, "#Undo#1134#a_UndoDlg##sampactn", '', 0, 0  -- undo.bmp
  5458.    buildsubmenu activeucmenu, 12, '', '', 16401, 0  -- MIS_SPACER
  5459.    buildsubmenu activeucmenu, 13, "#Shell#1153#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5460.  compile else
  5461. ;                             # Button text # Button bitmap # command # parameters # .ex file
  5462.    buildsubmenu activeucmenu,  1, "#Add File#1116#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5463.    buildsubmenu activeucmenu,  2, "#Save#1117#a_save##sampactn", '', 0, 0
  5464.    buildsubmenu activeucmenu,  3, "#Print#1113#a_print##sampactn", '', 0, 0  -- print.bmp
  5465.    buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5466.    buildsubmenu activeucmenu,  5, "#MonoFont#1106#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5467.    buildsubmenu activeucmenu,  6, "#Style#1112#apply_style##stylebut", '', 0, 0  -- style.bmp
  5468.    buildsubmenu activeucmenu,  7, "#UnStyle#1128#remove_style##stylebut", '', 0, 0  -- style.bmp
  5469.    buildsubmenu activeucmenu,  8, "#Attribs#1119#fonts_attribs##fonts", '', 0, 0  -- attribs.bmp
  5470.    buildmenuitem activeucmenu,  8, 80, "#Bold#1124#fonts_bold##fonts", '', 0, 0  -- bold.bmp
  5471.    buildmenuitem activeucmenu,  8, 81, "#Italic#1123#fonts_italic##fonts", '', 0, 0  -- italic.bmp
  5472.    buildmenuitem activeucmenu,  8, 82, "#Under#1122#fonts_underline##fonts", '', 0, 0  -- undrline.bmp
  5473.    buildmenuitem activeucmenu,  8, 83, "#Strike#1121#fonts_strikeout##fonts", '', 0, 0  -- strikout.bmp
  5474.    buildmenuitem activeucmenu,  8, 84, "#Outline#1120#fonts_outline##fonts", '', 0, 0  -- outline.bmp
  5475.    buildsubmenu activeucmenu,  9, '', '', 16401, 0  -- MIS_SPACER
  5476.    buildsubmenu activeucmenu, 10, "#Search#1115#a_SearchDlg##sampactn", '', 0, 0  -- search.bmp
  5477.    buildsubmenu activeucmenu, 11, "#Undo#1114#a_UndoDlg##sampactn", '', 0, 0  -- undo.bmp
  5478.    buildsubmenu activeucmenu, 12, '', '', 16401, 0  -- MIS_SPACER
  5479.    buildsubmenu activeucmenu, 13, "#Shell#1118#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5480.  compile endif -- WANT_TINY_ICONS
  5481.  
  5482. ; buildsubmenu activeucmenu,  1, "#Open#1102#a_Add_File##sampactn", '', 0, 0  -- EPM.bmp
  5483. ; buildsubmenu activeucmenu,  2, "#Print#1113#a_print##sampactn", '', 0, 0
  5484. ; buildsubmenu activeucmenu,  3, "#Shell#1109#a_Shell##sampactn", '', 0, 0  -- epmshell.bmp
  5485. ; buildsubmenu activeucmenu,  4, '', '', 16401, 0  -- MIS_SPACER
  5486. ; buildsubmenu activeucmenu,  5, "#Style#1112#apply_style##stylebut", '', 0, 0  -- style.bmp
  5487. ; buildsubmenu activeucmenu,  6, "#MonoFont#1106#a_MonoFont##sampactn", '', 0, 0  -- monofont.bmp
  5488. ; buildsubmenu activeucmenu,  7, "#Reflow#1107#reflow_prompt##reflow", '', 0, 0  -- reflow.bmp
  5489. ; buildsubmenu activeucmenu,  8, '', '', 16401, 0  -- MIS_SPACER
  5490. ; buildsubmenu activeucmenu,  9, "#Msgs#1100#a_Messages##sampactn", '', 0, 0  -- info.bmp
  5491. ; buildsubmenu activeucmenu, 10, "#List Ring#1110#a_List_Ring##sampactn", '', 0, 0  -- ringlist.bmp
  5492.  
  5493. ;;buildsubmenu activeucmenu, 11, "#Add New#1101#a_Add_New##sampactn", '', 0, 0  -- EPMadd.bmp
  5494. ;;buildsubmenu activeucmenu, 12, "#NewWind#1103#a_NewWindow##sampactn", '', 0, 0  -- newwindw.bmp
  5495. ;;buildsubmenu activeucmenu, 13, "#Settings#1104#a_Settings##sampactn", '', 0, 0  -- settings.bmp
  5496. ;;buildsubmenu activeucmenu, 14, "#Time#1105#a_Time##sampactn", '', 0, 0  -- clock.bmp
  5497. ;;buildsubmenu activeucmenu, 15, "#Jot#1108#jot_a_note##jot", '', 0, 0  -- idea.bmp
  5498. ;;buildsubmenu activeucmenu, 16, "#Tree#1111#tree_action##tree", '', 0, 0  -- tree.bmp
  5499. ;;buildsubmenu activeucmenu, 17, "#KwdHilit#kwdhilit.bmp#a_togl_hilit##sampactn", '', 0, 0
  5500.  
  5501.   showmenu activeucmenu, 3
  5502.   toolbar_loaded = \1
  5503.  
  5504. defc deletetemplate
  5505.    universal app_hini
  5506.    parse arg template_name
  5507. ;  if template_name='' then
  5508. ;     template_name = 'Default'
  5509. ;  endif
  5510.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5919, app_hini, put_in_buffer(template_name))
  5511.  
  5512.  compile if INCLUDE_STD_MENUS
  5513. defc toggle_toolbar
  5514.    universal toolbar_loaded
  5515.   compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  5516.    fon = queryframecontrol(EFRAMEF_TOOLBAR)  -- Query now, since toggling is asynch.
  5517.   compile endif  -- WANT_NODISMISS_MENUS
  5518.    'toggleframe' EFRAMEF_TOOLBAR
  5519.   compile if WANT_NODISMISS_MENUS & not defined(STD_MENU_NAME)
  5520.    SetMenuAttribute( 430, 8192, fon)
  5521.   compile endif  -- WANT_NODISMISS_MENUS
  5522.    if not toolbar_loaded then
  5523.       'default_toolbar'
  5524.    endif
  5525.  compile endif  -- INCLUDE_STD_MENUS
  5526.  
  5527. defc default_toolbar
  5528.    universal app_hini, appname, toolbar_loaded
  5529.  compile if WPS_SUPPORT
  5530.    universal wpshell_handle
  5531.    if wpshell_handle then
  5532.       newtoolbar = peekz(peek32(wpshell_handle, 80, 4))
  5533.       if newtoolbar='' then
  5534.          newtoolbar = \1
  5535.       endif
  5536.       if toolbar_loaded <> newtoolbar then
  5537.          toolbar_loaded = newtoolbar
  5538.          if toolbar_loaded = \1 then
  5539.             'loaddefaulttoolbar'
  5540.          else
  5541.             call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(toolbar_loaded))
  5542.          endif
  5543.       else  -- Else we're already set up; make sure toolbar is turned on
  5544.          'toggleframe' EFRAMEF_TOOLBAR 1
  5545.       endif
  5546.    else
  5547.  compile endif
  5548.       def_tb = queryprofile(app_hini, appname, INI_DEF_TOOLBAR)
  5549. ;     if def_tb = '' then def_tb = 'Default'; endif
  5550.       if def_tb <> '' then
  5551.          newcmd= queryprofile(app_hini, INI_UCMENU_APP, def_tb)
  5552.       else
  5553.          newcmd = ''
  5554.       endif
  5555.       if newcmd<>'' then
  5556.          toolbar_loaded = def_tb
  5557.          call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(toolbar_loaded))
  5558.       else
  5559.          'loaddefaulttoolbar'
  5560.       endif
  5561.  compile if WPS_SUPPORT
  5562.    endif
  5563.  compile endif
  5564. compile endif -- WANT_TOOLBAR
  5565.  
  5566. compile if EPM32
  5567. defc toggle_parse
  5568.    parse arg parseon kwfilename
  5569.    if parseon & .levelofattributesupport//2=0  then  -- the first bit of .levelofattributesupport is for color attributes
  5570.       call attribute_on(1) -- toggles color attributes mode
  5571.    endif
  5572.    if kwfilename='' then
  5573.       kwfilename = 'epmkwds.c'
  5574.    endif
  5575.    if parseon then
  5576.       findfile destfilename, kwfilename, 'EPMPATH'
  5577.       if rc then
  5578.          sayerror FILE_NOT_FOUND__MSG '-' kwfilename
  5579.          return
  5580.       endif
  5581.    endif
  5582.    getfileid fid
  5583.    call windowmessage(0,  getpminfo(EPMINFO_EDITFRAME),
  5584.                    5502,               -- EPM_EDIT_TOGGLEPARSE
  5585.                    parseon,
  5586.                    put_in_buffer(fid kwfilename))
  5587.  compile if 0
  5588. defc qparse =
  5589.    c =  windowmessage(1,  getpminfo(EPMINFO_EDITFRAME),
  5590.                    5505,               -- EPM_EDIT_KW_QUERYPARSE
  5591.                    0,
  5592.                    0)
  5593.    sayerror 'Keyword parsing is' word(OFF__MSG ON__MSG, 2 - (not c))  -- Use as boolean
  5594.  compile endif
  5595.  
  5596. defc dyna_cmd =
  5597.    parse arg library entrypoint cmdargs
  5598.    if entrypoint='' then
  5599.       sayerror -257  -- "Invalid number of parameters"
  5600.       return
  5601.    endif
  5602.    rc = 0
  5603.    cmdargs = cmdargs\0
  5604.    dynarc = dynalink32(library,
  5605.                        entrypoint,
  5606.                        gethwndc(EPMINFO_EDITCLIENT) ||
  5607.                        address(cmdargs),
  5608.                        2)
  5609.  
  5610. defc dynafree =
  5611.    res = dynafree(arg(1))
  5612.    if res then
  5613.       sayerror ERROR__MSG res
  5614.    endif
  5615. compile endif  -- EPM32
  5616.