[comp.sys.amiga.advocacy] Mac clipboard

jcav@quads.uchicago.edu (john cavallino) (06/11/91)

Some factual information on exactly how the Macintosh Clipboard works, for
comparison purposes (most of this directly quotes the Scrap Manager chapter
of volume 1 of Inside Macintosh):

- - - - -

From the user's point of view, all data that's cut or copied resides in the
Clipboard.  The Cut command deletes data and places it in the Clipboard;
the Copy command copies data into the Clipboard without deleting it.  The
next Paste command, wherever it is applied, inserts the contents of the
Clipboard at a specified place.

The Scrap Manager allows for a variety of data types and provides a
mechanism whereby applications have some control over how much information
is retained when data is transferred.

From the user's point of view there is only one thing in the Clipboard at a
time, but the application may store more than one version of the
information in the scrap, each representing the same Clipboard contents in
a different form.  For example, text cut with a word processor may be
stored in the desk scrap as formatted text, as plain ASCII, and as a
Quickdraw picture.  Desk scrap data types are 32-bit numbers, treated as
sequences of 4 characters.

The two standard types are 'TEXT' (plain ASCII) and 'PICT' (a Quickdraw
picture).  Applications must write at least one of these types to the scrap
and must be able to read BOTH types.   Most applications will prefer one of
these types over the other.

An application reading the desk scrap will look for its preferred type.  If
its preferred type isn't there, or if it is but was written by an
application with a different preferred type, the application may or may not
be able to use the data fully.

In addition to the standard data types, the desk scrap may also contain
application-specific types of data.  If several applications are to support
the transfer of a private type of data, each will read and write that type,
but must also support the standard types.

The order in which the data is written is important: the application should
write out the different types in order of preference.

OS support functions (Pascal-format, sorry):

FUNCTION InfoScrap:PScrapStuff;
--return pointer to an information record, one field of which is incremented
  each time new data appears in the clipboard.

FUNCTION ZeroScrap:longint;
--clear the contents of the clipboard, incrementing the above data field
  function result negative if error occured, zero otherwise.

FUNCTION PutScrap(length:longint; theType:ResType; source:Ptr):longint;
--write length bytes of data to the clipboard, assigning it theType
  function result negative if error occured, zero otherwise.

FUNCTION GetScrap(hDest:Handle; theType:ResType; VAR offset:longint):longint;
--search for data of theType in the clipboard, read it into the memory block,
  return the offset where the data was found.  If success, function result
  is length of data, else result is negative error code.   Note: the data
  block with the lowest offset value is the preferred type.


- - - - -

I'm sorry if that was too long, but I just wanted to get out the basic facts
of the Mac side of things.


-- 
John Cavallino                      |     EMail: jcav@midway.uchicago.edu
University of Chicago Hospitals     |    USMail: 5841 S. Maryland Ave, Box 145
Office of Facilities Management     |            Chicago, IL  60637
B0 f++ c+ g+ k s+(+) e+ h- pv (qv)  | Telephone: 312-702-6900