Clipboard Holder

Introduction and Overview

The clipboard has been present on RISC OS for some time but is much underused. This has been addressed in RISC OS 4.2; in particular the 'standard' applications Draw, Paint and Edit have been updated with clipboard-based Cut and Paste functions in an effort to lead the initiative to see more widespread use in RISC OS.

Technical Details

To help with this, RISC OS 4.24 onwards provides two simple SWIs to provide copy and paste facilities to applications.

Data pasted onto the clipboard is stored as a typed file - much as a selection saved to the RAM disc would be.

SWI Calls

ClipboardHolder_CopySWI &54040
Copy data to the clipboard
R0=Flags:
Bit(s)Meaning
0-2Type of copy to perform:
ValueMeaning
0Memory copy
1File copy
2-7Reserved
3-31Reserved, must be zero
R1=Filetype of data
R2=Pointer to block of memory if a memory copy; pointer to filename if a file copy
R3=Length of block of memory if a memory copy; undefined for all other uses
R0 - R3=Preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This call is used to copy data to the clipboard. The data must be assigned a filetype; this allows receiving applications to understand what they are dealing with. Data may be passed to the clipboard as a file or as a block of memory.

The application must, of course, implement 'cut' itself by using the SWI ClipboardHolder_Copy SWI and then removing its own data, leaving just the copy on the clipboard.

ClipboardHolder_PasteSWI &54041
Request data to 'paste' from the clipboard
R0=Flags:
Bit(s)Meaning
0-2Type of paste to be performed:
ValueMeaning
0Paste to memory
1Paste to file
2-7Reserved
3Only check the status and filetype
4-31Reserved, must be zero
R1=Preferred filetype of data, or -1 to receive it in the format it was copied as
R2=Window handle to provide clipboard data to (or 0 for a new window)
R3=Private handle to identify request
R0=State:
Bit(s)Meaning
0Clipboard can be delivered to memory
1Clipboard can be delivered to file
2Clipboard must be delivered by the clipboard protocol
3-31Reserved, must be zero
R1=Filetype of data
R2=Pointer to block of memory if a memory copy; pointer to filename if a file copy
R3=Length of block of memory if a memory copy; preserved for file copies
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This call is used to request data to paste from the clipboard. The data has been assigned a filetype when it was copied; this allows receiving applications to understand what they are dealing with.