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
);
54 } /* if(!PushChunk(iff, ID_FTXT, ID_CHRS, IFFSIZE_UNKNOWN)) */
57 } /* if(!PushChunk(iff, ID_FTXT, ID_FORM, IFFSIZE_UNKNOWN)) */
60 } /* if(!OpenIFF(iff,IFFF_WRITE)) */
61 CloseClipboard((struct ClipboardHandle
*)iff
->iff_Stream
);
63 } /* if((iff->iff_Stream = (IPTR)OpenClipboard(clipunit))) */
66 } /* if((iff = AllocIFF()))) */
70 STRPTR
clipboard_read_text(void)
72 struct IFFHandle
*iff
;
73 struct ContextNode
*cn
;
76 if((iff
= AllocIFF()))
78 if((iff
->iff_Stream
= (IPTR
)OpenClipboard(0)))
82 if(!OpenIFF(iff
, IFFF_READ
))
84 if (!(StopChunk(iff
, ID_FTXT
, ID_CHRS
)))
86 if (!ParseIFF(iff
, IFFPARSE_SCAN
))
88 cn
= CurrentChunk(iff
);
90 if ((cn
->cn_Type
== ID_FTXT
) && (cn
->cn_ID
== ID_CHRS
) && (cn
->cn_Size
> 0))
92 if ((retval
= mui_alloc(cn
->cn_Size
+ 1)))
94 ReadChunkBytes(iff
, retval
, cn
->cn_Size
);
96 retval
[cn
->cn_Size
] = '\0';
99 } /* if ((cn->cn_Type == ID_FTXT) && (cn->cn_ID == ID_CHRS) && (cn->cn_Size > 0)) */
101 } /* if (!ParseIFF(iff, IFFPARSE_SCAN)) */
103 } /* if (!(StopChunk(iff, ID_FTXT, ID_CHRS))) */
107 } /* if(!OpenIFF(iff, IFFF_READ)) */
108 CloseClipboard((struct ClipboardHandle
*)iff
->iff_Stream
);
110 } /* if((iff->iff_Stream = (IPTR)OpenClipboard(clipunit))) */
113 } /* if((iff = AllocIFF()))) */
118 void clipboard_free_text(STRPTR text
)