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