home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1992-09-02 | 139.4 KB | 3,200 lines
compile if EVERSION < 5 *** Error: This file supports EPM only, not earlier versions of E. compile endif include 'menuhelp.H' /* ╔════════════════════════════════════════════════════════════════════════════╗ ║ What's it called: stdctrl.e ║ ║ ║ ║ What does it do : contains special PM procedures and commands that enable ║ ║ the following from the EPM editor: ║ ║ ║ ║ listbox support - enables the dynamic creation of PM ║ ║ list boxes. A macro can pop up a ║ ║ list of items and have a the users ║ ║ selection returned to the macro. ║ ║ ║ ║ menu support - enables the dynamic creation and ║ ║ maintenance of named menus. ║ ║ A macro can create several menus that ║ ║ when shown and selected can execute ║ ║ editor commands. ║ ║ ║ ║ EPM - E.DLL communication : ║ ║ gives a EPM macro the ability to ║ ║ converse with EPM.EXE controls. ║ ║ For Example, popping EPM's commandline ║ ║ message dialog, etc. ║ ║ ║ ║ Who and When : Gennaro (Jerry) Cuomo 3 -88 ║ ║ ║ ╚════════════════════════════════════════════════════════════════════════════╝ */ /* ┌────────────────────────────────────────────────────────────────────────────┐ │ The following are constant values that are to be used as parameters to │ │ the getpminfo internal function or as control id's for control toggle. │ │ │ │ HAB 0 PARENTFRAME 4 EDITORMSGAREA 8 EDITVIOPS 12 │ │ OWNERCLIENT 1 EDITCLIENT 5 EDITORVSCROLL 9 EDITTITLEBAR 13 │ │ OWNERFRAME 2 EDITFRAME 6 EDITORHSCROLL 10 EDITCURSOR 14 │ │ PARENTCLIENT 3 EDITSTATUSAREA 7 EDITORINTERPRETER 11 PARTIALTEXT 15 │ │ EDITEXSEARCH 16 EDITMENUHWND 17 HDC 18 HINI 19 │ │ RINGICONS 20 FILEICONS 22 EXTRAWNDPOS 23 │ │ CursorBounce 24 CUA_marking 25 Arrows_Internal 26 │ └────────────────────────────────────────────────────────────────────────────┘ */ define compile if EVERSION >= '5.20' -- 5.20 adds a HINI to the *Profile calls. HINI_PARM = 'app_hini,' HINI_PARMU ='HINI_PROFILE,' compile else HINI_PARM = ' ' HINI_PARMU = ' ' compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ List Box Functions: │ │ │ │ listbox() │ │ listboxdemo() │ └────────────────────────────────────────────────────────────────────────────┘ */ /************************************************************************ listbox() param1 - Listbox title param2 - string of items, separated by a common separator. The common separator is the first character in the string. example: /cat/dog/fish/ separator='/' list=cat, dog, fish example: $cat/ground$fish/water$ separator='$' list=cat/ground, fish/water If this parameter starts with an x'00', then it will be assumed to represent a buffer, in the format: x'00' || atoi(length(text)) || selector(text) || offset(text) param3 - (optional) button names. A maximum of seven button names can be specified to allow multiple buttons. param4 - (optional) row of text in which list box will go under. If this parameter is not specified or if a parameter of zero (0) is specified, the box will be placed under the cursor. param5 - (optional) column of text in which list box will go under. If this parameter is not specified or if a parameter of zero (0) is specified, the box will be placed under the cursor. (NOTE: If the row parameter is selected the column parameter must be selected as well.) param6 - (optional) height of the listbox in characters (NOTE:Since the default PM font is proportional the character height and width are approximate values.) param7 - (optional) width of listbox in characters. param8 - (optional) buffer string (see below) The following procedure creates a PM list box dialog. The listbox will wait for user input and return a value that corresponds to the users input. If the user presses Enter or double clicks on an entry, that entry will be returned as the result of the listbox function. If Cancel is selected or Esc is pressed, the listbox function will return null. The listbox is a modal listbox, therefore user input is required before any thing else can happen. Jerry Cuomo 1-89 EPM 5.21 / 5.50 added some new features to the ETOOLKIT interface. Parameter 8 is used to expose this to the caller of listbox(). If present, it is a string consisting of: item# || button# || help_ID || handle || prompt where item# is the listbox entry to be initially selected, button# is the button that will be the default, help_ID is a help panel ID (all shorts), handle is the window handle of the OWNERCLIENT (needed to call help; ignored if help_ID is 0), and prompt is an ASCIIZ string to be displayed below the title bar. If help_ID is non-zero, the rightmost button is assumed to be the help button. The new parameters are passed to the toolkit in the return buffer, which is padded with nulls, so only the minimum needed string need be sent. The old way only supported returning a string if button 1 was pressed; button 2 was assumed to be Cancel, and returned null; anything else returned the button number. The new way returns one byte representing the button number (in hex) followed by the selected item. A button number of 0 means Esc was pressed or the dialog was closed. If param8 was passed, the listbox() routine returns this entire string; if not, it parses it and returns what the old callers expected. Larry Margolis / John Ponzo 6/91 ****************************************************************************/ defproc listbox(title,listbuf) if leftstr(listbuf,1)=\0 then liststuff = substr(listbuf,2,6) flags = substr(listbuf,8) else listbuf=listbuf \0 liststuff = atoi(length(listbuf)-1) || /* length of list */ selector(listbuf) || /* list */ offset(listbuf) flags = '' endif title = title \0 if arg(3)<>'' then /* button names were specified */ parse value arg(3) with delim 2 but1 (delim) but2 (delim) but3 (delim) but4 (delim) but5 (delim) but6 (delim) but7 (delim) nb=0 if but1<>'' then but1=but1\0; nb=nb+1; else sayerror 'LISTBOX:' BUTTON_ERROR__MSG; return 0; endif if but2<>'' then but2=but2\0; nb=nb+1; else but2=\0; endif if but3<>'' then but3=but3\0; nb=nb+1; else but3=\0; endif if but4<>'' then but4=but4\0; nb=nb+1; else but4=\0; endif if but5<>'' then but5=but5\0; nb=nb+1; else but5=\0; endif if but6<>'' then but6=but6\0; nb=nb+1; else but6=\0; endif if but7<>'' then but7=but7\0; nb=nb+1; else but7=\0; endif else but1=ENTER__MSG\0; but2=CANCEL__MSG\0; but3=\0; but4=\0; but5=\0 ; but6=\0; but7=\0 -- default buttons nb=2 endif if arg()>3 then /* were row and column specified */ row = arg(4); col = arg(5) /* row and col were passed */ if not row then row=.cursory-1 endif /* zero means current cursor pos */ if not col then col=.cursorx endif else col=.cursorx; row=.cursory-1 /* default: current cursor pos */ endif if arg()>5 then /* were height and width specified*/ height = arg(6) /* height was passed */ else height = 0 /* default: 0=use listbox default */ endif if arg()>6 then /* were height and width specified*/ width = arg(7) /* width was passed */ else width = 0 /* default: 0=use listbox default */ endif x = .fontwidth * col /* convert row and column into...*/ compile if EVERSION < 5.50 y = .windowy+.fontheight*(screenheight()-row-1) /* x,y coordinates in pels */ compile else y = .windowy+screenheight()-.fontheight*(row+1)-4 /* (Add a fudge factor temporarily */ compile endif compile if EVERSION >= 5.21 if arg()>7 then /* New way! */ selectbuf = leftstr(arg(8), 255, \0) else selectbuf = copies(\0,255) -- Was 85 /* null terminate return buffer */ endif compile else selectbuf = leftstr(\0,85) /* null terminate return buffer */ compile endif if flags='' then flags=3 -- bit 0=position below pts, bit 1=map to desktop endif call dynalink( ERES_DLL, /* list box control in EDLL dyna */ 'LISTBOX', /* function name */ gethwnd(EPMINFO_EDITFRAME) || /* edit frame handle */ atoi(flags) || atoi(x) || /* coordinates */ atoi(y) || atoi(height) || atoi(width) || atoi(nb) || selector(title) || /* list box dialog title */ offset(title) || selector(but1) || /* text to appear in buttons */ offset(but1) || selector(but2) || /* */ offset(but2) || selector(but3) || /* */ offset(but3) || selector(but4) || /* */ offset(but4) || selector(but5) || /* */ offset(but5) || selector(but6) || /* */ offset(but6) || selector(but7) || /* */ offset(but7) || liststuff || selector(selectbuf) || /* return string buffer */ offset(selectbuf) ) compile if EVERSION >= 5.21 button = asc(leftstr(selectbuf,1)) if arg(8) then return selectbuf; endif -- New way if button=0 | button=2 then return ''; endif -- Old way... if button<>1 then return button; endif EOS = pos(\0,selectbuf,2) -- CHR(0) signifies End Of String if not EOS then return 'error'; endif return substr(selectbuf,2,EOS-2) compile else EOS = pos(\0,selectbuf) -- CHR(0) signifies End Of String if not EOS then return 'error'; endif return leftstr(selectbuf,EOS-1) compile endif /*********** Sample command that uses the old list box function ********* defc listdemo select = listbox('My List','/Bryan/Jason/Jerry Cuomo/Ralph/Larry/Richard/'); if select=='' then sayerror 'Nothing Selected' else sayerror 'list box selection =<' select '>' endif **/ /*********** Sample command that uses the new list box function ********* defc listdemo sayerror 'Selected entry 3; default button 2; help panel 9300.' selectbuf = listbox('My List','/One/Two/Three', '/Go to/Delete/Cancel/Help',0,0,0,0, atoi(3) || atoi(2) || atoi(9300) || gethwnd(APP_HANDLE) || 'Prompt text'\0); button = asc(leftstr(selectbuf,1)) if button=0 then sayerror 'Nothing Selected' else EOS = pos(\0,selectbuf,2) -- CHR(0) signifies End Of String select= substr(selectbuf,2,EOS-2) sayerror 'Button' button 'was pressed; string =' select endif **/ /* ┌────────────────────────────────────────────────────────────────────────────┐ │ │ │ What's it called: EntryBox │ │ │ │ What does it do : Creates a System-Modal Dialog Box. (A System-Modal box │ │ must be processed before the function can continue.) │ │ The dialog box contains a entry field and 2 push buttons.│ │ (Up to 4 as of EPM 5.21 / 5.50. See below.) │ │ │ │ hwnd - handle of owner window │ │ title - question to appear on dialog title bar │ │ x,y - coordinates of lower left of entry box │ │ if (0,0) then centered to screen. │ │ cols - approximate number of cols in entry field │ │ in PM font characters │ │ max - maximum number of chars │ │ entry - entry field string returned │ │ │ │ Who and when : Gennaro (Jerry) Cuomo 4-89 │ │ │ └────────────────────────────────────────────────────────────────────────────┘ EPM 5.21 / 5.50 added some new features to the ETOOLKIT interface. Parameter 6 is used to expose this to the caller of entrybox(). If present, it is a string consisting of: button# || help_ID || handle || prompt See the listbox() comments to see what these represent, and what is returned. Larry Margolis / John Ponzo 6/91 */ -- entrybox title [,buttons][,entrytext][,cols][,maxchars][,param6] defproc entrybox(title) columns = arg(4) ; if columns=0 then columns=length(title); endif -- Now handled (better) internally title = title \0 nb = 2 -- default number of buttons if arg(2)<>'' then /* button names were specified */ parse value arg(2) with delim 2 but1 (delim) but2 (delim) but3 (delim) but4 (delim) ;; sayerror 'but1=<'but1'> but2=<'but2'> but3=<'but3'> but4=<'but4'>' if but1<>'' then but1=but1 \0; else sayerror 'ENTRYBOX:' BUTTON_ERROR__MSG; return 0; endif if but2<>'' then but2=but2 \0; else but2=''\0; endif if but3<>'' then but3=but3 \0;nb=3; else but3=''\0; endif if but4<>'' then but4=but4 \0;nb=4; else but4=''\0; endif else but1=\0; but2=\0; but3=\0; but4=\0 endif if arg()>2 then entrytext=arg(3) \0; else entrytext = \0; endif ;; if arg()>3 then columns =max(arg(4),1); else columns = 30; endif if columns<0 then columns = 30; endif if arg()>4 then maxchars =max(arg(5),1); else maxchars = 254; endif /* null terminate return buffer */ if arg()>5 then selectbuf = leftstr(arg(6), MAXCOL, \0) else selectbuf = copies(\0, MAXCOL) endif call dynalink( ERES_DLL, /* list box control in EDLL dyna */ 'ENTRYBOX', /* function name */ gethwnd(EPMINFO_EDITFRAME) || /* edit frame handle */ --atoi(0) || atoi(1) || selector(title) || /* */ offset(title) || atoi(0) || /* x coordinate */ atoi(0) || /* y coordinate (0,0) = center */ atoi(columns) || atoi(maxchars) || selector(entrytext) || /* (optional text in entry field)*/ offset(entrytext) || compile if EVERSION >= 5.21 atoi(nb) || /* Number of buttons */ compile endif selector(but1) || /* (optional button 1 text ) */ offset(but1) || selector(but2) || /* ( optional button 2 text ) */ offset(but2) || compile if EVERSION >= 5.21 selector(but3) || /* (optional button 3 text ) */ offset(but3) || selector(but4) || /* (optional button 4 text ) */ offset(but4) || compile endif selector(selectbuf) || /* return string buffer */ offset(selectbuf) ) compile if EVERSION >= '5.21' if arg(6) then return selectbuf; endif -- New way button = asc(leftstr(selectbuf,1)) if button=0 | button=2 then return ''; endif -- Old way... if button<>1 then return button; endif EOS = pos(\0,selectbuf,2) -- CHR(0) signifies End Of String if not EOS then return 'error'; endif return substr(selectbuf,2,EOS-2) compile else EOS = pos(\0,selectbuf) -- CHR(0) signifies End Of String if not EOS then return 'error'; endif return leftstr(selectbuf,EOS-1) compile endif /* ╔════════════════════════════════════════════════════════════════════════════╗ ║ EPM macro - EPM.EXE communication commands. ║ ║ ║ ║ togglefont - toggle from large to small to large font ║ ║ commandline - show commandline dialog [initialize with text] ║ ║ messagebox - show message dialog box [optionally add to it] ║ ║ opendlg - show open dialog box ║ ║ ║ ╚════════════════════════════════════════════════════════════════════════════╝ */ /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: togglecontrol │ │ │ │ what does it do : The command either toggles a EPM control window on or off│ │ or forces a EPM control window on or off. │ │ arg1 = EPM control window handle ID. Control window │ │ ids given above. The following windows handles │ │ are currently supported. │ │ EDITSTATUS, EDITVSCROLL, EDITHSCROLL, and │ │ EDITMSGLINE. │ │ arg2 [optional] = force option. │ │ a value of 0, forces control window off │ │ a value of 1, forces control window on │ │ IF this argument is not specified the window │ │ in question is toggled. │ │ │ │ This command is possible because of the EPM_EDIT_CONTROL │ │ EPM_EDIT_CONTROLSTATUS message. │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc togglecontrol compile if WANT_DYNAMIC_PROMPTS universal menu_prompt compile endif forceon=0 parse arg controlid fon if fon<>'' then forceon=(fon+1)*65536 endif call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5388, -- EPM_EDIT_CONTROLTOGGLE controlid + forceon, 0) compile if WANT_DYNAMIC_PROMPTS & EVERSION < 5.53 if controlid=23 then if querycontrol(controlid) then menu_prompt = 0; endif endif compile endif compile if EVERSION >= 5.53 defc toggleframe compile if WANT_DYNAMIC_PROMPTS universal menu_prompt compile endif forceon=0 parse arg controlid fon if fon<>'' then forceon=(fon+1)*65536 endif call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5907, -- EFRAMEM_TOGGLECONTROL controlid + forceon, 0) compile if WANT_DYNAMIC_PROMPTS if controlid=32 then if queryframecontrol(controlid) then menu_prompt = 0; endif endif compile endif defproc queryframecontrol(controlid) return windowmessage(1, getpminfo(EPMINFO_EDITFRAME), -- Send message to edit client 5907, -- EFRAMEM_TOGGLECONTROL controlid, 1) compile endif -- EVERSION >= 5.53 compile if WANT_DYNAMIC_PROMPTS defc toggleprompt universal menu_prompt menu_prompt = not menu_prompt if menu_prompt then compile if EVERSION < 5.53 'togglecontrol 23 0' -- Force Extra window to bottom. compile else 'toggleframe 32 0' -- Force Extra window to bottom. compile endif endif compile endif defc setscrolls compile if EVERSION >= 5.53 'toggleframe 8' 'toggleframe 16' compile else 'togglecontrol 9' 'togglecontrol 10' compile if EVERSION < '5.50' if not querycontrol(10) & not querycontrol(23) then 'togglecontrol 23 1' -- Force Extra window to top. sayerror 'Can not have info at bottom w/o scroll bars in EPM' EVERSION endif defc toggle_info 'togglecontrol 23' if not querycontrol(10) & not querycontrol(23) then 'togglecontrol 9 1' 'togglecontrol 10 1' sayerror 'Can not have info at bottom w/o scroll bars in EPM' EVERSION endif compile endif compile endif -- EVERSION >= 5.53 defproc querycontrol(controlid) return windowmessage(1, getpminfo(EPMINFO_EDITCLIENT), -- Send message to edit client 5388, -- EPM_EDIT_CONTROLTOGGLE controlid, 1) defc cursoroff=call cursoroff() -- Turn cursor off defproc cursoroff -- Turn cursor off 'togglecontrol 14 0' ; Trim window so it's an exact multiple of the font size. defc trim=call windowsize1(.windowheight,.windowwidth,0,0,1) defc windowsize1 parse arg row col x y flag junk if x='' | junk<>'' then sayerror -263 -- Invalid argument else call windowsize1(row,col,x,y,flag) endif defproc windowsize1(row,col,x,y) if upcase(leftstr(row,1))='P' then -- Already in pels cy = substr(row,2) else cy = .fontheight * row -- convert row into y coordinate in pels endif if upcase(leftstr(col,1))='P' then -- Already in pels cx = substr(col,2) else cx = .fontwidth * col -- convert col into x coordinate in pels endif if arg(5)<>'' then opts=arg(5); else opts=3; endif -- Default = SWP_SIZE (1) + SWP_MOVE (2) if opts // 2 then -- Don't bother calculating unless SWP_SIZE on swp1 = '??????????????????' call dynalink('PMWIN', 'WINQUERYWINDOWPOS', gethwnd(EPMINFO_EDITCLIENT) || selector(swp1) || offset(swp1) ) swp2 = '??????????????????' call dynalink('PMWIN', 'WINQUERYWINDOWPOS', gethwnd(EPMINFO_EDITFRAME) || selector(swp2) || offset(swp2) ) cx = cx + itoa(substr(swp2,5,2),10) - itoa(substr(swp1,5,2),10) cy = cy + itoa(substr(swp2,3,2),10) - itoa(substr(swp1,3,2),10) endif call dynalink( 'PMWIN', 'WINSETWINDOWPOS', gethwnd(EPMINFO_EDITFRAME) || atoi(0) || atoi(3) || /* HWND_TOP */ atoi(x) || atoi(y) || atoi(cx) || atoi(cy) || atoi(opts)) /* SWP_MOVE | SWP_SIZE */ compile if 0 -- Unused, so don't waste space. LAM defc qcontrol if querycontrol(arg(1)) then sayerror 'control on' else sayerror 'control off' endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: fontlist │ │ │ │ what does it do : Display a listbox containing the possible font cell sizes│ │ for the particular display type being used. │ │ The font dimensions are extracted from the fontlist str. │ │ │ │ who and when : Jerry C. 11/04/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ compile if EVERSION < 5.50 -- AVIO version defc fontlist compile if EVERSION >= 5.20 -- 5.20 beta 5; added a change font dialog. call windowmessage(0, getpminfo(APP_HANDLE), 5138, -- EPM_POPAVIOFONTDIALOG 0, .fontwidth*65536 + .fontheight ) compile else fontlist= '/1. 8 x 14 (Large) '|| '/2. 8 x 8 (Small) ' if dos_version()>=1020 then compile if EVERSION < 5.20 fontlist= '/8. 12 x 30 (Large)'|| '/7. 12 x 22' || '/6. 12 x 20' || '/5. 12 x 16' || '/4. 8 x 17 (Medium) '|| '/3. 8 x 8' || '/2. 7 x 25' || '/1. 7 x 15 (Small)' compile else outcount = atol(248) -- Room for 31 pairs of longs outdata = copies(' ',248) r = dynalink( 'PMGPI', -- Returns 1 if OK; 0 if not implemented; -1 if error 'DEVESCAPE', gethwnd(EPMINFO_HDC) || atol_swap(2) || -- DEVESC_QUERYVIOCELLSIZES atol(0) || -- incount atol(0) || -- indata selector(outcount) || offset(outcount) || selector(outdata) || offset(outdata) ) if r=1 then n = ltoa(substr(outdata,5,4),10) fontlist = '' do i = (n*8+1) to 9 by -8 fontlist = fontlist'/'n'.' ltoa(substr(outdata,i,4),10) 'x' ltoa(substr(outdata,i+4,4),10) n=n-1 enddo endif compile endif endif do forever retvalue=listbox(FONTLIST_PROMPT__MSG .fontwidth 'x' .fontheight,fontlist,'/'SELECT__MSG'/'CANCEL__MSG'/'HELP__MSG,2,screenwidth()/2) if retvalue<>3 then leave; endif 'helpmenu 6010' enddo if retvalue then parse value retvalue with . width . height . -- sayerror 'height and width =('height','width')' call setfont(width, height) endif compile endif compile else -- GPI version defc fontlist call windowmessage(0, getpminfo(APP_HANDLE), 5130, -- EPM_POPFONTDLG put_in_buffer(queryfont(.font)'.'trunc(.textcolor//16)'.'.textcolor%16), 0) defc processfontrequest universal default_font parse value arg(1) with fontname '.' fontsize '.' fontsel '.' setfont '.' markedonly '.' fg '.' bg -- sayerror 'Fontname=' fontname ' Fontsize=' fontsize 'Fontsel=' fontsel fontid=registerfont(fontname, fontsize, fontsel) if setfont & not markedonly then call setini( INI_FONT, fontname'.'fontsize'.'fontsel, 1) default_font = fontid endif if markedonly then -- insert font attribute within marked area only! themarktype = marktype() if not themarktype then /* check if mark exists */ sayerror NO_MARK__MSG return /* if mark doesn't exist, return */ endif getmark fstline, /* returned: first line of mark */ lstline, /* returned: last line of mark */ fstcol, /* returned: first column of mark */ lstcol, /* returned: last column of mark */ mkfileid /* returned: file id of marked file */ if fontid <> .font then call attribute_on(4) -- Mixed fonts flag addfont = 1 else addfont = .levelofattributesupport%4 - 2*(.levelofattributesupport%(8)) endif if bg<>'' then fg = bg*16+fg call attribute_on(1) -- Colors flag endif if themarktype='BLOCK' then do i = fstline to lstline if addfont then Insert_Attribute_Pair(16, fontid, i, i, fstcol, lstcol, mkfileid) endif if bg<>'' then Insert_Attribute_Pair(1, fg, i, i, fstcol, lstcol, mkfileid) endif enddo else if themarktype='LINE' then getline line, lstline, mkfileid lstcol=length(line) endif if addfont then Insert_Attribute_Pair(16, fontid, fstline, lstline, fstcol, lstcol, mkfileid) endif if bg<>'' then Insert_Attribute_Pair(1, fg, fstline, lstline, fstcol, lstcol, mkfileid) endif endif call attribute_on(8) -- "Save attributes" flag else .font = fontid endif defc Process_Style universal app_hini universal EPM_utility_array_ID call checkmark() -- verify there is a marked area, parse arg stylename -- can include spaces stylestuff = queryprofile(app_hini, 'Style', stylename) if stylestuff='' then return; endif -- Shouldn't happen parse value stylestuff with fontname '.' fontsize '.' fontsel '.' fg '.' bg getmark fstline, lstline, fstcol, lstcol, mkfileid if get_array_value(EPM_utility_array_ID, 'sn.'stylename, styleindex) then -- See if we have an index do_array 3, EPM_utility_array_ID, 'si.0', styleindex -- Get the styleindex = styleindex + 1 -- next index do_array 2, EPM_utility_array_ID, 'si.0', styleindex -- Save next index do_array 2, EPM_utility_array_ID, 'si.'styleindex, stylename -- Save index.name do_array 2, EPM_utility_array_ID, 'sn.'stylename, styleindex -- Save name.index endif oldmod = .modify if bg<>'' then ;; fg = 256 + bg*16 + fg fg = bg*16 + fg if marktype()='BLOCK' then do i = fstline to lstline Insert_Attribute_Pair(1, fg, i, i, fstcol, lstcol, mkfileid) enddo else if marktype()='LINE' then getline line, lstline, mkfileid lstcol=length(line) endif Insert_Attribute_Pair(1, fg, fstline, lstline, fstcol, lstcol, mkfileid) endif call attribute_on(1) -- Colors flag endif if fontsel<>'' then call attribute_on(4) -- Mixed fonts flag fontid=registerfont(fontname, fontsize, fontsel) if marktype()='BLOCK' then do i = fstline to lstline Insert_Attribute_Pair(16, fontid, i, i, fstcol, lstcol, mkfileid) enddo else Insert_Attribute_Pair(16, fontid, fstline, lstline, fstcol, lstcol, mkfileid) endif endif Insert_Attribute_Pair(14, styleindex, fstline, lstline, fstcol, lstcol, mkfileid) call attribute_on(8) -- "Save attributes" flag .modify = oldmod + 1 defc ChangeStyle universal app_hini universal EPM_utility_array_ID parse arg stylename -- Can include spaces if get_array_value(EPM_utility_array_ID, 'sn.'stylename, styleindex) then return -- If not known, then we're not using it, so nothing to do. endif stylestuff = queryprofile(app_hini, 'Style', stylename) if stylestuff='' then return; endif -- Shouldn't happen parse value stylestuff with fontname '.' fontsize '.' fontsel '.' fg '.' bg getfileid startid fontid=registerfont(fontname, fontsize, fontsel) fg = bg*16 + fg do i=1 to filesinring(1) -- Provide an upper limit; prevent looping forever if not (.levelofattributesupport%8 - 2*(.levelofattributesupport%16)) then -- Is attribute 8 off? iterate -- Not using styles in this file endif -- "Save attributes" flag line=0; col=1; offst=0 do forever class = 14 -- STYLE_CLASS attribute_action 1, class, offst, col, line -- 1=FIND NEXT ATTR if class=0 then leave; endif -- not found query_attribute class, val, IsPush, offst, col, line if val=styleindex then -- If it's this style, then... offst = offst+1 query_attribute class, val, IsPush, offst, col, line if class=16 & val<>fontid then -- Replace the font ID (if changed) insert_attribute class, fontid, IsPush, offst, col, line attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP endif offst = offst+1 query_attribute class, val, IsPush, offst, col, line if class=1 & val<>fg then -- Replace the color attribute (if changed) insert_attribute class, fg, IsPush, offst, col, line attribute_action 16, class, offst, col, line -- 16=DELETE_ATTR_SUBOP endif endif enddo -- Loop looking for STYLE_CLASS in current file next_file getfileid curfile if curfile = startid then leave; endif enddo -- Loop through all files in ring activatefile startid -- Make sure we're back where we started (in case was .HIDDEN) defc monofont parse value queryfont(.font) with fontname '.' fontsize '.' if fontname<>'Courier' & fontname<>'System Monospaced' then if rightstr(fontsize,2)='BB' then -- Bitmapped font parse value fontsize with 'DD' decipoints 'WW' width 'HH' height 'BB' if width & height then -- It's fixed pitch return endif endif .font = registerfont('System Monospaced',0,0) endif compile endif -- GPI version /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: Get_Array_Value(array_ID, array_index, value) │ │ │ │ what does it do : Looks up the index in the array, and if found, puts the │ │ value in VALUE. The result returned for the function │ │ is the return code from the array lookup - 0 if │ │ successful. If the index wasn't found, VALUE will │ │ contain the null string. │ │ │ │ who and when : Larry M. 9/12/91 │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc get_array_value(array_ID, array_index, var array_value) rc = 0 array_value = '' display -2 do_array 3, array_ID, array_index, array_value display 2 return rc defproc Insert_Attribute_Pair(attribute, val, fstline, lstline, fstcol, lstcol, fileid) ;sayerror 'Insert_Attribute_Pair('attribute',' val',' fstline',' lstline',' fstcol',' lstcol',' fileid')' class = attribute offst1 = -255 col = fstcol line = fstline pairoffst = -255 attribute_action 1, class, offst1, col, line, fileid -- 1=FIND NEXT ATTR ;sayerror 'attribute_action FIND NEXT ATTR,' class',' offst1',' col',' line',' fileid -- 1=FIND NEXT ATTR if class & col = fstcol & line = fstline then -- Found one! offst2 = offst1 attribute_action 3, class, offst2, col, line, fileid -- 3=FIND MATCH ATTR ;sayerror 'attribute_action FIND MATCH ATTR,' class',' offst2',' col',' line',' fileid -- 1=FIND NEXT ATTR if class then lc1 = lstcol + 1 if line=lstline & col=lc1 then -- beginning and end match, so replace the old attributes attribute_action 16, class, offst1, fstcol, fstline, fileid -- 16=DELETE ATTR ;sayerror 'attribute_action DELETE ATTR,' class',' offst1',' fstcol',' fstline',' fileid -- 1=FIND NEXT ATTR attribute_action 16, class, offst2, lc1, lstline, fileid -- 16=DELETE ATTR ;sayerror 'attribute_action DELETE ATTR,' class',' offst2',' lc1',' lstline',' fileid -- 1=FIND NEXT ATTR pairoffst = offst1 + 1 if not pairoffst then lstcol = lc1 endif elseif line>lstline | (line=lstline & col>lstcol) then -- old range larger then new ;sayerror 'pair offset set to 0' pairoffst = 0 -- so add attributes on the inside. lstcol = lc1 endif endif endif insert_attribute attribute, val, 1, pairoffst, fstcol, fstline, fileid insert_attribute attribute, val, 0, -pairoffst, lstcol, lstline, fileid ; Turns on the specified bit (1, 2, 4, etc.) and returns 0 or 1 depending ; on whether it was originally off or on. defproc attribute_on(bit) flag = .levelofattributesupport%bit - 2*(.levelofattributesupport%(bit*2)) if not flag then -- Is that bit off? .levelofattributesupport = .levelofattributesupport + bit -- Turn it on! endif return flag /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: setfont │ │ │ │ what does it do : Send change font message to editor. │ │ Arguments are the font cell width and the font cell │ │ height. example: setfont(7, 15) │ │ │ │ │ │ who and when : Jerry C. 11/04/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc setfont(width, height) call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), -- Post message to edit client 5381, -- EPM_EDIT_CHANGEFONT height, width) compile if EVERSION < 5.21 /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: togglefont │ │ │ │ what does it do : toggle from large to small font using by sending the │ │ current edit window a EPM_EDIT_CHANGEFONT message. │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ universals : the universal variable 'font' is used to keep track of │ │ the current font state. │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc togglefont universal font,defaultmenu compile if INCLUDE_MENU_SUPPORT if font then /* large font is active */ font = FALSE /* about to change to small*/ buildmenuitem defaultmenu, /* replace text in option..*/ 4, 408, /* menu. */ LARGE_FONT_MENU__MSG, 'togglefont'LARGE_FONT_MENUP__MSG,0,mpfrom2short(HP_OPTIONS_FONT, 0) else /* small font is active */ font = TRUE /* about to change to large*/ buildmenuitem defaultmenu, /* replace text in option..*/ 4, 408, /* menu. */ SMALL_FONT_MENU__MSG, 'togglefont'SMALL_FONT_MENUP__MSG,0,mpfrom2short(HP_OPTIONS_FONT, 0) endif showmenu defaultmenu /* activate above changes */ /* in the menu */ compile endif call setfont(0, 0) /* change font */ compile endif compile if EVERSION > 5.19 ---------------------------------------------------------------------------- ---- UNDO JAC 11/90 ---------------------------------------------------------------------------- defc processundo --undoaction 1, PresentState; --undoaction 2, OldestState; CurrentUndoState=arg(1) -- --if CurrentUndoState<OldestState then -- return --endif --sayerror 'Undoing State ' CurrentUndoState ' old='OldestState ' new='PresentState undoaction 7, CurrentUndoState; --refresh; defc restoreundo action=1 undoaction 5, action; defc renderundoinfo undoaction 1, PresentState -- Do to fix range, not for value. ; undoaction 2, OldestState; ; statestr=PresentState OldestState \0 undoaction 6, StateRange -- query range parse value staterange with oldeststate neweststate statestr=newestState oldeststate\0 action=1 undoaction 4, action -- sayerror '<'statestr'>' call windowmessage(1, arg(1), -- send message back to dialog 32, -- WM_COMMAND - 0x0020 9999, ltoa(offset(statestr) || selector(statestr), 10) ) defc undodlg ; undoaction 1, PresentState -- Do to fix range, not for value. ; undoaction 6, StateRange -- query range ; parse value staterange with oldeststate neweststate ; if oldeststate=neweststate then ; sayerror 'No other undo states recorded.' ; else call windowmessage(0, getpminfo(APP_HANDLE), 5131, -- EPM_POPFONTDLG 0, 0) ; endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: commandline syntax: commandline [optional text] │ │ │ │ what does it do : ask EPM.EXE to pop up its internal commandline control. │ │ This is done by posting a EPM_POPCMDLINE message to the │ │ EPM Book window. │ │ An optional string of text can be specified. If a string│ │ is specified then it will be inserted on the command line│ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc commandline -- The application will free the buffer allocated by this macro !!! call windowmessage(0, getpminfo(APP_HANDLE), 5124, -- EPM_POPCMDLINE 0, put_in_buffer(arg(1)) ) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: PostCmdToEditWindow(cmd, winhandle [, mp2 [, buflg]] ) │ │ │ │ what does it do : ask EPM.EXE to post a command to an edit window. MP2 is │ │ optional MP2 for the WinPostMsg. Default is 1 (EPM │ │ should free the command buffer). 4 means process │ │ synchronously (not safe), and 8 means that EPM should do │ │ a DosGetBuf to get the buffer. Optional 4th argument is │ │ passed to put_in_buffer (flag for DosAllocSeg; see │ │ put_in_buffer routine for details). │ │ │ │ who and when : Larry M. 7/23/90 │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc PostCmdToEditWindow(cmd,winhndl) if arg(3)<>'' then mp2=arg(3); else mp2=1; endif call windowmessage(0, winhndl, 5377, -- EPM_EDIT_COMMAND put_in_buffer(cmd,arg(4)), mp2) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: PostMe syntax: PostMe command │ │ │ │ what does it do : Ask EPM.EXE to post a command to the current edit window.│ │ Useful if you want to send a command on an OPEN but │ │ don't want to tie up the main queue while the command is │ │ executing. By posting the command back to the window, │ │ it will execute from the EI queue, and not keep everyone │ │ else waiting. │ │ │ │ Example of usage: │ │ "open 'PostMe long_running_command'" │ │ │ │ who and when : Larry M. 89/08/14 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc PostMe call PostCmdToEditWindow(arg(1),getpminfo(EPMINFO_EDITCLIENT)) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: buffer_command syntax: buffer_command buff_address │ │ │ │ what does it do : Executes the command that's stored in the buffer, then │ │ frees the buffer. Useful if you want to send a command │ │ to another window but don't want to worry about length │ │ or invalid characters. │ │ │ │ Example of usage: │ │ "open 'buffer_command" put_in_buffer(cmd_string) │ │ │ │ who and when : Larry M. 91/09/03 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc buffer_command parse arg buff . if not buff then return; endif -- Null pointer = no command buffer_long = atol(buff) peekz(buffer_long) -- Get the command from the buffer, & execute it call dynalink('DOSCALLS', -- dynamic link library name '#39', -- DosFreeSeg rightstr(buffer_long,2) ) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: messagebox syntax: messagebox [optional string] │ │ │ │ what does it do : ask EPM.EXE to pop up its internal message box control. │ │ This is done by posting a EPM_POPMSGBOX message to the │ │ EPM Book window. │ │ An optional string of text can be specified. If a string│ │ is specified then it will be inserted into the message bx│ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc messagebox -- The application will free the buffer allocated by this macro !!! call windowmessage(0, getpminfo(APP_HANDLE), 5125, -- EPM_POPMSGBOX 0, put_in_buffer(arg(1)) ) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: opendlg syntax: opendlg [EDIT | GET] │ │ │ │ what does it do : ask EPM.EXE to pop up its internal message box control. │ │ This is done by posting a EPM_POPOPENDLG message to the │ │ EPM Book window. │ │ If a file is selected, by default, it will be present-│ │ ed in a new window. If the 'EDIT' option is specified │ │ the file specified will be opened in the active edit │ │ window. │ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc opendlg call windowmessage(0, getpminfo(APP_HANDLE), 5126, -- EPM_POPOPENDLG 0, pos(upcase(arg(1)),' EDITGET')%4 * 65536) -- OPEN=0; EDIT=1; GET=2 /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: searchdlg syntax: searchdlg [next] │ │ │ │ what does it do : ask EPM.EXE to pop up its internal search & replace dlg. │ │ This is done by posting a EPM_POPCHANGEDLG message to the│ │ EPM Book window. │ │ if the [next] param = 'F' a find next will take place │ │ if the [next] param = 'C' a change next will take place │ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 2/27/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc searchdlg universal default_search_options, search_len if upcase(arg(1))='C' then 'c' /* repeat last change */ elseif upcase(arg(1))='F' then repeat_find compile if defined(HIGHLIGHT_COLOR) if not rc then compile if EVERSION < '5.50' refresh sayat '', .cursory, .cursorx, HIGHLIGHT_COLOR, min(search_len, .windowwidth - .cursorx + 1) compile else circleit 1, .line, .col, .col+search_len-1, HIGHLIGHT_COLOR ; refresh compile endif endif compile endif else -- The application will free the buffer allocated by this macro !!! call windowmessage(0, getpminfo(APP_HANDLE), 5128, -- EPM_POPCHANGEDLG 0, put_in_buffer(default_search_options)) endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: configdlg syntax: configdlg │ │ │ │ what does it do : ask EPM.EXE to pop up its internal configuration dialog. │ │ This is done by posting a EPM_POPCONFIGDLG message to the│ │ EPM Book window. │ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Jerry C. 7/20/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc configdlg compile if CHECK_FOR_LEXAM universal LEXAM_is_available compile endif call windowmessage(0, getpminfo(APP_HANDLE), 5129, -- EPM_POPCONFIGDLG compile if ENHANCED_ENTER_KEYS 0, -- Omit no pages compile else 64, -- Bit 7 on means omit page 7 compile endif compile if SPELL_SUPPORT compile if CHECK_FOR_LEXAM not LEXAM_is_available) compile else 0) compile endif compile else 1) -- Bit 0 on means omit spell stuff from page 4 compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: renderconfig syntax: renderconfig reply_window_hwnd │ │ │ │ what does it do : Upon the request of a external window, sent configuration│ │ information in the form of special WM_COMMAND messages │ │ to the window handle specified in parameter one. │ │ │ │ WM_COMMAND's first parameter is a ID number which informs│ │ the recieving window what type of information is in │ │ the second window parameter. │ │ │ │ The fuction is used by EPM to fill in the EPM CONFIG │ │ dialog box. │ │ │ │ who and when : Jerry C. & LAM 7/20/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc renderconfig universal ADDENDA_FILENAME universal DICTIONARY_FILENAME universal vAUTOSAVE_PATH, vTEMP_PATH universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE universal appname, app_hini compile if ENHANCED_ENTER_KEYS universal enterkey, a_enterkey, c_enterkey, s_enterkey universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey compile endif compile if CHECK_FOR_LEXAM universal LEXAM_is_available compile endif parse arg hndle page send_default . compile if EVERSION >= 5.21 help_panel = 5300 + page if page=1 then b= 3; e= 3; -- Page 1 is tabs elseif page=2 then b= 1; e= 1; -- Page 2 is margins elseif page=3 then b= 4; e= 7; -- Page 3 is colors elseif page=4 then b= 9; e=12; -- Page 4 is paths compile if SPELL_SUPPORT -- Enable IUO fields (dictionary & addenda paths) compile if CHECK_FOR_LEXAM if LEXAM_is_available then compile endif help_panel = 5390 -- Different help panel compile if CHECK_FOR_LEXAM endif compile endif compile endif elseif page=5 then b= 2; e= 2; -- Page 5 is autosave elseif page=6 then b=13; e=13; -- Page 6 is fonts compile if ENHANCED_ENTER_KEYS elseif page=7 then b=14; e=14; -- Page 7 is enter keys compile endif else b= 1; e=12; -- No notebook control; send all 12 help_panel = 0 -- The old config dlg doesn't expect a help panel number endif compile elseif EPATH='LAMPATH' -- Includes Enter_keys panel as a separate dialog. if page=7 then b=14; e=14; -- Page 7 is enter keys help_panel = 5307 else b= 1; e=12; -- No notebook control; send all 12 help_panel = 0 endif compile else b= 1; e=12; -- No notebook control; send all 12 help_panel = 0 compile endif if b<=4 & e>=4 then tempstr= queryprofile( $HINI_PARM appname, INI_STUFF) if tempstr='' | tempstr=1 then tempstr=TEXTCOLOR MARKCOLOR STATUSCOLOR MESSAGECOLOR; endif parse value tempstr with ttextcolor tmarkcolor tstatuscolor tmessagecolor . endif for i=b to e -- Send config info if i=1 then tempstr= checkini(send_default, INI_MARGINS, DEFAULT_MARGINS) elseif i=2 then tempstr= checkini(send_default, INI_AUTOSAVE, DEFAULT_AUTOSAVE) elseif i=3 then tempstr= checkini(send_default, INI_TABS, DEFAULT_TABS) elseif i=4 then tempstr= ttextcolor elseif i=5 then tempstr= tmarkcolor elseif i=6 then tempstr= tstatuscolor elseif i=7 then tempstr= tmessagecolor compile if SPELL_SUPPORT -- Enable IUO fields (dictionary & addenda paths) compile if CHECK_FOR_LEXAM elseif i=8 then if not LEXAM_is_available then iterate; endif; tempstr= '' compile else elseif i=8 then tempstr= '' compile endif compile else elseif i=8 | i=11 | i=12 then iterate compile endif elseif i=9 then tempstr= checkini(send_default, INI_AUTOSAVEPATH, vAUTOSAVE_PATH, AUTOSAVE_PATH) elseif i=10 then tempstr= checkini(send_default, INI_TEMPPATH, vTEMP_PATH, TEMP_PATH) compile if SPELL_SUPPORT elseif i=11 then tempstr= checkini(send_default, INI_DICTIONARY, DICTIONARY_FILENAME) elseif i=12 then tempstr= checkini(send_default, INI_ADDENDA, ADDENDA_FILENAME) compile endif compile if EVERSION >= 5.50 -- GPI elseif i=13 then tempstr= queryfont(.font)'.'trunc(.textcolor//16)'.'.textcolor%16 compile endif compile if ENHANCED_ENTER_KEYS elseif i=14 then if send_default then compile if ENTER_ACTION='' | ENTER_ACTION='ADDLINE' -- The default ek = \1 compile elseif ENTER_ACTION='NEXTLINE' ek = \2 compile elseif ENTER_ACTION='ADDATEND' ek = \3 compile elseif ENTER_ACTION='DEPENDS' ek = \4 compile elseif ENTER_ACTION='DEPENDS+' ek = \5 compile elseif ENTER_ACTION='STREAM' ek = \6 compile endif compile if C_ENTER_ACTION='ADDLINE' c_ek = \1 compile elseif C_ENTER_ACTION='' | C_ENTER_ACTION='NEXTLINE' -- The default c_ek = \2 compile elseif C_ENTER_ACTION='ADDATEND' c_ek = \3 compile elseif C_ENTER_ACTION='DEPENDS' c_ek = \4 compile elseif C_ENTER_ACTION='DEPENDS+' c_ek = \5 compile elseif C_ENTER_ACTION='STREAM' c_ek = \6 compile endif tempstr = ek || ek || c_ek || ek || ek || ek || c_ek || ek else tempstr = chr(enterkey) || chr(a_enterkey) || chr(c_enterkey) || chr(s_enterkey) || chr(padenterkey) || chr(a_padenterkey) || chr(c_padenterkey) || chr(s_padenterkey) endif compile endif endif tempstr = tempstr\0 -- null terminate (asciiz) call windowmessage(1, hndle, 32, -- WM_COMMAND - 0x0020 mpfrom2short(help_panel, i), ltoa(offset(tempstr) || selector(tempstr), 10) ) endfor ;;sayerror 'page='page'; hndl='hndle'; help_panel='help_panel'; b='b';e='e'; ENHANCED_ENTER='ENHANCED_ENTER_KEYS compile if ENHANCED_ENTER_KEYS defc enterkeys = universal enterkey, a_enterkey, c_enterkey, s_enterkey universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey universal appname, app_hini parse arg perm enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey if perm then call setprofile($HINI_PARM appname,INI_ENTERKEYS, enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey) endif compile endif ; send_default is a flag that says we're reverting to the default product options. ; defaultdata is the value to be used as the window default if INIKEY isn't found ; in the EPM.INI; it will also be used as the product default if no fourth parameter ; is given. defproc checkini(send_default, inikey, defaultdata ) universal appname, app_hini if send_default then if arg()>3 then return arg(4) endif return defaultdata endif inidata=queryprofile($HINI_PARM appname,inikey) if inidata<>'' then return inidata endif return defaultdata ; 5.21 lets you apply without saving, so we add an optional 3rd parameter. ; If omitted, assume the old way - save. If present, only save if 1. defproc setini( inikey, inidata ) universal appname, app_hini if arg()>=3 then perm=arg(3) else perm=1 endif if perm then call setprofile($HINI_PARM appname, inikey, inidata) endif return inidata /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: setconfig syntax: setconfig configid newvalue │ │ │ │ what does it do : The function is called by the EPM CONFIG dialog box to │ │ return values set by the user. │ │ │ │ │ │ who and when : Jerry C. & LAM 7/20/89 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc setconfig universal ADDENDA_FILENAME universal DICTIONARY_FILENAME universal vTEMP_FILENAME, vTEMP_PATH universal vAUTOSAVE_PATH universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE universal appname, app_hini compile if EPATH = 'LAMPATH' universal mail_list_wid compile endif compile if EVERSION >= 5.21 universal vMESSAGECOLOR, vSTATUSCOLOR compile endif compile if EVERSION >= 5.21 parse value upcase(arg(1)) with configid perm newcmd compile else parse value upcase(arg(1)) with configid newcmd; perm=1 compile endif if configid= 1 then if .margins<>newcmd then 'postme maybe_reflow_all'; endif .margins=newcmd; vDEFAULT_MARGINS=setini(INI_MARGINS, .margins, perm); elseif configid= 2 then .autosave=setini(INI_AUTOSAVE,newcmd, perm); vDEFAULT_AUTOSAVE=newcmd elseif configid= 3 then rc=0; .tabs=newcmd; if not rc then vDEFAULT_TABS=setini(INI_TABS,newcmd, perm); endif elseif configid= 4 then .textcolor=newcmd elseif configid= 5 then .markcolor=newcmd compile if EVERSION < 5.21 elseif configid= 6 then .statuscolor=newcmd elseif configid= 7 then .messagecolor=newcmd call setprofile( $HINI_PARM appname, INI_STUFF, .textcolor .markcolor .statuscolor .messagecolor) compile else elseif configid= 6 & newcmd<>vSTATUSCOLOR then vSTATUSCOLOR=newcmd 'setstatusline' elseif configid= 7 & newcmd<>vMESSAGECOLOR then vMESSAGECOLOR=newcmd 'setmessageline' compile endif elseif configid= 9 then if newcmd<>'' & rightstr(newcmd,1)<>'\' then newcmd=newcmd'\' endif if rightstr(newcmd,2)='\\' then -- Temp fix for dialog bug newcmd=leftstr(newcmd,length(newcmd)-1) endif vAUTOSAVE_PATH=setini(INI_AUTOSPATH,newcmd, perm) elseif configid=10 then if newcmd<>'' & rightstr(newcmd,1)<>'\' then newcmd=newcmd'\' endif if rightstr(newcmd,2)='\\' then -- Temp fix for dialog bug newcmd=leftstr(newcmd,length(newcmd)-1) endif if upcase(leftstr(vTEMP_FILENAME,length(vTEMP_PATH))) = upcase(vTEMP_PATH) then vTEMP_FILENAME=newcmd||substr(vTEMP_FILENAME,length(vTEMP_PATH)+1) elseif not verify(vTEMP_FILENAME,':\','M') then -- if not fully qualified vTEMP_FILENAME=newcmd||vTEMP_FILENAME endif vTEMP_PATH=setini(INI_TEMPPATH,newcmd, perm) elseif configid=11 then DICTIONARY_FILENAME = setini(INI_DICTIONARY,newcmd, perm) elseif configid=12 then ADDENDA_FILENAME = setini(INI_ADDENDA,newcmd, perm) compile if EVERSION >= 5.21 -- Now, only do this once elseif configid= 0 then call setprofile( $HINI_PARM appname, INI_STUFF, .textcolor .markcolor vstatuscolor vmessagecolor) compile endif endif compile if EPATH = 'LAMPATH' compile if IBM_IUO -- last item = 12 if mail_list_wid<>'' & configid=12 then compile else -- last item = 10; no spell checking if mail_list_wid<>'' & configid=10 then compile endif cmd = 'initconfig'\0 call windowmessage(1, mail_list_wid, 5515, -- x158B; LAM BROADCAST COM ltoa(offset(cmd) || selector(cmd), 10), 65536) endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: initconfig │ │ │ │ what does it do : Set universal variables according to the values │ │ previously saved in the EPM.INI file. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defc initconfig universal ADDENDA_FILENAME universal DICTIONARY_FILENAME universal vTEMP_FILENAME, vTEMP_PATH universal vAUTOSAVE_PATH universal appname, app_hini, font universal vDEFAULT_TABS, vDEFAULT_MARGINS, vDEFAULT_AUTOSAVE compile if EVERSION >= '5.50' universal default_font compile endif compile if WANT_CUA_MARKING = 'SWITCH' universal CUA_marking_switch compile endif compile if WANT_DYNAMIC_PROMPTS universal menu_prompt compile endif compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH) universal savepath compile endif compile if EVERSION >= 5.21 universal vMESSAGECOLOR, vSTATUSCOLOR compile endif compile if ENHANCED_ENTER_KEYS universal enterkey, a_enterkey, c_enterkey, s_enterkey universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey compile endif compile if WANT_STREAM_MODE = 'SWITCH' universal stream_mode compile endif compile if RING_OPTIONAL universal ring_enabled compile endif compile if WANT_LONGNAMES='SWITCH' universal SHOW_LONGNAMES compile endif compile if WANT_PROFILE='SWITCH' universal REXX_PROFILE compile endif compile if TOGGLE_ESCAPE universal ESCAPE_KEY compile endif compile if TOGGLE_TAB universal TAB_KEY compile endif newcmd= queryprofile( $HINI_PARM appname, INI_STUFF) if newcmd then compile if EVERSION < 5.21 parse value newcmd with ttextcolor tmarkcolor tstatuscolor tmessagecolor . .textcolor=ttextcolor; .markcolor=tmarkcolor; .statuscolor=tstatuscolor; .messagecolor=tmessagecolor compile else parse value newcmd with ttextcolor tmarkcolor tstatuscolor tmessagecolor . .textcolor=ttextcolor; .markcolor=tmarkcolor if tstatuscolor<>'' & tstatuscolor<>vSTATUSCOLOR then vSTATUSCOLOR=tstatuscolor; 'setstatusline'; endif if tmessagecolor<>'' & tmessagecolor<>vMESSAGECOLOR then vMESSAGECOLOR=tmessagecolor; 'setmessageline'; endif compile endif newcmd=queryprofile( $HINI_PARM appname, INI_MARGINS) if newcmd then .margins=newcmd; vDEFAULT_MARGINS=newcmd; endif newcmd=queryprofile( $HINI_PARM appname, INI_AUTOSAVE) if newcmd<>'' then .autosave=newcmd; vDEFAULT_AUTOSAVE=newcmd; endif newcmd=queryprofile( $HINI_PARM appname, INI_TABS) if newcmd then .tabs=newcmd; vDEFAULT_TABS=newcmd; endif newcmd=queryprofile( $HINI_PARM appname, INI_TEMPPATH) if newcmd then vTEMP_PATH=newcmd if rightstr(vTemp_Path,1)<>'\' then vTemp_Path = vTemp_Path'\' -- Must end with a backslash. endif if not verify(vTEMP_FILENAME,':\','M') then -- if not fully qualified vTEMP_FILENAME=vTEMP_PATH||vTEMP_FILENAME endif endif newcmd=queryprofile( $HINI_PARM appname, INI_AUTOSPATH) if newcmd then vAUTOSAVE_PATH=newcmd if rightstr(vAUTOSAVE_Path,1)<>'\' then vAUTOSAVE_Path = vAUTOSAVE_Path'\' -- Must end with a backslash. endif compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH) savepath=vAUTOSAVE_PATH compile endif endif newcmd=queryprofile( $HINI_PARM appname, INI_DICTIONARY) if newcmd then DICTIONARY_FILENAME=newcmd endif newcmd=queryprofile( $HINI_PARM appname, INI_ADDENDA) if newcmd then ADDENDA_FILENAME=newcmd endif endif -- Options from Option pulldown newcmd=queryprofile( $HINI_PARM appname, INI_OPTFLAGS) if newcmd<>'' then parse value newcmd with statflg msgflg vscrollflg hscrollflg fileiconflg rotflg extraflg markflg menu_prompt streamflg longnames profile escapekey tabkey . compile if EVERSION >= '5.53' 'toggleframe 1' statflg 'toggleframe 2' msgflg 'toggleframe 8' vscrollflg 'toggleframe 16' hscrollflg compile if EVERSION < 5.50 -- File icon not optional in 5.50 'toggleframe 64' fileiconflg compile endif compile if RING_OPTIONAL if ring_enabled then 'toggleframe 4' rotflg; endif compile else 'toggleframe 4' rotflg compile endif 'toggleframe 32' extraflg compile else 'togglecontrol 7' statflg 'togglecontrol 8' msgflg 'togglecontrol 9' vscrollflg 'togglecontrol 10' hscrollflg compile if EVERSION < 5.50 -- File icon not optional in 5.50 'togglecontrol 22' fileiconflg compile endif compile if RING_OPTIONAL if ring_enabled then 'togglecontrol 20' rotflg; endif compile else 'togglecontrol 20' rotflg compile endif 'togglecontrol 23' extraflg compile endif compile if WANT_CUA_MARKING = 'SWITCH' if markflg<>CUA_marking_switch then 'CUA_mark_toggle' endif compile endif compile if WANT_STREAM_MODE = 'SWITCH' if streamflg<>stream_mode then 'stream_toggle'; endif compile endif compile if WANT_LONGNAMES='SWITCH' if longnames<>'' then SHOW_LONGNAMES = longnames endif compile endif compile if WANT_PROFILE='SWITCH' if PROFILE<>'' then REXX_PROFILE = PROFILE endif compile endif compile if TOGGLE_ESCAPE if ESCAPEKEY<>'' then ESCAPE_KEY = ESCAPEKEY endif compile endif compile if TOGGLE_TAB if TABKEY<>'' then TAB_KEY = TABKEY endif compile endif compile if EVERSION >= 5.50 -- 5.50 configures enter keys as part of endif -- Settings dlg, not as part of Save Options compile endif compile if WANT_STREAM_MODE <> 1 and ENHANCED_ENTER_KEYS newcmd=queryprofile( $HINI_PARM appname, INI_ENTERKEYS) if newcmd<>'' then parse value newcmd with enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey . endif compile endif compile if EVERSION >= 5.21 & EVERSION < 5.50 -- 5.21 configures font on config panel, endif -- not as part of Save Options compile endif compile if EVERSION < 5.50 newcmd =queryprofile( $HINI_PARM appname, INI_FONTCY) if newcmd<>'' then compile if EVERSION < 5.20 -- Earlier EPM versions didn't do DEVESCAPE if screenxysize('X')>1000 and dos_version()>=1020 then -- BGA and 1.2 or above compile else -- We can assume 1.2 or above; 1.1 no longer supported if screenxysize('X')>1000 or dos_version()>=1030 then -- BGA *or* 1.3 for many fonts compile endif call setfont(queryprofile($HINI_PARM appname, INI_FONTCX),newcmd) -- don't care what pulldown says elseif font = (newcmd=8) then -- if font true and smallfont, or font false and largefont 'togglefont' -- this changes the font and updates the "change to xxx font" pulldown endif endif compile else newcmd =queryprofile( $HINI_PARM appname, INI_FONT) parse value newcmd with fontname '.' fontsize '.' fontsel if newcmd<>'' then .font=registerfont(fontname, fontsize, fontsel); default_font = .font endif compile endif compile if EVERSION < 5.21 -- Before 5.21 saves font as part endif -- of Save Options processing. compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: saveoptions │ │ │ │ what does it do : save state of items on options pull down in os2ini │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defc saveoptions universal appname, app_hini compile if WANT_DYNAMIC_PROMPTS universal menu_prompt compile endif compile if EPATH = 'LAMPATH' universal mail_list_wid compile endif compile if ENHANCED_ENTER_KEYS & EVERSION < 5.21 universal enterkey, a_enterkey, c_enterkey, s_enterkey universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey compile endif compile if RING_OPTIONAL universal ring_enabled compile endif compile if WANT_STACK_CMDS = 'SWITCH' universal stack_cmds compile endif compile if WANT_STREAM_MODE = 'SWITCH' universal stream_mode compile endif compile if WANT_LONGNAMES='SWITCH' universal SHOW_LONGNAMES compile endif compile if WANT_PROFILE='SWITCH' universal REXX_PROFILE compile endif compile if TOGGLE_ESCAPE universal ESCAPE_KEY compile endif compile if TOGGLE_TAB universal TAB_KEY compile endif compile if WANT_CUA_MARKING = 'SWITCH' universal CUA_marking_switch compile else CUA_marking_switch = 0 compile endif compile if not WANT_DYNAMIC_PROMPTS menu_prompt = 1 compile endif compile if WANT_STREAM_MODE <> 'SWITCH' stream_mode = 0 compile endif compile if WANT_LONGNAMES<>'SWITCH' show_longnames = 0 compile endif compile if WANT_PROFILE<>'SWITCH' REXX_PROFILE = 0 compile endif compile if not TOGGLE_ESCAPE ESCAPE_KEY = 1 compile endif compile if not TOGGLE_TAB TAB_KEY = 0 compile endif call setprofile($HINI_PARM appname,INI_OPTFLAGS, compile if EVERSION >= 5.53 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) compile else 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) compile endif ; messageline statusline vert. scroll horiz. scroll file icon rotate buttons info window pos. call setprofile($HINI_PARM appname,INI_FONTCX, .fontwidth ) -- font width call setprofile($HINI_PARM appname,INI_FONTCY, .fontheight ) -- font height compile if WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21 call setprofile($HINI_PARM appname,INI_ENTERKEYS, enterkey a_enterkey c_enterkey s_enterkey padenterkey a_padenterkey c_padenterkey s_padenterkey) compile endif compile if RING_OPTIONAL call setprofile($HINI_PARM appname,INI_RINGENABLED, ring_enabled) compile endif compile if WANT_STACK_CMDS = 'SWITCH' call setprofile($HINI_PARM appname,INI_STACKCMDS, stack_cmds) compile endif call windowmessage(0, getpminfo(APP_HANDLE), 62, 0, 0) -- x'003E' = WM_SAVEAPPLICATION compile if EPATH = 'LAMPATH' cmd = 'initconfig'\0 if mail_list_wid<>'' then call windowmessage(1, mail_list_wid, -- This updates LaMail's hidden window 5515, -- x158B; LAM BROADCAST COM ltoa(offset(cmd) || selector(cmd), 10), 65536) endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: processdragdrop │ │ │ │ what does it do : this defc is automatically called by the │ │ toolkit when a drag drop event is successfully made │ │ │ │ what are the args: cmdid = 1 - epm edit window │ │ 2 - File icon window (self) │ │ 3 - epm book icon │ │ 4 - system editor │ │ 5 - File Manager folder │ │ 10 - Print manager │ │ │ │ hwnd = handle of target window's frame │ └────────────────────────────────────────────────────────────────────────────┘ */ defc PROCESSDRAGDROP parse arg cmdid hwnd ; hwnd=atol_swap(hwnd) if cmdid=10 then compile if ENHANCED_PRINT_SUPPORT 'printdlg' compile else sayerror PRINTING__MSG .filename compile if EVERSION < '5.50' 'xcom save' default_printer() compile else 'xcom save /ne' default_printer() compile endif sayerror 0 compile endif elseif cmdid=1 and hwnd<>getpminfo(EPMINFO_EDITFRAME) and leftstr(.filename,1)<>'.' then call PostCmdToEditWindow('e '.filename,hwnd,9,2) -- Get-able elseif cmdid=3 then if .filename=UNNAMED_FILE_NAME then name=''; else name=.filename; endif call windowmessage(0, getpminfo(APP_HANDLE), 5386, -- EPM_EDIT_NEWFILE put_in_buffer(name,2), -- share = GETable 9) -- EPM does a GET first & a FREE after. compile if IBM_IUO elseif cmdid=4 then call winmessagebox(SYS_ED__MSG,SYS_ED1__MSG\10' :-)', 16406) -- CANCEL + ICONQUESTION + MB_MOVEABLE compile endif elseif cmdid=5 then str=leftstr('',MAXCOL) len= dynalink( 'PMWIN', 'WINQUERYWINDOWTEXT', atol_swap(hwnd) || atoi(MAXCOL) || selector(str) || /* string selector */ offset(str) ) /* string offset */ p = lastpos('\',leftstr(str,len)) if p then str = leftstr(str,p)'=' call parse_filename(str, .filename) if exist(str) then if 1<>winmessagebox(str, EXISTS_OVERLAY__MSG, 16417) then -- OKCANCEL + CUANWARNING + MOVEABLE return -- 1 = MB OK endif endif 'save' str if not rc then sayerror SAVED_TO__MSG str; endif else call winmessagebox('"'leftstr(str,len)'"',NO_SLASH__MSG, 16406) -- CANCEL + ICONQUESTION + MB_MOVEABLE endif endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: repaint_window │ │ │ │ what does it do : send a paint message to the editor. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc repaint_window() call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 35, 0, 0) -- WM_PAINT compile if EVERSION >= 5.21 /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: saveas_dlg syntax: saveas_dlg │ │ │ │ what does it do : ask EPM.EXE to pop up its "Save as" dialog box control. │ │ This is done by posting a EPM_POPOPENDLG message to the │ │ EPM Book window. │ │ │ │ (All EPM_EDIT_xxx messages are defined in the ETOOLKT │ │ PACKAGE available on PCTOOLS.) │ │ │ │ who and when : Larry M. 6/12/91 │ └────────────────────────────────────────────────────────────────────────────┘ */ defc saveas_dlg compile if WANT_LONGNAMES='SWITCH' universal SHOW_LONGNAMES compile endif if not saveas_dlg(name, type) then compile if EVERSION >= '5.50' if leftstr(name,1)='"' & rightstr(name,1)='"' then name=substr(name,2,length(name)-2) endif compile endif .filename = name compile if WANT_LONGNAMES compile if WANT_LONGNAMES='SWITCH' if SHOW_LONGNAMES then compile endif if get_EAT_ASCII_value('.LONGNAME')<>'' then call delete_ea('.LONGNAME') .titletext = '' endif compile if WANT_LONGNAMES='SWITCH' endif compile endif compile endif 'save' endif defproc saveas_dlg(var name, var type) type = copies(\0,255) if .filename=UNNAMED_FILE_NAME then name = type else name = leftstr(.filename,255,\0) endif res= dynalink( ERES_DLL, -- library name 'ERESSAVEAS', -- function name gethwnd(EPMINFO_EDITCLIENT) || gethwnd(APP_HANDLE) || selector(name) || offset(name) || selector(type) || offset(type) ) ; Return codes: 0=OK; 1=memory problem; 2=bad string; 3=couldn't load control from DLL if res=2 then -- File dialog didn't like the .filename; name = copies(\0,255) -- try again with no file name call dynalink( ERES_DLL, -- library name 'ERESSAVEAS', -- function name gethwnd(EPMINFO_EDITCLIENT) || gethwnd(APP_HANDLE) || selector(name) || offset(name) || selector(type) || offset(type) ) endif parse value name with name \0 parse value type with type \0 if name='' then return -275; endif -- sayerror('Missing filename') if exist(name) then if 1<>winmessagebox('Save As', name\10\10||EXISTS_OVERLAY__MSG, 16417) then -- OKCANCEL + CUANWARNING + MOVEABLE return -5 -- sayerror('Access denied') endif endif if type then call delete_ea('.TYPE') 'add_ea .TYPE' type endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: showwindow │ │ │ │ what does it do : allows the edit window to become invisible or visible │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc showwindow -- post the EPM_EDIT_SHOW message call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT), 5385, upcase(arg(1))<>'OFF', -- 0 if OFF, else 1 0) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: settitletext │ │ │ │ what does it do : set the text in the editors active title bar. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc settitletext() text = arg(1) compile if SHOW_MODIFY_METHOD = 'TITLE' if .modify then text = text || SHOW_MODIFY_TEXT endif compile endif .titletext = text /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: updateringmenu │ │ │ │ what does it do : update ring menu │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ compile if MENU_LIMIT defproc updateringmenu() universal activemenu,defaultmenu universal EPM_utility_array_ID compile if 0 -- LAM: Delete this feature; nobody used it, and it slowed things down. do_array 3, EPM_utility_array_ID, 'menu.0', menucount -- Item 0 is count of menus. if menucount=0 then return; endif compile endif getfileid fid if fid<>'' then compile if 0 -- LAM: Delete this feature; nobody used it, and it slowed things down. showmenu_flag = 0 do i=1 to menucount do_array 3, EPM_utility_array_ID, 'menu.'i, menuname -- Get menuname[i] deletemenu menuname, 5, 0, 1 -- Delete its ring menu if activemenu=menuname then showmenu_flag = 1; endif end compile else deletemenu defaultmenu, 5, 0, 1 -- Delete its ring menu compile endif startid = fid ;; len = 1 -- Will be length of buffer required. Init to 1 for null terminator. do menuid = 500 to 500+MENU_LIMIT -- Prevent looping forever. ;; len = len + length(.filename) + 7 -- 7 = 1 sep '/' + max 4 for index + 2 blanks compile if 0 -- LAM: Delete this feature; nobody used it, and it slowed things down. do i=1 to menucount do_array 3, EPM_utility_array_ID, 'menu.'i, menuname -- Get menuname[i] if menuid < 500 + MENU_LIMIT then buildmenuitem menuname, 5, menuid, .filename, 'activatefileid 'fid, 0, 0 elseif menuid = 500 + MENU_LIMIT then buildmenuitem menuname, 5, menuid, '~'MORE__MSG'...', 'Ring_More', 0, 0 endif end compile else if menuid < 500 + MENU_LIMIT then if .titletext=='' then buildmenuitem defaultmenu, 5, menuid, .filename, 'activatefileid 'fid, 0, 0 else buildmenuitem defaultmenu, 5, menuid, .titletext, 'activatefileid 'fid, 0, 0 endif elseif menuid = 500 + MENU_LIMIT then buildmenuitem defaultmenu, 5, menuid, '~'MORE__MSG'...', 'Ring_More', 0, 0 activatefile startid leave endif compile endif nextfile getfileid fid if fid=startid then leave; endif enddo ;; do_array 2, EPM_utility_array_ID, 'NS', len -- Item NS is NameSize - size of buffer. if activemenu=defaultmenu then showmenu activemenu, 5 endif endif compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: WinMessageBox │ │ │ │ what does it do : This routine issues a PM WinMessageBox call, and returns │ │ the result. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defproc winmessagebox(caption, text) ; msgtype = 4096 -- must be system modal. ; if arg(3) then ; msgtype=arg(3) + 4096 * (1 - (arg(3)%4096 - 2 * (arg(3)%8192))) -- ensure x'1000' on ; endif if arg(3) then msgtype=arg(3) else msgtype = 0 endif caption = caption\0 text = text\0 return dynalink( 'PMWIN', 'WINMESSAGEBOX', atoi(0) || atoi(1) || -- Parent -- atoi(0) || atoi(1) || -- Owner gethwnd(EPMINFO_EDITFRAME) || /* edit frame handle */ selector(text) || -- Text offset(text) || selector(caption) || -- Title offset(caption) || atoi(0) || -- Window atoi(msgtype) ) -- Style /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: activatefileid │ │ │ │ what does it do : This command is used when a RING menu item is selected │ │ it switches view to the file that was just selected. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ compile if MENU_LIMIT defc activatefileid fid = arg(1) activatefile fid compile endif define compile if MENU_LIMIT list_col=33 -- Under 'Ring' on action bar compile else list_col=23 -- Under 'Options' on action bar compile endif /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: Ring_More │ │ │ │ what does it do : This command is called when the More... selection on │ │ the ring menu is selected. (Or by the Ring action bar │ │ item if MENU_LIMIT = 0.) It generates a listbox │ │ containing all the filenames, and selects the │ │ appropriate fileid if a filename is selected. │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defc Ring_More compile if EVERSION >= 5.20 -- The new way; easy and fast. if filesinring()=1 then sayerror ONLY_FILE__MSG return endif call windowmessage(0, getpminfo(APP_HANDLE), 5141, -- EPM_POPRINGDIALOG 0, 0) compile else -- The old way; slow and complicated. universal EPM_utility_array_ID sayerror LISTING__MSG getfileid fid startid = fid ;; do_array 3, EPM_utility_array_ID, 'NS', len -- Item NS is size of names buffer required len = 1 -- Will be length of buffer required. Init to 1 for null terminator. tmp_str = '' -- In case we don't need a buffer longest=0 do i = 1 to FilesInRing(2) -- Prevent looping forever. do_array 2, EPM_utility_array_ID, 'F'i, fid -- Put fileid into array index [i] if .titletext=='' then fname=.filename else fname=.titletext endif len = len + length(fname) + length(i) + 3 -- 3 = 1 sep '/' + 2 blanks longest=max(longest, length(fname) + length(i) + 2) tmp_str = tmp_str || \1 || i || ' 'substr('. ',(.modify=0)+1,1) || fname nextfile getfileid fid if fid=startid then leave; endif enddo if i=1 then sayerror ONLY_FILE__MSG return endif if length(tmp_str)<MAXCOL then -- We can use the string; no need to bother with a buffer. filesbuffer = selector(tmp_str) filesbuf_offset = offset(tmp_str) buf_offset = length(tmp_str) tmp_str = tmp_str\0 -- null terminate free_the_buffer = 0 else -- Have to allocate and fill a buffer. filesbuffer = "??" -- initialize string pointer r = dynalink('DOSCALLS', -- dynamic link library name '#34', -- DosAllocSeg atoi(min(len+1,65535)) || -- Number of Bytes requested selector(filesbuffer) || -- string selector offset(filesbuffer) || -- string offset atoi(0)) -- Share information if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif filesbufseg = itoa(filesbuffer,10) buf_offset = 0 filesbuf_offset = atoi(0) do i = 1 to FilesInRing(2) ;; do_array 2, EPM_utility_array_ID, 'F'i, fid -- Put fileid into array index [i] if .titletext=='' then fname=.filename else fname=.titletext endif tmp_str = \1 || i || ' 'substr('. ',(.modify=0)+1,1) || fname -- \1 || "1 D:\E_MACROS\STDCTRL.E" if buf_offset+length(tmp_str) >= 65535 then activatefile startid call WinMessageBox(TOO_MANY_FILES__MSG, NOT_FIT__MSG, 16416) leave endif poke filesbufseg,buf_offset,tmp_str buf_offset=buf_offset+length(tmp_str) nextfile getfileid fid if fid=startid then leave; endif enddo poke filesbufseg,buf_offset,\0 -- Null terminate free_the_buffer = 1 endif but1=SELECT__MSG\0; but2=CANCEL__MSG\0; but3=\0; but4=\0; but5=\0; but6=\0; but7=\0 /* default butts*/ if longest<.windowwidth-LIST_COL then col=LIST_COL -- Under appropriate pulldown on action bar. else col=0 -- At left edge of edit window. endif ;; row = -2 - querycontrol(7) - querycontrol(8) -- Allow for status and message line /* null terminate return buffer */ selectbuf = leftstr(\0,255) -- If this were used for 5.53 or above, would have to change this... rect = '????????????????' -- Left, Bottom, Right, Top call dynalink( 'PMWIN', 'WINQUERYWINDOWRECT', gethwnd(EPMINFO_EDITCLIENT) || selector(rect) || /* string selector */ offset(rect) ) /* string offset */ ; LAM: Originally, I placed the listbox more or less below the action bar menu ; title. But, on some machines, it didn't wind up in the right place. ; Also, it got thrown off if the user had partial text displayed. So, I ; changed from (a) to (b), which gets the exact position in pels (using ; the WinQueryWindowRect call, above) rather than multiplying an ; approximate character position by the font height. (c) was an attempt ; to place the list box immediately under the pulldown, by taking into ; account the status line and message line. I decided that I wanted to ; see the status line (so the "nnn files" wouldn't be covered), so I went ; back to (b). It's more efficient, and I'm willing to not worry about ; whether or not the message line is covered by the listbox. title=FILES_IN_RING__MSG\0 sayerror 0; refresh call dynalink( ERES_DLL, -- list box control in EDLL dynalink 'LISTBOX', -- function name gethwnd(EPMINFO_EDITFRAME)|| -- edit frame handle atoi(3) || atoi(.fontwidth * col) || -- coordinates ;; (a) atoi(.fontheight*(screenheight()+querycontrol(7)+querycontrol(8))) || substr(rect,13,2) || -- (b) ;; (c) atoi(itoa(substr(rect,13,2),10)+.fontheight*(querycontrol(7)+querycontrol(8))) || atoi(min(i,16)) || -- height = smaller of # files or 16 atoi(0) || -- width - 0 means as much as needed atoi(2) || -- Number of buttons selector(title) || -- title offset(title) || selector(but1) || -- text to appear in buttons offset(but1) || selector(but2) || offset(but2) || selector(but3) || offset(but3) || selector(but4) || offset(but4) || selector(but5) || offset(but5) || selector(but6) || offset(but6) || selector(but7) || offset(but7) || atoi(buf_offset) || -- length of list filesbuffer || -- list segment filesbuf_offset || -- list offset selector(selectbuf) || -- return string buffer offset(selectbuf) ) if free_the_buffer then call dynalink('DOSCALLS', -- dynamic link library name '#39', -- DosFreeSeg filesbuffer) endif EOS = pos(\0,selectbuf) -- CHR(0) signifies End Of String if EOS = 1 then return; endif parse value selectbuf with idx . if not isnum(idx) then sayerror UNEXPECTED__MSG; return; endif do_array 3, EPM_utility_array_ID, 'F'idx, fileid activatefile fileid compile endif -- The old way; slow and complicated. defproc mpfrom2short(mphigh, mplow) return ltoa( atoi(mplow) || atoi(mphigh), 10 ) /* Returns the edit window handle, as a 4-digit decimal string. */ defproc gethwnd(w) ; EditHwnd = getpminfo(w) /* get edit window handle */ /* String handling in E language : */ /* EditHwnd = '1235:1234' <- address in string form */ /* atol(EditHwnd)= '11GF' <- four byte pointer, represented */ /* as its ascii character */ /* equivalent. */ /* Flipping (substr(...) ) <- places 4 bytes in correct order. */ /* Note: 2byte vars are converted with atoi ie. USHORT */ /* Note: 4byte vars are converted with atol ie. HWND,HAB */ /* get edit window handle */ /* convert string to string pointer */ /* interchange upper two bytes with */ /* lower two bytes. (flip words) */ return atol_swap(getpminfo(w)) defproc gethwndc(w) return atol(getpminfo(w)) /* ┌────────────────────────────────────────────────────────────────────────────┐ │ what's it called: dupmark │ │ │ │ what does it do : This command is used when a Mark menu item is selected │ │ │ └────────────────────────────────────────────────────────────────────────────┘ */ defc dupmark mt = upcase(arg(1)) if mt = 'M' then ; if marktype() then call pmove_mark() ; else -- If no mark, look in Shared Text buffer ; 'GetSharBuff' -- See clipbrd.e for details ; endif elseif mt = 'C' then if marktype() then call pcopy_mark() else -- If no mark, look in Shared Text buffer 'GetSharBuff' -- See clipbrd.e for details endif elseif mt = 'O' then if marktype() then compile if WANT_CHAR_OPS call pcommon_adjust_overlay('O') compile else overlay_block compile endif else -- If no mark, look in Shared Text buffer 'GetSharBuff O' -- See clipbrd.e for details endif elseif mt = 'A' then compile if WANT_CHAR_OPS call pcommon_adjust_overlay('A') compile else adjustblock compile endif elseif mt = 'U' then unmark 'ClearSharBuff' elseif mt = 'D' then -- Normal delete mark compile if WANT_DM_BUFFER 'Copy2DMBuff' -- See clipbrd.e for details compile endif -- WANT_DM_BUFFER call pdelete_mark() 'ClearSharBuff' elseif mt = 'D2' then -- special for drag/drop; only deletes mark w/o touching buffers call pdelete_mark() elseif mt = 'P' then -- Print marked area call checkmark() -- verify there is a marked area, ;compile if ENHANCED_PRINT_SUPPORT -- DUPMARK P is only called if no enhanced print support ; printer=get_printer() ; if printer<>'' then 'print' printer; endif ;compile else 'print' -- then print it. ;compile endif endif /* ╔════════════════════════════════════════════════════════════════════════════╗ ║ MENU support. ║ ║ EPM's menu support is achieved through the use of the MENU manager. ║ ║ This menu manager is located in EUTIL.DLL in versions prior to 5.20; ║ ║ in E.DLL for EPM 5.20 and above. The menu manager contains powerful ║ ║ functions that allow an application to create there own named menus. ║ ║ Building Menus with the Menu Manager: ║ ║ The menu manager provides two fuctions which allow the creating ║ ║ or replacing of items in a named menu. ║ ║ Note: A menu is first built and then displayed in the window. ║ ║ BUILDSUBMENU - creates or modifies a sub menu ║ ║ BUILDMENUITEM - create or modifies a menu item under a sub menu ║ ║ ║ ║ Showing a named Menu ║ ║ SHOWMENU - show the specified named menu in the specified ║ ║ window frame. ║ ║ ║ ║ Deleting a name menu ║ ║ DELETEMENU - remove a named menu from the internal menory ║ ║ manager. ║ ╚════════════════════════════════════════════════════════════════════════════╝ */ defexit universal defaultmenu deletemenu defaultmenu defaultmenu='' /* ┌─────────────────────────────────────────────────────────────────────────────┐ │What's it called : processmenu | processcommand │ │ │ │What does it do : This command is not called by macros. It is called by │ │ the internal editor message handler. When a menu │ │ selected messaged is received by the internal message │ │ handler, (WM_COMMAND) this function is called with │ │ the menu id as a parameter. │ │ │ │ │ │Who and When : Jerry C. 3/4/89 │ └─────────────────────────────────────────────────────────────────────────────┘ */ compile if EVERSION > 5.19 defc processcommand -- Now called processcommand compile if EVERSION > 5.20 universal activeaccel compile endif compile else defc processmenu compile endif universal activemenu menuid = arg(1) if menuid='' then sayerror PROCESS_ERROR__MSG return endif compile if EVERSION > 5.19 -- first test if command was generated by the -- next/prev buttons on the editor frame. if menuid=44 then nextfile elseif menuid=45 then prevfile else compile if EVERSION > 5.20 accelstr=queryaccelstring(activeaccel, menuid) if accelstr<>'' then accelstr else compile endif compile endif if activemenu='' then sayerror 'Error in active menu' return endif -- execute user string, after stripping off null terminating char parse value querymenustring(activemenu,menuid) with command \1 helpstr strip(command,'T',\0) compile if EVERSION > 5.19 compile if EVERSION > 5.20 endif compile endif endif compile endif compile if EVERSION >= 5.51 & 0 -- Not used... defc processaccel universal activeaccel menuid = arg(1) if menuid='' then sayerror PROCESS_ERROR__MSG return endif queryaccelstring(activeaccel, menuid) compile endif defc processmenuselect -- Called when a menu item is activated; used for prompting compile if INCLUDE_MENU_SUPPORT compile if WANT_DYNAMIC_PROMPTS universal activemenu, menu_prompt menuid = arg(1) if menuid='' | activemenu='' | not menu_prompt then sayerror 0 return endif parse value querymenustring(activemenu,menuid) with command \1 helpstr if helpstr<>'' then compile if EVERSION >= '5.21' display -8 compile endif sayerror helpstr compile if EVERSION >= '5.21' display 8 compile endif else sayerror 0 endif compile else sayerror 0 compile endif compile endif -- INCLUDE_MENU_SUPPORT ; Note: this routine does *not* get called when Command (menuid 1) is selected. defc PROCESSMENUINIT -- Called when a pulldown or pullright is initialized. compile if INCLUDE_MENU_SUPPORT universal activemenu, defaultmenu universal EPM_utility_array_ID compile if WANT_DYNAMIC_PROMPTS universal menu_prompt compile endif universal lastchangeargs compile if WANT_STACK_CMDS universal mark_stack, position_stack compile if WANT_STACK_CMDS = 'SWITCH' universal stack_cmds compile endif compile endif compile if WANT_CUA_MARKING = 'SWITCH' universal CUA_marking_switch compile endif compile if WANT_STREAM_MODE = 'SWITCH' universal stream_mode compile endif compile if RING_OPTIONAL universal ring_enabled compile endif if activemenu<>defaultmenu then return; endif menuid = arg(1) if menuid=8 then -- Edit on = marktype()<>'' buf_flag = 0 if not on then -- Only check buffer if no mark bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER) if bufhndl then -- If the buffer exists, check the buf_flag=itoa(peek(bufhndl,2,2),10) -- amount of used space in buffer call buffer(FREEBUF, bufhndl) -- then free it. endif endif compile if EVERSION < '5.50' getline current undo getline original undo SetMenuAttribute( 816, 16384, original/==current) compile else SetMenuAttribute( 816, 16384, isadirtyline()) compile endif SetMenuAttribute( 800, 16384, on | buf_flag) -- Can copy if mark or buffer has data SetMenuAttribute( 801, 16384, on) SetMenuAttribute( 802, 16384, on | buf_flag) -- Ditto for Overlay mark SetMenuAttribute( 803, 16384, on) SetMenuAttribute( 805, 16384, on) SetMenuAttribute( 806, 16384, on) SetMenuAttribute( 808, 16384, on) SetMenuAttribute( 809, 16384, on) SetMenuAttribute( 814, 16384, on) paste = clipcheck(format) & (format=256) & browse()=0 SetMenuAttribute( 810, 16384, paste) SetMenuAttribute( 811, 16384, paste) SetMenuAttribute( 812, 16384, paste) compile if WANT_STACK_CMDS compile if WANT_STACK_CMDS = 'SWITCH' if stack_cmds then compile endif SetMenuAttribute( 820, 16384, on) SetMenuAttribute( 821, 16384, mark_stack<>'') SetMenuAttribute( 822, 16384, mark_stack<>'') SetMenuAttribute( 824, 16384, position_stack<>'') SetMenuAttribute( 825, 16384, position_stack<>'') compile if WANT_STACK_CMDS = 'SWITCH' endif compile endif compile endif compile if EVERSION > 5.19 undoaction 1, PresentState -- Do to fix range, not for value. undoaction 6, StateRange -- query range parse value staterange with oldeststate neweststate . SetMenuAttribute( 818, 16384, oldeststate<>neweststate ) -- Set to 1 if different compile endif return endif if menuid=4 then -- Options compile if RING_OPTIONAL if ring_enabled then compile endif SetMenuAttribute( 410, 16384, filesinring()>1) compile if RING_OPTIONAL endif compile endif return endif compile if WANT_CUA_MARKING = 'SWITCH' | WANT_STREAM_MODE = 'SWITCH' | RING_OPTIONAL | WANT_STACK_CMDS = 'SWITCH' if menuid=400 then -- Options / Preferences compile if WANT_CUA_MARKING = 'SWITCH' SetMenuAttribute( 441, 8192, CUA_marking_switch) compile endif compile if WANT_STREAM_MODE = 'SWITCH' SetMenuAttribute( 442, 8192, not stream_mode) compile endif compile if RING_OPTIONAL SetMenuAttribute( 443, 8192, not ring_enabled) compile endif compile if WANT_STACK_CMDS = 'SWITCH' SetMenuAttribute( 445, 8192, not stack_cmds) compile endif return endif compile endif if menuid=425 then -- Options / Frame controls compile if EVERSION >= 5.53 SetMenuAttribute( 413, 8192, not queryframecontrol(1) ) SetMenuAttribute( 414, 8192, not queryframecontrol(2) ) SetMenuAttribute( 415, 8192, not queryframecontrol(16)) compile if EVERSION < 5.50 -- File icon not optional in 5.50 SetMenuAttribute( 416, 8192, not queryframecontrol(64)) compile endif compile else SetMenuAttribute( 413, 8192, not querycontrol(7) ) SetMenuAttribute( 414, 8192, not querycontrol(8) ) SetMenuAttribute( 415, 8192, not querycontrol(10)) ;; SetMenuAttribute( 416, 8192, not querycontrol(15)) compile if EVERSION < 5.50 -- File icon not optional in 5.50 SetMenuAttribute( 416, 8192, not querycontrol(22)) compile endif compile endif compile if RING_OPTIONAL if ring_enabled then compile endif compile if EVERSION >= 5.53 SetMenuAttribute( 417, 8192, not queryframecontrol(4)) compile else SetMenuAttribute( 417, 8192, not querycontrol(20)) compile endif compile if RING_OPTIONAL else SetMenuAttribute( 417, 16384, 1) -- Grey out Rotate Buttons if ring not enabled endif compile endif compile if EVERSION >= 5.53 SetMenuAttribute( 421, 8192, not queryframecontrol(32)) compile else SetMenuAttribute( 421, 8192, not querycontrol(23)) compile endif compile if WANT_DYNAMIC_PROMPTS SetMenuAttribute( 422, 8192, not menu_prompt) compile endif return endif if menuid=3 then -- Search getsearch strng parse value strng with . c . -- blank, 'c', or 'l' SetMenuAttribute( 302, 16384, c<>'') -- Find Next OK if not blank SetMenuAttribute( 303, 16384, lastchangeargs<>'') -- Change Next only if 'c' return endif compile if WANT_BOOKMARKS if menuid=305 then -- Search do_array 3, EPM_utility_array_ID, 'bmi.0', bmcount -- Index says how many bookmarks there are SetMenuAttribute( 308, 16384, bmcount>0) SetMenuAttribute( 311, 16384, bmcount>0) SetMenuAttribute( 312, 16384, bmcount>0) return endif compile endif -- WANT_BOOKMARKS tryinclude 'mymnuini.e' -- For user-supplied additions to this routine. compile endif -- INCLUDE_MENU_SUPPORT defproc SetMenuAttribute( menuid, attr, on) if not on then attr=mpfrom2short(attr, attr) endif call windowmessage(1, getpminfo(EPMINFO_EDITMENUHWND), 402, menuid + 65536, attr) defc processname = newname = arg(1) if newname<>'' & newname<>.filename then compile if defined(PROCESSNAME_CMD) -- Let the user override this, if desired. PROCESSNAME_CMD newname compile else 'name' newname compile endif endif defc undo = undo defc popbook = compile if EVERSION >= 5.50 & EPATH<>'LAMPATH' call windowmessage(0, getpminfo(APP_HANDLE), 13, -- WM_ACTIVATE 1, getpminfo(APP_HANDLE)) compile elseif EVERSION >= 5.21 & EPATH<>'LAMPATH' call windowmessage(0, getpminfo(APP_HANDLE), 5142, -- EPM_POP_BOOK_ICON 0, 0) compile else call dynalink( 'PMWIN', 'WINSETWINDOWPOS', gethwnd(EPMINFO_OWNERFRAME) || atoi(0) || atoi(3) || /* HWND_TOP */ atoi(0) || atoi(0) || atoi(0 ) || atoi(0 ) || atoi(132 )) /* SWP_ACTIVATE + SWP_ZORDER */ compile endif defc printdlg compile if EVERSION >= '5.50' if arg(1)<>'M' then call windowmessage(0, getpminfo(APP_HANDLE), 5144, -- EPM_PRINTDLG 0, put_in_buffer(.filename)) return endif compile else if arg(1)='M' then compile endif call checkmark() -- verify there is a marked area, compile if EVERSION < '5.50' endif compile endif App = 'PM_SPOOLER_PRINTER'\0 inidata = copies(' ',255) l = dynalink( 'PMSHAPI', 'PRFQUERYPROFILESTRING', atol(0) || -- HINI_PROFILE selector(App) || -- pointer to application name offset(App) || atol(0) || -- Key name is NULL; returns all keys atol(0) || -- Default return string is NULL selector(inidata)|| -- pointer to returned string buffer offset(inidata) || atol_swap(255), 2) -- max length of returned string if not l then sayerror NO_PRINTERS__MSG; return; endif parse value queryprofile($HINI_PARMU 'PM_SPOOLER', 'PRINTER') with default_printername ';' inidata=leftstr(inidata,l) 'xcom e /c /q tempfile' if rc<>-282 then -- sayerror('New file') sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc) return endif .autosave = 0 ;; deleteline 1 ;compile if EVERSION < 5.50 parse value queryprofile($HINI_PARMU 'PM_SPOOLER_PRINTER_DESCR', default_printername) with descr ';' insertline default_printername '('descr')', .last+1 -- Place default first. ;compile else ; default_entry = 1 ;compile endif do while inidata<>'' parse value inidata with printername \0 inidata if printername=default_printername then ;compile if EVERSION < 5.50 iterate ;compile else ; default_entry = .last ;compile endif endif parse value queryprofile($HINI_PARMU 'PM_SPOOLER_PRINTER_DESCR', printername) with descr ';' insertline printername '('descr')', .last+1 enddo buflen = filesize() + .last + 1 bufhndl = buffer(CREATEBUF, 'LISTBOX', buflen, 1 ) -- create a private buffer if not bufhndl then sayerror 'CREATEBUF' ERROR_NUMBER__MSG RC; return; endif noflines = buffer(PUTBUF, bufhndl, 1, 0, APPENDCR) last = .last .modify = 0 'xcom quit' if not noflines then sayerror 'PUTBUF' ERROR_NUMBER__MSG RC; return; endif usedsize = buffer(USEDSIZEBUF,bufhndl) compile if EVERSION < 5.50 ret = listbox(SELECT_PRINTER__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32),'',1,5) compile else parse value listbox(PRINT__MSG, \0 || atoi(usedsize) || atoi(bufhndl) || atoi(32), '/'DRAFT__MSG'/'WYSIWYG__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0, atoi(1/*default_entry*/) || atoi(1) || atoi(6060) || gethwndc(APP_HANDLE) || SELECT_PRINTER__MSG) with button 2 printername ' (' \0 compile endif call buffer(FREEBUF, bufhndl) compile if EVERSION < 5.50 if ret='' then return; endif parse value ret with printername ' (' compile else if button<>\1 & button<>\2 then return; endif compile endif parse value queryprofile($HINI_PARMU 'PM_SPOOLER_PRINTER', printername) with dev ';' . ';' queue ';' compile if EVERSION >= 5.50 if button=\1 then -- Draft compile endif if dev='' then sayerror PRINTER__MSG printername NO_DEVICE__MSG else if arg(1)='M' then 'print' dev -- PRINT command will print the marked area else compile if EVERSION < '5.50' 'xcom save' dev -- Save the file to the printer compile else 'xcom save /ne' dev -- Save the file to the printer compile endif endif endif compile if EVERSION >= 5.50 elseif button=\2 then -- WYSIWYG if queue='' then sayerror PRINTER__MSG printername NO_QUEUE__MSG else if arg(1)='M' then getmark firstline,lastline,firstcol,lastcol,markfileid getfileid fileid mt=marktype() 'xcom e /n' /* Create a temporary no-name file. */ if rc=-282 then -- sayerror("New file") if mt='LINE' then deleteline endif elseif rc then stop endif getfileid tempofid .levelofattributesupport = markfileid.levelofattributesupport .font = markfileid.font call pcopy_mark() if rc then stop endif call pset_mark(firstline,lastline,firstcol,lastcol,mt,markfileid) activatefile tempofid sayerror PRINTING_MARK__MSG else sayerror PRINTING__MSG .filename endif mouse_setpointer WAIT_POINTER ;; qprint queue qprint printername if arg(1)='M' then .modify=0; 'xcom q' endif mouse_setpointer EPM_POINTER sayerror 0 /* clear 'printing' message */ endif -- have queue endif -- button 2 compile endif defc printfile if arg(1)<>'' then compile if EVERSION < '5.50' 'xcom save' arg(1) -- Save the file to the printer compile else 'xcom save /ne' arg(1) -- Save the file to the printer compile endif endif compile if EVERSION >= 5.50 defc qprint if arg(1)='' then sayerror PRINTER__MSG /*printername*/ NO_QUEUE__MSG else mouse_setpointer WAIT_POINTER qprint arg(1) mouse_setpointer EPM_POINTER endif compile endif compile if WANT_CUA_MARKING = 'SWITCH' defc CUA_mark_toggle universal CUA_marking_switch CUA_marking_switch = not CUA_marking_switch 'togglecontrol 25' CUA_marking_switch call MH_set_mouse() compile endif compile if WANT_STREAM_MODE = 'SWITCH' defc stream_toggle universal stream_mode stream_mode = not stream_mode 'togglecontrol 24' stream_mode compile endif compile if RING_OPTIONAL defc ring_toggle universal ring_enabled universal activemenu, defaultmenu ring_enabled = not ring_enabled compile if EVERSION < 5.53 'togglecontrol 20' ring_enabled compile else 'toggleframe 4' ring_enabled compile endif deletemenu defaultmenu, 2, 0, 1 -- Delete the file menu call add_file_menu(defaultmenu) deletemenu defaultmenu, 4, 0, 1 -- Delete the file menu call add_options_menu(defaultmenu, dos_version()>=1020) if activemenu=defaultmenu then showmenu activemenu endif compile endif compile if WANT_STACK_CMDS = 'SWITCH' defc stack_toggle universal stack_cmds universal activemenu, defaultmenu stack_cmds = not stack_cmds deletemenu defaultmenu, 8, 0, 1 -- Delete the edit menu call add_edit_menu(defaultmenu) if activemenu=defaultmenu then showmenu activemenu endif compile endif compile if WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21 ; This will be moved into the notebook control, so no NLS translation for the temporary macro code. defc config_enter compile if EPATH = 'LAMPATH' call dynalink( 'LAMRES', 'LAMRESENTERKEYDIALOG', gethwnd(EPMINFO_EDITFRAME) || gethwnd(EPMINFO_EDITFRAME) ) compile else universal enterkey, a_enterkey, c_enterkey, s_enterkey universal padenterkey, a_padenterkey, c_padenterkey, s_padenterkey compile if WANT_STREAM_MODE = 'SWITCH' universal stream_mode compile endif 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/'); if k=='' then return endif parse value k with k '. ' keyname select = listbox('Select an action for the' keyname 'key:', '/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/') if select=='' then return endif parse value select with select '.' if k=1 then enterkey= select elseif k=2 then a_enterkey= select elseif k=3 then c_enterkey= select elseif k=4 then s_enterkey= select elseif k=5 then padenterkey= select elseif k=6 then a_padenterkey= select elseif k=7 then c_padenterkey= select else s_padenterkey= select endif compile if WANT_STREAM_MODE = 'SWITCH' if stream_mode then call winmessagebox('Stream mode active','Key change will not be visible until stream mode is turned off.', 16432) -- MB_OK + MB_INFORMATION + MB_MOVEABLE endif compile endif compile endif -- LAMPATH compile endif -- WANT_STREAM_MODE <> 1 & ENHANCED_ENTER_KEYS & EVERSION < 5.21 defc helpmenu -- send EPM icon window a help message. call windowmessage(0, getpminfo(APP_HANDLE), 5133, -- EPM_HelpMgrPanel arg(1), -- mp1 = 0=Help for help, 1=index; 2=TOC; 256... =panel # 0) -- mp2 = NULL defc ibmmsg ever = EVERSION if \0 = rightstr(EVERSION,1) then ever=leftstr(EVERSION,length(eversion)-1) endif compile if EPATH = 'LAMPATH' call WinMessageBox("LaMail", LAMAIL_VER__MSG "2.0"\13EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384) compile else call WinMessageBox(EDITOR__MSG, EDITOR_VER__MSG ver(0)\13MACROS_VER__MSG ever\13\13COPYRIGHT__MSG, 16384) compile endif defproc screenxysize( cxcy ) -- syntax : retvalue =screenxysize( 'Y' or 'X' ) return dynalink( 'PMWIN', 'WINQUERYSYSVALUE', atoi(0) || atoi(1) || atoi(20 + (upcase(cxcy)='Y'))) defproc put_in_buffer(string) if string='' then -- Was a string given? return 0 -- If not, return a null pointer. endif if arg(2)='' then share=0; else share=arg(2); endif strbuffer = "??" -- Initialize string pointer. r = dynalink('DOSCALLS', -- Dynamic link library name '#34', -- DosAllocSeg atoi(length(string)+1) || -- Number of bytes requested selector(strbuffer) || -- String selector offset(strbuffer) || -- String offset atoi(share)) -- Share information if r then sayerror ERROR__MSG r ALLOC_HALTED__MSG; stop; endif strbuffer = itoa(strbuffer,10) poke strbuffer,0,string -- Copy string to new allocated buf poke strbuffer,length(string),\0 -- Add a null at the end return mpfrom2short(strbuffer,0) -- Return a long pointer to buffer compile if EVERSION > 5.20 defc loadaccel universal activeaccel activeaccel='defaccel' compile if INCLUDE_MENU_SUPPORT -- Help key ;; buildacceltable activeaccel, 'helpmenu 4000', AF_VIRTUALKEY, VK_F1, 1000 -- Build keys on File menu buildacceltable activeaccel, 'dokey F8', AF_VIRTUALKEY, VK_F8, 1101 -- F8 buildacceltable activeaccel, 'dokey c+O', AF_CHAR+AF_CONTROL, 79, 1102 -- c+O buildacceltable activeaccel, 'dokey c+O', AF_CHAR+AF_CONTROL, 111, 1103 -- c+o buildacceltable activeaccel, 'dokey F7', AF_VIRTUALKEY, VK_F7, 1104 -- F7 buildacceltable activeaccel, 'dokey F2', AF_VIRTUALKEY, VK_F2, 1105 -- F2 buildacceltable activeaccel, 'dokey F3', AF_VIRTUALKEY, VK_F3, 1106 -- F3 buildacceltable activeaccel, 'dokey F4', AF_VIRTUALKEY, VK_F4, 1107 -- F4 -- Build keys on Edit menu ('C' & 'O' appear under Action bar keys for English) ; buildacceltable activeaccel, 'dokey a+C', AF_CHAR+AF_ALT, 67, 1201 -- a+C ; buildacceltable activeaccel, 'dokey a+C', AF_CHAR+AF_ALT, 99, 1202 -- a+c buildacceltable activeaccel, 'dokey a+M', AF_CHAR+AF_ALT, 77, 1203 -- a+M buildacceltable activeaccel, 'dokey a+M', AF_CHAR+AF_ALT, 109, 1204 -- a+m ; buildacceltable activeaccel, 'dokey a+O', AF_CHAR+AF_ALT, 79, 1205 -- a+O ; buildacceltable activeaccel, 'dokey a+O', AF_CHAR+AF_ALT, 111, 1206 -- a+o buildacceltable activeaccel, 'dokey a+A', AF_CHAR+AF_ALT, 65, 1207 -- a+A buildacceltable activeaccel, 'dokey a+A', AF_CHAR+AF_ALT, 97, 1208 -- a+a buildacceltable activeaccel, 'dokey a+U', AF_CHAR+AF_ALT, 85, 1209 -- a+U buildacceltable activeaccel, 'dokey a+U', AF_CHAR+AF_ALT, 117, 1210 -- a+u buildacceltable activeaccel, 'dokey a+D', AF_CHAR+AF_ALT, 68, 1211 -- a+D buildacceltable activeaccel, 'dokey a+D', AF_CHAR+AF_ALT, 100, 1212 -- a+d buildacceltable activeaccel, 'copy2clip', AF_VIRTUALKEY+AF_CONTROL, VK_INSERT, 1213 -- c+Insert buildacceltable activeaccel, 'cut', AF_VIRTUALKEY+AF_SHIFT, VK_DELETE, 1214 -- s+Delete buildacceltable activeaccel, 'paste' DEFAULT_PASTE, AF_VIRTUALKEY+AF_SHIFT, VK_INSERT, 1215 -- s+Insert buildacceltable activeaccel, 'dokey F9', AF_VIRTUALKEY, VK_F9, 1216 -- F9 compile if EVERSION >= 5.50 buildacceltable activeaccel, 'dokey c+Y', AF_CHAR+AF_CONTROL, 89, 1217 -- c+Y buildacceltable activeaccel, 'dokey c+Y', AF_CHAR+AF_CONTROL, 121, 1218 -- c+y compile endif buildacceltable activeaccel, 'select_all',AF_CHAR+AF_CONTROL, 47, 1219 -- c+/ buildacceltable activeaccel, 'DUPMARK U', AF_CHAR+AF_CONTROL, 92, 1220 -- c+\ -- Build keys on Search menu buildacceltable activeaccel, 'dokey c+S', AF_CHAR+AF_CONTROL, 83, 1301 -- c+S buildacceltable activeaccel, 'dokey c+S', AF_CHAR+AF_CONTROL, 115, 1302 -- c+s buildacceltable activeaccel, 'dokey c+F', AF_CHAR+AF_CONTROL, 70, 1303 -- c+F buildacceltable activeaccel, 'dokey c+F', AF_CHAR+AF_CONTROL, 102, 1304 -- c+f buildacceltable activeaccel, 'dokey c+C', AF_CHAR+AF_CONTROL, 67, 1305 -- c+C buildacceltable activeaccel, 'dokey c+C', AF_CHAR+AF_CONTROL, 99, 1306 -- c+c -- Build keys on Bookmark submenu buildacceltable activeaccel, 'dokey c+B', AF_CHAR+AF_CONTROL, 66, 1355 -- c+B buildacceltable activeaccel, 'dokey c+B', AF_CHAR+AF_CONTROL, 98, 1356 -- c+b -- Build keys on Options menu buildacceltable activeaccel, 'dokey c+G', AF_CHAR+AF_CONTROL, 71, 1401 -- c+G buildacceltable activeaccel, 'dokey c+G', AF_CHAR+AF_CONTROL, 103, 1402 -- c+g -- Build keys on Command menu buildacceltable activeaccel, 'dokey c+I', AF_CHAR+AF_CONTROL, 73, 1501 -- c+I buildacceltable activeaccel, 'dokey c+I', AF_CHAR+AF_CONTROL, 105, 1502 -- c+i -- Block action bar accelerator keys (English) compile if BLOCK_ACTIONBAR_ACCELERATORS buildacceltable activeaccel, 'dokey a+'FILE_ACCEL__L, AF_CHAR+AF_ALT, FILE_ACCEL__A1 , 1001 -- a+F buildacceltable activeaccel, 'dokey a+'FILE_ACCEL__L, AF_CHAR+AF_ALT, FILE_ACCEL__A2 , 1002 -- a+f buildacceltable activeaccel, 'dokey a+'EDIT_ACCEL__L, AF_CHAR+AF_ALT, EDIT_ACCEL__A1 , 1003 -- a+E buildacceltable activeaccel, 'dokey a+'EDIT_ACCEL__L, AF_CHAR+AF_ALT, EDIT_ACCEL__A2 , 1004 -- a+e buildacceltable activeaccel, 'dokey a+'SEARCH_ACCEL__L, AF_CHAR+AF_ALT, SEARCH_ACCEL__A1 , 1005 -- a+S buildacceltable activeaccel, 'dokey a+'SEARCH_ACCEL__L, AF_CHAR+AF_ALT, SEARCH_ACCEL__A2 , 1006 -- a+s buildacceltable activeaccel, 'dokey a+'OPTIONS_ACCEL__L, AF_CHAR+AF_ALT, OPTIONS_ACCEL__A1, 1007 -- a+O buildacceltable activeaccel, 'dokey a+'OPTIONS_ACCEL__L, AF_CHAR+AF_ALT, OPTIONS_ACCEL__A2, 1008 -- a+o buildacceltable activeaccel, 'dokey a+'COMMAND_ACCEL__L, AF_CHAR+AF_ALT, COMMAND_ACCEL__A1, 1009 -- a+C buildacceltable activeaccel, 'dokey a+'COMMAND_ACCEL__L, AF_CHAR+AF_ALT, COMMAND_ACCEL__A2, 1010 -- a+c buildacceltable activeaccel, 'dokey a+'HELP_ACCEL__L, AF_CHAR+AF_ALT, HELP_ACCEL__A1 , 1011 -- a+H buildacceltable activeaccel, 'dokey a+'HELP_ACCEL__L, AF_CHAR+AF_ALT, HELP_ACCEL__A2 , 1012 -- a+h compile if MENU_LIMIT buildacceltable activeaccel, 'dokey a+'RING_ACCEL__L, AF_CHAR+AF_ALT, RING_ACCEL__A1 , 1013 -- a+R buildacceltable activeaccel, 'dokey a+'RING_ACCEL__L, AF_CHAR+AF_ALT, RING_ACCEL__A2 , 1014 -- a+r compile endif compile endif compile endif -- INCLUDE_MENU_SUPPORT buildacceltable activeaccel, 'Alt_enter 1', AF_VIRTUALKEY+AF_ALT, VK_NEWLINE, 1080 -- Alt+Enter buildacceltable activeaccel, 'Alt_enter 2', AF_VIRTUALKEY+AF_ALT, VK_ENTER, 1081 -- Alt+PadEnter buildacceltable activeaccel, 'Alt_enter 3', AF_VIRTUALKEY+AF_SHIFT,VK_NEWLINE, 1082 -- Shift+Enter buildacceltable activeaccel, 'Alt_enter 4', AF_VIRTUALKEY+AF_SHIFT, VK_ENTER, 1083 -- Shift+PadEnter compile if defined(BLOCK_ALT_KEY) buildacceltable activeaccel, 'beep 2000 50', AF_VIRTUALKEY+AF_LONEKEY, VK_ALT, 1020 compile endif activateacceltable activeaccel compile if defined(BLOCK_ALT_KEY) defc beep = parse arg pitch duration .; call beep(pitch, duration) compile endif defc alt_enter = compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> '' -- define each key separately universal a_enterkey, a_padenterkey, s_enterkey, s_padenterkey call enter_common(substr(a_enterkey||a_padenterkey||s_enterkey||s_padenterkey,arg(1),1)) compile else executekey enter compile endif defc dokey executekey resolve_key(arg(1)) compile endif -- EVERSION >= 5.20 defc rename name = .filename if name=UNNAMED_FILE_NAME then name=''; endif compile if EVERSION >= 5.21 parse value entrybox(RENAME__MSG, '', name, 0, 240, ; atoi(1) || atoi(0) || gethwndc(APP_HANDLE) || atoi(1) || atoi(0) || atol(0) || RENAME_PROMPT__MSG '<' directory() '>') with button 2 name \0 if button=\1 & name<>'' then 'name' name; endif compile else name = entrybox(RENAME__MSG, '', name) if name<>'' then 'name' name; endif compile endif defc maybe_reflow_ALL do i = 1 to .last if textline(i)<>'' then -- Only ask if there's text in the file. if askyesno(REFLOW_ALL__MSG,1) = YES_CHAR then 'reflow_all' endif leave endif enddo compile if EVERSION >= 5.21 ; Called with a string to set the statusline text to that string; with no argument ; to just set the statusline color. defc setstatusline universal vSTATUSCOLOR, current_status_template if arg(1) then current_status_template = arg(1) compile if EVERSION >= 5.53 template=atoi(length(current_status_template)) || current_status_template compile else template=chr(length(current_status_template)) || current_status_template compile endif template_ptr=put_in_buffer(template) else template_ptr=0 endif call windowmessage(1, getpminfo(EPMINFO_EDITCLIENT), 5431, -- EPM_FRAME_STATUSLINE template_ptr, vSTATUSCOLOR) ; Called with a string to set the messageline text to that string; with no argument ; to just set the messageline color. defc setmessageline universal vMESSAGECOLOR if arg(1) then template=chr(length(arg(1))) || arg(1) template_ptr=put_in_buffer(template) else template_ptr=0 endif call windowmessage(1, getpminfo(EPMINFO_EDITCLIENT), 5432, -- EPM_FRAME_MESSAGELINE template_ptr, vMESSAGECOLOR) compile endif defc new getfileid startfid 'xcom e /n' if rc<>-282 then return; endif -- sayerror 'New file' getfileid newfid activatefile startfid temp = startfid -- temp fix for some bug 'quit' getfileid curfid activatefile newfid if curfid=startfid then -- Wasn't quit; user must have said Cancel to Quit dlg 'xcom quit' endif compile if 0 defc QueryHLP = sayerror '"'QueryCurrentHLPFiles()'"' defproc QueryCurrentHLPFiles() universal CurrentHLPFiles; return CurrentHLPFiles; defc setHLP = sayerror '"'SetCurrentHLPFiles(arg(1))'"' defproc SetCurrentHLPFiles(newlist) universal CurrentHLPFiles; hwndHelpInst = windowmessage(1, getpminfo(APP_HANDLE), 5139, -- EPM_QueryHelpInstance 0, 0) if hwndHelpInst==0 then -- there isn't a help instance deal with. return "No Help Instance"; endif newlist2 = newlist || chr(0); retval = windowmessage(1, hwndHelpInst, 557, -- HM_SET_HELP_LIBRARY_NAME ltoa(offset(newlist2) || selector(newlist2), 10), 0) if retval==0 then -- it worked, now remember what you told it. CurrentHLPFiles = newlist; else -- failed for some reason, anyway, we had better revert to -- the previous version of the HLP list. if CurrentHLPFiles=="" then CurrentHLPFiles = " "; endif newlist2 = CurrentHLPFiles || chr(0); retval2 = windowmessage(1, hwndHelpInst, 557, -- HM_SET_HELP_LIBRARY_NAME ltoa(offset(newlist2) || selector(newlist2), 10), 0) if retval2==0 then -- whew, we were able to revert to the old list return retval; else return "two errors" retval retval2; endif endif compile endif compile if not EXTRA_EX include 'EPM_EA.E' compile endif