Implement -autoCopyPV
[xboard.git] / backend.c
index d219f97..06c3145 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -735,10 +735,10 @@ ClearOptions (ChessProgramState *cps)
 
 char *engineNames[] = {
   /* TRANSLATORS: "first" is the first of possible two chess engines. It is inserted into strings
-     such as "% engine" / "%s chess program" / "%s machine" - all meaning the same thing */
+     such as "%s engine" / "%s chess program" / "%s machine" - all meaning the same thing */
 N_("first"),
   /* TRANSLATORS: "second" is the second of possible two chess engines. It is inserted into strings
-     such as "% engine" / "%s chess program" / "%s machine" - all meaning the same thing */
+     such as "%s engine" / "%s chess program" / "%s machine" - all meaning the same thing */
 N_("second")
 };
 
@@ -5451,6 +5451,7 @@ UnLoadPV ()
 {
   int oldFMM = forwardMostMove; // N.B.: this was currentMove before PV was loaded!
   if(endPV < 0) return;
+  if(appData.autoCopyPV) CopyFENToClipboard();
   endPV = -1;
   if(gameMode == AnalyzeMode && currentMove > forwardMostMove) {
        Boolean saveAnimate = appData.animate;
@@ -10072,6 +10073,18 @@ NextMatchGame ()
 {   // performs game initialization that does not invoke engines, and then tries to start the game
     int res, firstWhite, swapColors = 0;
     if(!NextTourneyGame(nextGame, &swapColors)) return; // this sets matchGame, -fcp / -scp and other options for next game, if needed
+    if(matchMode && appData.debugMode) { // [HGM] debug split: game is part of a match; we might have to create a debug file just for this game
+       char buf[MSG_SIZ];
+       snprintf(buf, MSG_SIZ, appData.nameOfDebugFile, nextGame+1); // expand name of debug file with %d in it
+       if(strcmp(buf, currentDebugFile)) { // name has changed
+           FILE *f = fopen(buf, "w");
+           if(f) { // if opening the new file failed, just keep using the old one
+               ASSIGN(currentDebugFile, buf);
+               fclose(debugFP);
+               debugFP = f;
+           }
+       }
+    }
     firstWhite = appData.firstPlaysBlack ^ (matchGame & 1 | appData.sameColorGames > 1); // non-incremental default
     firstWhite ^= swapColors; // reverses if NextTourneyGame says we are in an odd round
     first.twoMachinesColor =  firstWhite ? "white\n" : "black\n";   // perform actual color assignement
@@ -13385,17 +13398,6 @@ TwoMachinesEvent P((void))
        break;
     }
 
-    if(matchMode && appData.debugMode) { // [HGM] debug split: game is part of a match; we might have to create a debug file just for this game
-       snprintf(buf, MSG_SIZ, appData.nameOfDebugFile, nextGame+1); // expand name of debug file with %d in it
-       if(strcmp(buf, currentDebugFile)) { // name has changed
-           FILE *f = fopen(buf, "w");
-           if(f) { // if opening the new file failed, just keep using the old one
-               ASSIGN(currentDebugFile, buf);
-               fclose(debugFP);
-               debugFP = f;
-           }
-       }
-    }
 //    forwardMostMove = currentMove;
     TruncateGame(); // [HGM] vari: MachineWhite and MachineBlack do this...
 
@@ -13909,6 +13911,8 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y)
             } else
            boards[0][y][x] = selection;
            DrawPosition(TRUE, boards[0]);
+           ClearHighlights();
+           fromX = fromY = -1;
        }
        break;
     }