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