2 Copyright © 1999, David Le Corfec.
3 Copyright © 2002, The AROS Development Team.
14 #include <exec/types.h>
15 #include <exec/memory.h>
17 #include <clib/alib_protos.h>
18 #include <libraries/iffparse.h>
19 #include <datatypes/textclass.h>
20 #include <proto/exec.h>
21 #include <proto/iffparse.h>
22 #include <proto/utility.h>
25 #include "clipboard.h"
28 #include "muimaster_intern.h"
33 extern struct Library
*MUIMasterBase
;
35 void clipboard_write_text(STRPTR text
, LONG textlen
)
37 struct IFFHandle
*iff
;
39 if ((iff
= AllocIFF()))
41 if ((iff
->iff_Stream
= (IPTR
) OpenClipboard(0)))
44 if (!OpenIFF(iff
, IFFF_WRITE
))
46 if (!PushChunk(iff
, ID_FTXT
, ID_FORM
, IFFSIZE_UNKNOWN
))
48 if (!PushChunk(iff
, ID_FTXT
, ID_CHRS
, IFFSIZE_UNKNOWN
))
50 WriteChunkBytes(iff
, text
, textlen
);
59 CloseClipboard((struct ClipboardHandle
*)iff
->iff_Stream
);
65 STRPTR
clipboard_read_text(void)
67 struct IFFHandle
*iff
;
68 struct ContextNode
*cn
;
71 if ((iff
= AllocIFF()))
73 if ((iff
->iff_Stream
= (IPTR
) OpenClipboard(0)))
77 if (!OpenIFF(iff
, IFFF_READ
))
79 if (!(StopChunk(iff
, ID_FTXT
, ID_CHRS
)))
81 if (!ParseIFF(iff
, IFFPARSE_SCAN
))
83 cn
= CurrentChunk(iff
);
85 if ((cn
->cn_Type
== ID_FTXT
)
86 && (cn
->cn_ID
== ID_CHRS
) && (cn
->cn_Size
> 0))
88 if ((retval
= mui_alloc(cn
->cn_Size
+ 1)))
90 ReadChunkBytes(iff
, retval
, cn
->cn_Size
);
92 retval
[cn
->cn_Size
] = '\0';
99 CloseClipboard((struct ClipboardHandle
*)iff
->iff_Stream
);
108 void clipboard_free_text(STRPTR text
)