home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / editors / epm / sampmacs / stdctrl.e < prev    next >
Encoding:
Text File  |  1993-12-15  |  188.1 KB  |  4,406 lines

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