worked on premove bug
[xboard.git] / winboard / wclipbrd.c
index 55b9dfd..4d0fac9 100644 (file)
@@ -1,25 +1,27 @@
 /*\r
  * wclipbrd.c -- Clipboard routines for WinBoard\r
- * $Id: wclipbrd.c,v 2.1 2003/10/27 19:21:02 mann Exp $\r
  *\r
- * Copyright 2000 Free Software Foundation, Inc.\r
+ * Copyright 2000,2009 Free Software Foundation, Inc.\r
+ *\r
+ * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
  * ------------------------------------------------------------------------\r
- * This program is free software; you can redistribute it and/or modify\r
+ *\r
+ * GNU XBoard is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
+ * the Free Software Foundation, either version 3 of the License, or (at\r
+ * your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * GNU XBoard is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * General Public License for more details.\r
  *\r
  * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- * ------------------------------------------------------------------------\r
- */\r
+ * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
+ *\r
+ *------------------------------------------------------------------------\r
+ ** See the file ChangeLog for a revision history.  */\r
 \r
 #include "config.h"\r
 \r
@@ -37,6 +39,7 @@
 \r
 /* Imports from winboard.c */\r
 extern HWND hwndMain;\r
+Boolean ParseFEN(Board b, int *stm, char *FEN);\r
 \r
 /* File globals */\r
 static char *copyTemp;\r
@@ -47,7 +50,7 @@ CopyFENToClipboard()
 {\r
   char *fen = NULL;\r
 \r
-  fen = PositionToFEN(currentMove,1);\r
+  fen = PositionToFEN(currentMove, NULL);\r
   if (!fen) {\r
     DisplayError("Unable to convert position to FEN.", 0);\r
     return;\r
@@ -197,7 +200,7 @@ CopyTextToClipboard(char *text)
     locked = !((err == NO_ERROR) || (err == ERROR_NOT_LOCKED));\r
     if (appData.debugMode) {\r
       fprintf(debugFP, \r
-             "CopyTextToClipboard(): err %d locked %d\n", err, locked);\r
+             "CopyTextToClipboard(): err %d locked %d\n", (int)err, locked);\r
     }\r
   }\r
   if (locked) {\r
@@ -290,18 +293,24 @@ PasteGameFromClipboard()
 VOID PasteGameOrFENFromClipboard()\r
 {\r
   char *buf;\r
-  char *tmp;\r
+//  char *tmp;\r
+  Board dummyBoard; int dummy; // [HGM] paste any\r
 \r
   if (!PasteTextFromClipboard(&buf)) {\r
     return;\r
   }\r
 \r
+#if 0\r
   tmp = buf;\r
   while( *tmp == ' ' || *tmp == '\t' || *tmp == '\r' || *tmp == '\n' ) {\r
       tmp++;\r
   }\r
 \r
   if( *tmp == '[' ) {\r
+#else\r
+  // [HGM] paste any: make still smarter, to allow pasting of games without tags, recognize FEN in stead\r
+  if(!ParseFEN(dummyBoard, &dummy, buf) ) {\r
+#endif\r
       PasteGameFromString( buf );\r
   }\r
   else {\r
@@ -367,7 +376,7 @@ PasteTextFromClipboard(char **text)
     locked = !((err == NO_ERROR) || (err == ERROR_NOT_LOCKED));\r
     if (appData.debugMode) {\r
       fprintf(debugFP, \r
-             "PasteTextFromClipboard(): err %d locked %d\n", err, locked);\r
+             "PasteTextFromClipboard(): err %d locked %d\n", (int)err, locked);\r
     }\r
   }\r
   if (locked) \r