home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / epmmac / stdctrl.e < prev    next >
Text File  |  1993-08-04  |  172KB  |  3,909 lines

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