home *** CD-ROM | disk | FTP | other *** search
- /*
- ***************************************************************************
- *
- * Datei:
- * RSysClip.c
- *
- * Inhalt:
- * void SaveListToClip(struct List *list, char *text);
- * void RSysListToClip(void);
- * void RSysEntryToClip(void);
- *
- * Bemerkungen:
- * Unterstützung des ClipBoard-Devices.
- *
- * Erstellungsdatum:
- * 07-Jul-93 Rolf Böhme
- *
- * Änderungen:
- * 07-Jul-93 Rolf Böhme Erstellung
- *
- ***************************************************************************
- */
-
- #include "RSysFunc.h"
- #include "RSysDebug.h"
-
- #define ID_FTXT MAKE_ID('F','T','X','T')
- #define ID_CHRS MAKE_ID('C','H','R','S')
-
- void
- SaveListToClip(struct List *list,char *text)
- {
- char Success = FALSE;
- struct Node *node;
- int len;
- struct IFFHandle *Handle;
-
- DPOS;
-
- if (IFFParseBase = OpenLibrary ((UBYTE *)"iffparse.library", 0L))
- {
- if(Handle = AllocIFF())
- {
- if(Handle->iff_Stream = (ULONG)OpenClipboard(PRIMARY_CLIP))
- {
- InitIFFasClip(Handle);
-
- if(!OpenIFF(Handle,IFFF_WRITE))
- {
- if(!PushChunk(Handle,ID_FTXT,ID_FORM,IFFSIZE_UNKNOWN))
- {
- if(!PushChunk(Handle,0,ID_CHRS,IFFSIZE_UNKNOWN))
- {
- if(list != NULL)
- {
- for(node = list->lh_Head; node->ln_Succ; node = node->ln_Succ)
- {
- len = strlen(node->ln_Name);
-
- if(WriteChunkBytes(Handle,node->ln_Name,len) != len)
- break;
-
- if(WriteChunkBytes(Handle,"\n",1) != 1)
- break;
- }
- }
- else
- {
- len = strlen(text);
-
- if(WriteChunkBytes(Handle,(STRPTR)text,len) != len)
- Success = FALSE;
- }
-
- if(!PopChunk(Handle))
- Success = TRUE;
- }
- }
-
- if(Success)
- {
- if(PopChunk(Handle))
- Success = FALSE;
- }
-
- CloseIFF(Handle);
- }
-
- CloseClipboard((struct ClipboardHandle *)Handle->iff_Stream);
- }
-
- FreeIFF(Handle);
- }
-
- CloseLibrary (IFFParseBase);
- }
-
- if(!Success)
- ErrorHandle(CLIPBOARD_ERR, WRITE_FAIL, NO_KILL);
-
- return;
- }
-
- void
- RSysListToClip(void)
- {
- PrintInfo("Saving List to clipboard", SPEAK, 0);
-
- SaveListToClip(&ListeLVList, NULL);
-
- PrintStatistics();
-
- return;
- }
-
- void
- RSysEntryToClip(void)
- {
- register struct IntuiMessage *message;
- APTR object;
- ULONG class,
- code;
-
- DPOS;
-
- Flags.quit_clip = 0;
-
- PrintInfo("Select list entry (ESC to cancel)", SPEAK, 0);
-
- do
- {
- /*
- * Warten auf folgende Events:
- * - ^C wurde eingegeben
- * - Events vom Hauptfenster
- */
- Wait(1L << SysWnd->UserPort->mp_SigBit);
-
- while ((message = (struct IntuiMessage *)
- GT_GetIMsg(SysWnd->UserPort)) != NULL)
- {
- /*
- * Die wichtigsten Daten werden aus der erhaltenen
- * Nachricht kopiert.
- */
- object = message->IAddress;
- class = message->Class;
- code = message->Code;
-
- /*
- * Die Nachricht wird sofort beantwortet, damit
- * Intuition nicht länger als notwendig auf eine
- * Antwort wartet.
- */
- GT_ReplyIMsg(message);
-
- if(class == IDCMP_GADGETUP)
- {
- if(((struct Gadget *)object)->GadgetID == GD_ListeLV)
- {
- struct Node *node;
-
- if(node = GetNode(&ListeLVList,code))
- {
- SaveListToClip(NULL, node->ln_Name);
- Flags.quit_clip = 1;
- }
- }
- }
-
- if((class == IDCMP_VANILLAKEY) && (code == '\33'))
- {
- Flags.quit_clip = 1;
- PrintInfo("Selection aborted!",SPEAK, SEC);
- }
- }
- }
- while(NOT(Flags.quit_clip));
-
- PrintStatistics();
-
- return;
- }
-
-