'Cut/Copy/Paste'

'Cut/Copy/Paste'

As of version 3.5.4, 4C supports Cut/Copy/Paste operations between 4C applications and non 4C applications. Cut and Copy from a 4C application are similar and are discussed first. Pasting into a 4C application is a little more complicated and will be discussed later in this document.


'Cut/Copy'

If you have a 3.5.4 client installed, then Cut and Copy are enabled. You do not need to make any changes to your application for bitmaps, defalt text, and default DIF formats to be copied to the client clipboard. Once in the clipboard, other applications can access that data. You can change what gets copied to the clipboard if you have 4C server version 3.5.4 or higher installed. You do this by defining PCLs to be called when either the 'cut' or the 'copy' key is pressed, just as you would for any other function key.

Here is how 4C handles the copy key if the application does not catch it.

So, as a default, when the 4C Client copies data to the clipboard, it may appear there in only bitmap format, in bitmap format, text format, and DIF format, or in bitmap format, text format, DIF format and 4C format. Only 4C applications will be able to make use of the 4C format but word processors can easily use the text and bitmap formats as well

The application cannot override copying the bitmap to the clipboard, but it can change the text that gets copied, it can change the 4C format data that gets copied, and it may also copy data in DIF format which can be used by spreadsheets. In order to do so, it catches the copy key and then sends the data by using the following SysPCLs.

The general idea is to call sys.cbc_init() once, then send all the data for each of the formats that you want sent to the clipboard and finish it by calling sys.cbc_end() once. For each type of data that you want to send, you must call sys.cbc_open() once and then send the data and then call sys.cbc_close() once. The data is sent by making multiple calls to sys.cbc_senddata() or sys.cbc_sendtext().

It is not necessary, to send all data formats. If you catch the <copy> key in a scrolling program and you want to send the default text, but different 4C format data, then only send the 4C format data. The clipboard will still have the bitmap format and the text format when a user tries to paste data.

The only trick to sending data is letting 4C know what data you want to send. This is done by specifying an <asfile> in the sys.cbc_open(), sys.cbc_senddata(), and sys.cbc_close() calls. You make sure that the file buffers have the correct data before calling sys.cbc_senddata() and 4C will format it correctly.

Cut is implemented similarly. The only difference is that if you are running 4CSrvr version 3.5.4 or higher and you do not process the <cut> key, then in addition to copying the selection to the clipboard, 4C will treat the <cut> like an unhandled <delete>. This default behaviour only affects scrolling programs.


'Paste'



Pasting data into a 4C application requires both 4CClient and 4CServer to be version 3.5.4 or higher. Pasting data is only allowed in 4C programs where it has been specifically enabled. There are two ways to enable pasting into a 4C application.

The first way is to catch the <paste> key and have the application do all the processing with a little help from the sys.cbp_ SysPCLs. This can be used for any type program but is harder to implement than the second way. The sys.prog.mstr program and the sys.ph.maint program both catch the <paste> key and then do their own processing of it.

The other way is to just check the "Paste OK" box in the default driver options screen or call sys.set_droption(DR_PASTEOK) in the DrInit PCL. This method can only be used in scrolling screens. When a scrolling program enables pasting this way and the client pastes data, 4C will automate the processing by going through a series of state changes, each of which allows the application to call a PCL or to allow default processing. The sys.df.maint1 program handles the <paste> key using this method.

The 3 New Program States used for pasting are PasteInit, PasteSelect, and PasteEnd. You can specify PCLs to call in these states in program characteristics by selecting ProgPaste from the context menu. Here is what happens and what you are allowed to do in each of the paste states. At the end of the paste operation, 4C will redisplay the current page on the screen and eventually reach the EndPage state again.

The best example of implementing paste in this way is sys.df.maint1. Look at the code and try different pastes. See what happens when you:

The following SysPCLs are meant for use by an application processing a paste.


Misc Issues



Back to Top