From 18886d86cbb6e962ce2d1e81069f9fa8bb55abba Mon Sep 17 00:00:00 2001 From: mazzearos Date: Thu, 2 Aug 2012 22:10:04 +0000 Subject: [PATCH] Added clipboard support for AROS. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1976 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/readline.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/readline.c b/src/readline.c index b39f2483..fd7b30de 100644 --- a/src/readline.c +++ b/src/readline.c @@ -46,6 +46,9 @@ #include #elif defined __HAIKU__ #include "haiku.h" +#elif defined(__AROS__) +#include +#include #endif // Virtual keyboard is mandatory on these platforms: @@ -252,6 +255,67 @@ char* getClipboard() } } return dst; + #elif defined(__AROS__) + + struct IFFHandle *iff = NULL; + struct ContextNode *cn; + long error=0, unitnumber=0; + char *dst = NULL; + + if (!(iff = AllocIFF ())) + { + goto bye; + } + + if (!(iff->iff_Stream = (IPTR) OpenClipboard (unitnumber))) + { + goto bye; + } + + InitIFFasClip (iff); + + if ((error = OpenIFF (iff, IFFF_READ)) != 0) + { + goto bye; + } + + if ((error = StopChunk(iff, ID_FTXT, ID_CHRS)) != 0) + { + goto bye; + } + + while(1) + { + error = ParseIFF(iff,IFFPARSE_SCAN); + if (error) break; // we're reading only the 1st chunk + + cn = CurrentChunk(iff); + + if (cn && (cn->cn_Type == ID_FTXT) && (cn->cn_ID == ID_CHRS)) + { + if ((dst = malloc(cn->cn_Size + 1)) != NULL) + { + dst[0] = '\0'; + if ((ReadChunkBytes(iff,dst,cn->cn_Size)) > 0) + { + dst[cn->cn_Size] = '\0'; + } + } + } + } + +bye: + if (iff) + { + CloseIFF (iff); + + if (iff->iff_Stream) + CloseClipboard ((struct ClipboardHandle *)iff->iff_Stream); + FreeIFF (iff); + } + + return dst; + #elif defined __HAIKU__ return haiku_get_clipboard(); #else