Article View: comp.sys.amiga.tech
Article #2541Re: Clipboard device...
From: Juergen Hermann
Date: Mon, 04 Dec 1989 01:26
Date: Mon, 04 Dec 1989 01:26
88 lines
2540 bytes
2540 bytes
In article <22940@gryphon.COM> yonge@pnet02.gryphon.com (Yam Hui) writes:
>that I could use anywhere, including the manuals. The sample code in the ROM
>kernal manual does not work at all, and came without comments.
Well, this is uncommented also, but I can assure you that it works :-).
It's written for Manx 3.6 w/ 16 bit ints, but should also work with
Lattice.
It writes a global array of lines (lines[i].buf) to the clipboard,
formatted as IFF.FTXT.
void ClipStr (ClipIO, str, len)
struct IOClipReq * ClipIO;
char * str;
int len;
{
ClipIO->io_Command = CMD_WRITE;
ClipIO->io_Flags = 0;
ClipIO->io_Data = (STRPTR) str;
ClipIO->io_Length = (LONG) len;
DoIO (ClipIO);
} /* ClipStr */
int clip_msg ()
{
struct MsgPort * Port = NULL;
struct IOClipReq * ClipIO = NULL;
long length;
register i;
int err = 0;
if (line_count > 0) {
err = 1;
if ((Port = CreatePort (NULL, 0L)) != NULL &&
(ClipIO = CreateExtIO (Port, (long) sizeof (*ClipIO))) != NULL) {
if (OpenDevice ("clipboard.device", PRIMARY_CLIP, ClipIO, 0L) == 0L) {
for (i = 0, length = 0L; i < line_count; i++) {
length += strlen (lines[i].buf) + 1L;
}
ClipIO->io_Offset = 0L;
ClipIO->io_ClipID = 0L;
length += 12L;
ClipStr (ClipIO, "FORM", 4);
ClipStr (ClipIO, &length, 4);
ClipStr (ClipIO, "FTXTCHRS", 8);
length -= 12L;
ClipStr (ClipIO, &length, 4);
for (i = 0; i < line_count; i++) {
ClipStr (ClipIO, lines[i].buf, strlen (lines[i].buf));
ClipStr (ClipIO, "\n", 1);
}
if (length & 1L) {
ClipStr (ClipIO, "", 1L);
}
ClipIO->io_Command = CMD_UPDATE;
DoIO (ClipIO);
CloseDevice (ClipIO);
err = 0;
}
}
if (ClipIO) {
DeleteExtIO (ClipIO);
}
if (Port) {
DeletePort (Port);
}
}
return (err);
} /* clip_msg */
--
// Juergen Hermann root@ccave.smurf.ira.uka.de
\X/ 75 Karlsruhe 1, FRG Fido: 2:241/2.1212@FidoNet
Technical Details
Message-ID:
<85@ccave.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!mit-amt!snorkelwacker!ira.uka.de!smurf!ccave!rootReferences:
<22940@gryphon.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!mit-amt!snorkelwacker!ira.uka.de!smurf!ccave!root From: root@ccave.UUCP (Juergen Hermann) Newsgroups: comp.sys.amiga.tech Subject: Re: Clipboard device... Summary: Code to access the clipboard.device Keywords: clipboard.device Message-ID: <85@ccave.UUCP> Date: 4 Dec 89 01:26:23 GMT References: <22940@gryphon.COM> Reply-To: root@ccave.UUCP (Juergen Hermann) Organization: Chameleon's Cave [JDCP 0.96] Lines: 88