home *** CD-ROM | disk | FTP | other *** search
- /*
- ╔════════════════════════════════════════════════════════════════════════════╗
- ║ What's it called: clipbrd.e ║
- ║ ║
- ║ What does it do: contains procedures and commands that all: ║
- ║ -Allow one to pass lines of text between edit windows ║
- ║ -Allow text to be placed in the PM clipboard ║
- ║ ║
- ║ Text Manipulation between Edit Windows ║
- ║ ====================================== ║
- ║ Copy2SharBuff - Copy Marked area to EPM shared buffer ║
- ║ GetSharBuff - Get text from EPM shared buffer ║
- ║ ClearSharBuf - Flush out Stuff in shared buffer ║
- ║ Copy2DMBuff - Copy Marked area to "Delete Mark" buffer ║
- ║ GetDMBuff - Get text from "Delete Mark" buffer ║
- ║ ║
- ║ Text Manipulation between an Edit Window and PM clipboard ║
- ║ ======================================================== ║
- ║ ║
- ║ copy2clip - copy marked text to the PM clipboard. ║
- ║ ║
- ║ cut - like copy2clip, but deletes the marked text. ║
- ║ ║
- ║ paste - retrieve text from PM clipboard to edit window. ║
- ║ ║
- ║ ║
- ║ Who and When: Ralph Yozzo, Gennaro (Jerry) Cuomo, & Larry Margolis 3-88 ║
- ║ 6/89 ║
- ╚════════════════════════════════════════════════════════════════════════════╝
- */
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Copy2SharBuff - │
- │ Copy Marked area to EPM shared buffer │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc Copy2SharBuff /* former name = CLIPBRD_pt */
- if not marktype() then /* check if mark exists */
- return /* if mark doesn't exist, return */
- endif
- /* save the dimensions of the mark */
- compile if EVERSION >= 5.50
- getmarkg fstline, /* returned: first line of mark */
- compile else
- getmark fstline, /* returned: first line of mark */
- compile endif
- 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 */
-
- getfileid fileid /* save file id of visible file */
- activatefile mkfileid /* switch to file with mark */
- /* Try to open the buffer. If it doesn't exist, create it. */
- bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER)
- if bufhndl then
- opened = 1
- else
- -- Make a 64K buffer... memory's plentiful. Easily changed.
- bufsize = MAXBUFSIZE
- bufhndl = buffer(CREATEBUF, EPMSHAREDBUFFER, bufsize)
- opened = 0
- endif
- if not bufhndl then
- sayerror CAN_NOT_OPEN__MSG EPMSHAREDBUFFER '-' ERROR_NUMBER__MSG RC
- stop
- endif
-
- /* Copy the current marked lines (up to 64k worth of data ) into EPM's */
- /* shared memory buffer. */
- compile if EVERSION >= 5.51
- call buffer(PUTMARKBUF, bufhndl, fstline, lstline, APPENDCR+APPENDLF+STRIPSPACES) -- Was +FINALNULL
- compile else -- Older versions needed the null for the copy to clipboard routine
- call buffer(PUTMARKBUF, bufhndl, fstline, lstline, APPENDCR+APPENDLF+STRIPSPACES+FINALNULL)
- compile endif
-
- compile if EVERSION >= 5.50
- poke bufhndl, 28, atol(lstline-fstline+1-(lstline>.last)) -- Remember how many lines are *supposed* to be there.
- compile else
- poke bufhndl, 28, atol(lstline-fstline+1) -- Remember how many lines are *supposed* to be there.
- compile endif
-
- activatefile fileid
- if opened then
- call buffer(FREEBUF, bufhndl)
- endif
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ GetSharBuff - │
- │ Get text from EPM shared buffer. │
- │ 'O' means Overlay instead of copy. │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc GetSharBuff /* former name = CLIPBRD_gt */
- /* EPMSHAREDBUFFER= buffer name known between edit windows */
- -- Try to open the buffer. If it doesn't exist, nothing to get.
- bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER)
- if not bufhndl then
- sayerror CAN_NOT_OPEN__MSG EPMSHAREDBUFFER '-' ERROR_NUMBER__MSG RC
- stop
- endif
- call psave_pos(save_pos)
- call GetBuffCommon(bufhndl, NO_MARK_NO_BUFF__MSG, arg(1))
- call buffer(FREEBUF, bufhndl)
- call prestore_pos(save_pos)
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ ClearSharBuff - │
- │ Flush out stuff in EPM shared buffer │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc ClearSharBuff
- bufhndl=buffer(OPENBUF, EPMSHAREDBUFFER)
- if bufhndl then
- call buffer(CLEARBUF, bufhndl)
- call buffer(FREEBUF, bufhndl)
- endif
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ copy2clip │
- │ copy marked text into the PM clipboard. │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc copy2clip
- call checkmark() /* Make sure there's a mark. */
-
- 'Copy2SharBuff' -- Recopy the marked area to the shared buffer,
- -- in case the user has modified the mark contents.
-
- /* Try to open the buffer. If it doesn't exist, then we can't copy */
- bufhndl = buffer(OPENBUF, EPMSHAREDBUFFER)
- if not bufhndl then
- return 1 /* buffer does not exist */
- endif
- if peek(bufhndl,6,2) /== peek(bufhndl,28,2) then
- sayerror TOO_MUCH_FOR_CLIPBD__MSG
- return 1
- endif
-
- compile if EVERSION < '5.50'
- hab=gethwnd(0) /* get EPM's anchorblock */
- call dynalink('PMWIN', /* Open PM's clipboard */
- 'WINOPENCLIPBRD',
- hab)
-
- call dynalink('PMWIN', -- Empty the clipboard completely
- 'WINEMPTYCLIPBRD', -- before filling it.
- hab)
- result = dynalink(EUTIL_DLL, /* create a buffer and copy */
- 'CLIPBOARDCOPY', /* the contents of the EPM */
- atoi(bufhndl)|| /* shared buffer */
- atoi(0) ||
- atoi(1), /* buffer to pm clipboard */
- 2) /* return long */
-
- /* Clipboardcopy allocates a buffer of memory */
- /* we don't have to worry about freeing the buffer that clipboardcopy */
- /* allocates... PM will free it */
-
- call dynalink('PMWIN', /* call PM function to */
- 'WINSETCLIPBRDDATA', /* move data into the PM e cb*/
- hab || /* anchor block */
- atol(result) || /* pointer to text. */
- atoi(1) || /* format (TEXT) */
- atoi(256)) /* selector */
-
- call dynalink('PMWIN',
- 'WINCLOSECLIPBRD',
- hab)
- call buffer(FREEBUF, bufhndl)
-
- compile else
- -- Copying to the Clipboard using the EToolkit message:
- -- EPM_EDIT_CLIPBOARDCOPY - mp1 = pointer to memory buffer containing
- -- contents to copy to the clipboard.
- -- mp2 = flag that describes what type of buffer
- -- was passed in mp1.
- -- 0=CF_TEXT type buffer, terminated by nul
- -- 1=EPM shared memory buffer (32byte head)
- -- When the contents of mp1 is copied to the clipboard a EPM defc event is
- -- called by the name of PROCESSCLIPBOARDCOPY. Arg(1) of this function is
- -- the original buffer passed in as mp1. The caller may choose to free
- -- the buffer during this command. if zero is passed as arg(1), an error
- -- was encountered. An error message should be displayed at this point.
-
- call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
- 5441, -- EPM_EDIT_CLIPBOARDCOPY
- mpfrom2short( bufhndl, 0),
- 1)
-
- defc processclipboardcopy
- result=arg(1)
- if not result then -- If non-zero, free the buffer.
- call buffer(FREEBUF, itoa(substr(atol(result),3,2),10)) -- pass just the selector
- endif
-
- compile endif -- EVERSION < '5.50'
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ cut │
- │ copy marked text into the PM clipboard, then delete the mark. │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc cut
- 'copy2clip'
- if not RC then
- getmark firstline,lastline,firstcol,lastcol,markfileid
- markfileid.line = firstline
- if leftstr(marktype(), 1)<>'L' then
- markfileid.col = firstcol
- endif
- call pdelete_mark()
- endif
-
- /*
- ┌─────────────────────────────────────────────────────────────────────────┐
- │ paste │
- │ │
- │ retrieve text from PM clipboard to edit window │
- │ │
- └─────────────────────────────────────────────────────────────────────────┘
- */
- defc paste
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
- if browse() then
- sayerror BROWSE_IS__MSG ON__MSG
- return
- endif
- compile if EVERSION < '5.50'
- if not clipcheck(format) then
- sayerror CLIPBOARD_ERROR__MSG
- return
- endif
- if format<>256 then -- no text in clipboard
- sayerror CLIPBOARD_EMPTY__MSG
- return
- endif
-
- compile if EPM32
- hab=gethwndc(0) -- get EPM's anchorblock
- call dynalink32('PMWIN', /* Open PM's clipboard */
- '#793', -- WINOPENCLIPBRD
- hab)
-
- result = dynalink32('PMWIN', /* call PM function to */
- '#806', -- WINQUERYCLIPBRDDATA /* look at the data in the cb*/
- hab || /* anchor block */
- atol(1), /* data format ( TEXT ) */
- 4) /* return a 4 byte result */
-
- result = dynalink32(EUTIL_DLL, /* create a buffer and copy */
- 'ClipboardCopy', /* */
- atol(result) || /* */
- atol(0), /* pm clipboard to shared buf*/
- 4) /* */
- call dynalink32('PMWIN',
- '#707', -- WINCLOSECLIPBRD
- hab)
- compile else
- hab=gethwnd(0) -- get EPM's anchorblock
- call dynalink('PMWIN', /* Open PM's clipboard */
- 'WINOPENCLIPBRD',
- hab)
-
- result = dynalink('PMWIN', /* call PM function to */
- 'WINQUERYCLIPBRDDATA', /* look at the data in the cb*/
- hab || /* anchor block */
- atoi(1), /* data format ( TEXT ) */
- 2) /* return a 4 byte result */
-
- result = dynalink(EUTIL_DLL, /* create a buffer and copy */
- 'CLIPBOARDCOPY', /* */
- atol(result) || /* */
- atoi(0), /* pm clipboard to shared buf*/
- 2) /* */
- call dynalink('PMWIN',
- 'WINCLOSECLIPBRD',
- hab)
- compile endif -- EPM32
-
- result=itoa(substr(atol(result),3,2),10) /* convert from bin to str */
- if arg(1)='C' | arg(1)='B' then
- poke result, 8, chr(68-asc(arg(1))) -- 'C'->1; 'B'->2; mark as a character or block buffer
- compile if WANT_CUA_MARKING
- if arg(1)='C' &
- compile if WANT_CUA_MARKING = 'SWITCH'
- CUA_marking_switch &
- compile endif
- marktype()
- then
- call pbegin_mark()
- call pdelete_mark()
- 'ClearSharBuff' /* Remove Content in EPM shared text buffer */
- endif
- compile endif
- call psave_mark(savemark) -- Save the user's mark
- call GetBuffCommon(result, NOTHING_TO_PASTE__MSG, arg(1))
- -- clause continued below for common stuff.
- compile else -- if EVERSION < 5.50
- -- Pasting from the PM Clipboard using the EToolkit message:
- -- EPM_EDIT_CLIPBOARDPASTE- mp1 = flag that describes the type of paste
- -- that is desired. A paste could be of
- -- the following types; 'C' for Character, 'B' for
- -- block and 'L' for line.
- -- During the processing of this message the text in the PM clipboard is
- -- queried. Once this is done an EPM defc event is
- -- called by the name of PROCESSCLIPBOARDPASTE. Arg(1) of this function
- -- contains a pointer to a buffer containing a copy of the text found in
- -- the PM clipboard. Arg(2) of this function is
- -- the original flag passed in as mp1. The caller may choose to free
- -- the buffer during this command. if zero is passed as arg(1), an error
- -- was encountered. An error message should be displayed at this point.
- mark=arg(1)
- if mark<>'C' and mark<>'B' then
- mark='L'
- endif
- call windowmessage(0, getpminfo(EPMINFO_EDITCLIENT),
- 5442, -- EPM_EDIT_CLIPBOARDPASTE
- asc(mark), 0)
-
- defc processclipboardpaste
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
-
- parse arg result mark .
- if not result then
- sayerror CLIPBOARD_ERROR__MSG
- return
- endif
-
- if mark=67 | mark=66 then -- asc('C') | asc('B')
- poke result, 8, chr(68-mark) -- 'C'->1; 'B'->2; mark as a character or block buffer
- compile if WANT_CUA_MARKING
- if mark=67 &
- compile if WANT_CUA_MARKING = 'SWITCH'
- CUA_marking_switch &
- compile endif
- marktype()
- then
- getmark x, x, x, x, mark_fid
- getfileid cur_fid
- if mark_fid=cur_fid then
- call pbegin_mark()
- call pdelete_mark()
- else
- unmark
- sayerror MARKED_OTHER__MSG
- endif
- 'ClearSharBuff' /* Remove content in EPM shared text buffer */
- endif
- compile endif
- call psave_mark(savemark) -- Save the user's mark
- call GetBuffCommon(result, NOTHING_TO_PASTE__MSG, chr(mark))
- compile endif -- EVERSION < '5.50'
- -- Two cases join here, in the middle of this IF statement.
- call prestore_mark(savemark) -- Restore the user's mark
- else
- oldsize = .last
- compile if EVERSION >= 5.50
- call buffer(GETBUF2, result) /* put buffer into text */
- compile if EVERSION >= 5.60
- if textline(.line+.last-oldsize)=='' then
- deleteline .line+.last-oldsize
- endif
- compile endif
- compile else
- call buffer(GETBUF, result) /* put buffer into text */
- compile endif -- EVERSION >= 5.50
- '+'(.last-oldsize)
- endif
-
- compile if EPM32
- call dynalink32('DOSCALLS', /* dynamic link library name */
- '#304', /* DosFreeSeg */
- ltoa(atoi(0) || atoi(result), 10))
- compile else
- call dynalink('DOSCALLS', /* dynamic link library name */
- '#39', /* DosFreeSeg */
- atoi(result))
- compile endif
-
- compile if WANT_DM_BUFFER
- definit
- universal DMbuf_handle
- DMbuf_handle = 0
-
- defexit
- universal DMbuf_handle
- if DMbuf_handle then
- call buffer(FREEBUF, DMbuf_handle) -- Free the OPEN
- endif
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Copy2DMBuff - │
- │ Copy Marked area to "Delete Mark" buffer │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc Copy2DMBuff
- universal DMbuf_handle
- themarktype = marktype()
- if not themarktype then /* check if mark exists */
- return /* if mark doesn't exist, return */
- endif
- /* save the dimensions of the mark */
- 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 themarktype='BLOCK' then -- Size of block, + 2 per line for CR, LF
- size=(lstcol-fstcol+3) * (lstline-fstline+1) + 3
- else -- Probably much larger than we need, but must assume:
- size=(MAXCOL+2) * (lstline-fstline+1) +3 -- 255 chars/line + CR, LF
- endif
- /* Try to open the buffer. If it doesn't exist or is too small, create it. */
- if not DMbuf_handle then
- DMbuf_handle = buffer(OPENBUF, EPMDMBUFFER)
- if DMbuf_handle then
- call buffer(FREEBUF, DMbuf_handle) -- Free the OPEN
- endif
- endif
- if DMbuf_handle then
- maxsize = buffer(MAXSIZEBUF,DMbuf_handle)
- if size > maxsize & maxsize < MAXBUFSIZE then
- success=buffer(FREEBUF, DMbuf_handle) -- Free the original CREATE
- if not success then
- sayerror ERROR__MSG rc TRYING_TO_FREE__MSG EPMDMBUFFER BUFFER__MSG
- endif
- DMbuf_handle = ''
- endif
- endif
- if not DMbuf_handle then
- DMbuf_handle = buffer(CREATEBUF, EPMDMBUFFER, min(size,MAXBUFSIZE), 1)
- endif
- if not DMbuf_handle then
- messageNwait(CAN_NOT_OPEN__MSG EPMDMBUFFER '-' ERROR_NUMBER__MSG RC)
- return
- endif
-
- getfileid fileid /* save file id of visible file */
- activatefile mkfileid /* switch to file with mark */
- /* Copy the current marked lines (up to 64k worth of data ) into EPM's */
- /* shared memory buffer. */
- call buffer(PUTMARKBUF, DMbuf_handle, fstline, lstline, APPENDCR+APPENDLF+STRIPSPACES)
-
- poke DMbuf_handle, 28, atol(lstline-fstline+1) -- Remember how many lines are *supposed* to be there.
-
- activatefile fileid
-
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ GetDMBuff - │
- │ Get text from "Delete Mark" buffer. │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defc GetDMBuff
- universal DMbuf_handle
- -- Try to open the buffer. If it doesn't exist, nothing to get.
- ;; DMbuf_handle = buffer(OPENBUF, EPMDMBUFFER)
- ;; -- (If it doesn't exist in this window, the lines were deleted from some other window.)
- if not DMbuf_handle then
- ;; sayerror 'Unable to open a buffer named' EPMDMBUFFER'. Error number 'RC
- sayerror NO_MARK_DELETED__MSG
- return
- endif
- call psave_mark(savemark) -- Save the user's mark
- call GetBuffCommon(DMbuf_handle, NO_TEXT_RECOVERED__MSG) -- (This marks what's recovered)
- call prestore_mark(savemark) -- Restore the user's mark
- compile endif -- WANT_DM_BUFFER
-
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ GetBuffCommon │
- │ Common code called by GetSharBuff, Paste and GetDMBuff │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- defproc GetBuffCommon(bufhndl, errormsg)
- markt = buffer(MARKTYPEBUF, bufhndl)
- getfileid activefid -- get current files file id
- if not markt & arg(3)<>'O' then -- MARKT=0 ==> line mark (simple case)
- noflines = buffer(GETBUF, bufhndl) -- Retrieve data from shared EPM buf
- if noflines then
- call pset_mark(.line+1,.line+noflines,1,MAXCOL,'LINE',activefid)
- '+'noflines
- call verify_buffer_size(bufhndl, noflines)
- else
- sayerror errormsg
- endif
- return -- ... and that's all.
- endif
-
- cur_line_len = length(textline(.line))
- 'xcom e /q /c epmbuff.cpy' -- edit a temp hidden file
- .visible=0 -- (hide file)
- getfileid tmpfileid -- get hidden file's id
-
- compile if EVERSION >= 5.50
- noflines = buffer(GETBUF2, bufhndl) -- retrieve data from shared EPM buf
- compile else
- noflines = buffer(GETBUF, bufhndl) -- retrieve data from shared EPM buf
- compile endif -- EVERSION >= 5.50
- compile if 0 -- EVERSION >= 5.50
- if arg(3)='C' then
- noflines = buffer(GETBUF2, bufhndl) -- retrieve data from shared EPM buf
- else
- ;compile endif
- ; noflines = buffer(GETBUF, bufhndl) -- retrieve data from shared EPM buf
- ;compile if EVERSION >= 5.50
- endif
- compile endif
- if not noflines then
- 'xcom quit'
- sayerror errormsg
- return
- endif
- compile if EVERSION < 5.50
- insert_attribute 13, 0, 2, 0, activefid.col, activefid.line, activefid -- Place a bookmark on the character
- compile endif
-
- compile if EVERSION >= 5.50
- orig_lines = ltoa(peek(bufhndl,28,4),10)
- compile if EVERSION = 5.50
- if orig_lines & orig_lines = noflines-1 & markt = 2 & textline(.last)==\0 then -- Block mark? Get rid of extra blank line
- compile else
- if orig_lines & orig_lines = noflines-1 & markt = 2 & textline(.last)=='' then -- Block mark? Get rid of extra blank line
- compile endif
- noflines = noflines-1
- deleteline .last
- endif
- compile endif
- length_last = length(textline(.last))
- split_start = 0; split_end = 0
- '+1' -- advance to next line in hidden
- if markt=2 | markt=4 then -- Mark type is BLOCK(G)
- markblock -- block mark first character
- noflines+1 -- advance down to last line
- if arg(3)='B' then -- Block-marking from clipboard;
- .col=longestline() -- move cursor to end of longest line
- else -- Was originally a block; width is OK.
- .col=length_last -- move to last character
- endif
- markblock -- complete block mark
- elseif markt=1 | markt=3 then -- Mark type is Character(G)
- split_start = activefid.col + length(textline(2)) > MAXCOL
- split_end = cur_line_len - activefid.col + length_last > MAXCOL
- compile if EVERSION >= 5.50
- setmark 2, .last, 1, length_last+1, 3, tmpfileid -- 3 = CHARG mark
- compile else
- mark_char -- character mark first char
- noflines+1 -- advance down to last
- .col=length_last -- move to last character
- mark_char -- complete character mark
- compile endif
- else
- mark_line -- line mark first line
- noflines+1 -- advance down to last
- mark_line -- complete line mark
- endif
-
- activatefile activefid -- activate destination file
- rc=0 -- clear return code before copy
- if arg(3)='O' then
- compile if WANT_CHAR_OPS
- call pcommon_adjust_overlay('O') -- copy mark
- compile else
- overlay_block
- compile endif
- else
- if split_end then split; endif
- if split_start then split; '+1'; begin_line; endif
- call pcopy_mark() -- copy mark
- endif
- if rc then -- Test for memory too full for copy_mark.
- display -4
- sayerror ERROR_COPYING__MSG
- display 4
- endif
-
- activatefile tmpfileid -- activate temp file
- 'xcom q' -- quit it
- activatefile activefid -- activate destination file
- compile if EVERSION < 5.50
- class = 13 -- BOOKMARK_CLASS
- col=.col+1; line=.line; offst=0
- attribute_action 1, class, offst, col, line -- 1=FIND NEXT ATTR
- if class=13 then
- query_attribute class, val, IsPush, offst, col, line
- line; .col=col
- attribute_action 16, class, offst, col, line -- 16=Delete attribute
- endif
- compile else -- 5.50 does char marks internally, so moving to the end of the mark will always work.
- call pend_mark()
- ; sayerror 'length_last='length_last'; .col='.col'; cl1, cl2 =' cl1 cl2
- if length_last then executekey right; endif
- compile endif
- call verify_buffer_size(bufhndl, noflines)
-
- defproc verify_buffer_size(bufhndl, noflines)
- orig_lines = ltoa(peek(bufhndl,28,4),10)
- if orig_lines <> noflines & orig_lines then -- If 0, assume never set.
- display -4
- sayerror ONLY__MSG noflines LINES_OF__MSG orig_lines RECOVERED__MSG
- display 4
- endif
-
- defc clipview =
- if not clipcheck(format) then
- sayerror CLIPBOARD_ERROR__MSG
- return
- endif
- if format<>256 then -- no text in clipboard
- sayerror CLIPBOARD_EMPTY__MSG
- return
- endif
- "open 'paste C' 'postme clipview2'"
-
- defc clipview2 =
- if .filename=UNNAMED_FILE_NAME then
- .filename=CLIPBOARD_VIEW_NAME
- .autosave = 0
- .modify = 0
- call browse(1)
- endif
-
- defproc clipcheck(var format) -- Returns error code; if OK, sets FORMAT
- compile if EPM32
- hab=gethwndc(0) -- get EPM's anchorblock
- format = \0\0\0\0 -- (reserve four bytes)
- rc=dynalink32('PMWIN', -- call PM function to
- '#807', -- look at the data in the cb
- hab || -- anchor block
- atol(1) || -- data format ( TEXT )
- address(format), 4)
- -- format = ltoa(format,10) -- Convert format to ASCII
- format = 1024
- compile else
- hab=gethwnd(0) -- get EPM's anchorblock
- format = \0\0 -- (reserve two bytes)
- rc=dynalink('PMWIN', -- call PM function to
- 'WINQUERYCLIPBRDFMTINFO', -- look at the data in the cb
- hab || -- anchor block
- atoi(1) || -- data format ( TEXT )
- address(format))
- -- format = itoa(format,10) -- Convert format to ASCII
- format = 256
- compile endif
- return rc
-
- compile if EVERSION >= 5.50
- defc insert_text_file
- universal default_edit_options
- get_file = strip(arg(1))
- if get_file='' then sayerror NO_FILENAME__MSG 'GET'; return; endif
- if pos(argsep,get_file) then
- sayerror INVALID_OPTION__MSG
- return
- endif
- getfileid fileid
- s_last=.last
- display -1
- 'e /q /d' get_file
- editrc=rc
- getfileid gfileid
- if editrc=sayerror('New file') | not .last then
- 'q'
- display 1
- if editrc= -2 | not .last then -- -2 = sayerror('New file') then
- sayerror FILE_NOT_FOUND__MSG': 'get_file
- else
- sayerror FILE_NOT_FOUND__MSG': 'get_file
- endif
- return
- endif
- if editrc & editrc<>-278 then -- -278 sayerror('Lines truncated') then
- display 1
- sayerror editrc
- stop
- endif
- call psave_mark(save_mark)
- compile if WANT_BOOKMARKS
- if not .levelofattributesupport then
- 'loadattributes'
- endif
- compile endif
- get_file_attrib = .levelofattributesupport
- setmark 1, .last, 1, length(textline(.last))+1, 3, gfileid -- 3 = CHARG mark
- activatefile fileid
- rc=0
- copy_mark
- copy_rc=rc -- Test for memory too full for copy_mark.
- activatefile gfileid
- 'q'
- parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt
- if fileid=s_mkfileid then -- May have to move the mark.
- diff=fileid.last-s_last -- (Adjustment for difference in size)
- if fileid.line<s_firstline then s_firstline=s_firstline+diff; endif
- if fileid.line<s_lastline then s_lastline=s_lastline+diff; endif
- endif
- call prestore_mark(s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt)
- activatefile fileid
- if get_file_attrib // 2 then
- call attribute_on(1) -- Colors flag
- endif
- if get_file_attrib % 4 - 2 * (get_file_attrib % 8) then
- call attribute_on(4) -- Mixed fonts flag
- endif
- if get_file_attrib % 8 - 2 * (get_file_attrib % 16) then
- call attribute_on(8) -- "Save attributes" flag
- endif
- display 1
- if copy_rc & copy_rc<>-281 then
- sayerror NOT_2_COPIES__MSG get_file
- endif
- compile endif