X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwclipbrd.c;h=55b9dfd712e2fb0674d3083aca7b4a0ac4e34852;hb=e59f2b1735fb0ef47b63a1fc560edcc58826ef58;hp=dbb47a7d18341530052c6e95b6aa98003807ad45;hpb=a180888cfea059c10e147b2357571c421cb4346f;p=xboard.git diff --git a/winboard/wclipbrd.c b/winboard/wclipbrd.c index dbb47a7..55b9dfd 100644 --- a/winboard/wclipbrd.c +++ b/winboard/wclipbrd.c @@ -1,6 +1,6 @@ /* * wclipbrd.c -- Clipboard routines for WinBoard - * $Id: wclipbrd.c,v 2.1 2003/10/27 19:21:02 mann Exp $ + * $Id: wclipbrd.c,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 2000 Free Software Foundation, Inc. * @@ -47,7 +47,7 @@ CopyFENToClipboard() { char *fen = NULL; - fen = PositionToFEN(currentMove); + fen = PositionToFEN(currentMove,1); if (!fen) { DisplayError("Unable to convert position to FEN.", 0); return; @@ -57,6 +57,38 @@ CopyFENToClipboard() free(fen); } +/* [AS] */ +HGLOBAL ExportGameListAsText(); + +VOID CopyGameListToClipboard() +{ + HGLOBAL hMem = ExportGameListAsText(); + + if( hMem != NULL ) { + /* Assign memory block to clipboard */ + BOOL ok = OpenClipboard( hwndMain ); + + if( ok ) { + ok = EmptyClipboard(); + + if( ok ) { + if( hMem != SetClipboardData( CF_TEXT, hMem ) ) { + ok = FALSE; + } + } + + CloseClipboard(); + + if( ! ok ) { + GlobalFree( hMem ); + } + } + + if( ! ok ) { + DisplayError( "Cannot copy list to clipboard.", 0 ); + } + } +} VOID CopyGameToClipboard() @@ -194,16 +226,16 @@ CopyTextToClipboard(char *text) return TRUE; } -/* [AS] Reworked paste functions so they can work with strings too */ - -VOID PasteFENFromString( char * fen ) -{ - if (appData.debugMode) { - fprintf(debugFP, "PasteFenFromString(): fen '%s'\n", fen); - } - EditPositionPasteFEN(fen); /* call into backend */ - free(fen); -} +/* [AS] Reworked paste functions so they can work with strings too */ + +VOID PasteFENFromString( char * fen ) +{ + if (appData.debugMode) { + fprintf(debugFP, "PasteFenFromString(): fen '%s'\n", fen); + } + EditPositionPasteFEN(fen); /* call into backend */ + free(fen); +} VOID @@ -214,10 +246,10 @@ PasteFENFromClipboard() DisplayError("Unable to paste FEN from clipboard.", 0); return; } - PasteFENFromString( fen ); + PasteFENFromString( fen ); } -VOID PasteGameFromString( char * buf ) +VOID PasteGameFromString( char * buf ) { FILE *f; size_t len; @@ -227,55 +259,55 @@ VOID PasteGameFromString( char * buf ) f = fopen(pasteTemp, "w"); if (!f) { DisplayError("Unable to create temporary file.", 0); - free(buf); /* [AS] */ + free(buf); /* [AS] */ return; } len = fwrite(buf, sizeof(char), strlen(buf), f); fclose(f); if (len != strlen(buf)) { DisplayError("Error writing to temporary file.", 0); - free(buf); /* [AS] */ + free(buf); /* [AS] */ return; } LoadGameFromFile(pasteTemp, 0, "Clipboard", TRUE); - free( buf ); /* [AS] */ -} - - -VOID -PasteGameFromClipboard() -{ - /* Write the clipboard to a temp file, then let LoadGameFromFile() - * do all the work. */ - char *buf; - if (!PasteTextFromClipboard(&buf)) { - return; - } - PasteGameFromString( buf ); + free( buf ); /* [AS] */ +} + + +VOID +PasteGameFromClipboard() +{ + /* Write the clipboard to a temp file, then let LoadGameFromFile() + * do all the work. */ + char *buf; + if (!PasteTextFromClipboard(&buf)) { + return; + } + PasteGameFromString( buf ); } -/* [AS] Try to detect whether the clipboard contains FEN or PGN data */ -VOID PasteGameOrFENFromClipboard() -{ - char *buf; - char *tmp; - - if (!PasteTextFromClipboard(&buf)) { - return; - } - - tmp = buf; - while( *tmp == ' ' || *tmp == '\t' || *tmp == '\r' || *tmp == '\n' ) { - tmp++; - } - - if( *tmp == '[' ) { - PasteGameFromString( buf ); - } - else { - PasteFENFromString( buf ); - } -} +/* [AS] Try to detect whether the clipboard contains FEN or PGN data */ +VOID PasteGameOrFENFromClipboard() +{ + char *buf; + char *tmp; + + if (!PasteTextFromClipboard(&buf)) { + return; + } + + tmp = buf; + while( *tmp == ' ' || *tmp == '\t' || *tmp == '\r' || *tmp == '\n' ) { + tmp++; + } + + if( *tmp == '[' ) { + PasteGameFromString( buf ); + } + else { + PasteFENFromString( buf ); + } +} int PasteTextFromClipboard(char **text)