From 272e35c7f6874eae7f6f5487ad427a57212b9eca Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 6 May 2011 23:14:02 +0200 Subject: [PATCH] Let Shift+RightClick on PV actually play the PV moves --- backend.c | 18 +++++++++++++----- winboard/wengineoutput.c | 3 ++- xengineoutput.c | 4 +++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend.c b/backend.c index 8dcfbd6..a2c554f 100644 --- a/backend.c +++ b/backend.c @@ -5244,7 +5244,7 @@ ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) Boolean pushed = FALSE; void -ParsePV(char *pv, Boolean storeComments) +ParsePV(char *pv, Boolean storeComments, Boolean atEnd) { // Parse a string of PV moves, and append to current game, behind forwardMostMove int fromX, fromY, toX, toY; char promoChar; ChessMove moveType; @@ -5308,7 +5308,7 @@ fprintf(debugFP,"parsePV: %d %c%c%c%c yy='%s'\nPV = '%s'\n", valid, fromX+AAA, f else parseList[endPV-1][0] = NULLCHAR; } while(valid); - currentMove = endPV; + currentMove = (atEnd || endPV == forwardMostMove) ? endPV : forwardMostMove + 1; if(currentMove == forwardMostMove) ClearPremoveHighlights(); else SetPremoveHighlights(moveList[currentMove-1][0]-AAA, moveList[currentMove-1][1]-ONE, moveList[currentMove-1][2]-AAA, moveList[currentMove-1][3]-ONE); @@ -5331,7 +5331,7 @@ LoadMultiPV(int x, int y, char *buf, int index, int *start, int *end) do{ while(buf[index] && buf[index] != '\n') index++; } while(buf[index] == '\n' && buf[index+1] == '\\' && buf[index+2] == ' ' && index++); // join kibitzed PV continuation line buf[index] = 0; - ParsePV(buf+startPV, FALSE); + ParsePV(buf+startPV, FALSE, !shiftKey); *start = startPV; *end = index-1; return TRUE; } @@ -5341,15 +5341,23 @@ LoadPV(int x, int y) { // called on right mouse click to load PV int which = gameMode == TwoMachinesPlay && (WhiteOnMove(forwardMostMove) == (second.twoMachinesColor[0] == 'w')); lastX = x; lastY = y; - ParsePV(lastPV[which], FALSE); // load the PV of the thinking engine in the boards array. + ParsePV(lastPV[which], FALSE, TRUE); // load the PV of the thinking engine in the boards array. return TRUE; } void UnLoadPV() { + int oldFMM = forwardMostMove; // N.B.: this was currentMove before PV was loaded! if(endPV < 0) return; endPV = -1; + if(shiftKey && gameMode == AnalyzeMode) { + if(pushed) storedGames--; // abandon shelved tail of original game + pushed = FALSE; + forwardMostMove = currentMove; + currentMove = oldFMM; + ToNrEvent(forwardMostMove); + } currentMove = forwardMostMove; if(pushed) { PopInner(0); pushed = FALSE; } // restore shelved game contnuation ClearPremoveHighlights(); @@ -16248,7 +16256,7 @@ LoadVariation(int index, char *text) PushTail(currentMove, forwardMostMove); // shelve main variation. This truncates game // kludge: use ParsePV() to append variation to game move = currentMove; - ParsePV(start, TRUE); + ParsePV(start, TRUE, TRUE); forwardMostMove = endPV; endPV = -1; currentMove = move; // cleanup what ParsePV did ClearPremoveHighlights(); CommentPopDown(); diff --git a/winboard/wengineoutput.c b/winboard/wengineoutput.c index 0633f8a..301d4f6 100644 --- a/winboard/wengineoutput.c +++ b/winboard/wengineoutput.c @@ -332,7 +332,8 @@ LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARA case WM_NOTIFY: if( wParam == IDC_EngineMemo1 || wParam == IDC_EngineMemo2 ) { MSGFILTER * lpMF = (MSGFILTER *) lParam; - if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL | MK_SHIFT)) == 0 ) { + if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL)) == 0 ) { + shiftKey = (lpMF->wParam & MK_SHIFT) != 0; // [HGM] remember last shift status currentPV = (wParam == IDC_EngineMemo2); GetMemoLine(hDlg, LOWORD(lpMF->lParam), HIWORD(lpMF->lParam)); } diff --git a/xengineoutput.c b/xengineoutput.c index 5a85d7d..57a32d3 100644 --- a/xengineoutput.c +++ b/xengineoutput.c @@ -215,7 +215,8 @@ void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b); // from xopt char memoTranslations[] = ":Ctrlc: CopyMemoProc() \n \ : HandlePV() \n \ -: select-start() SelectPV() \n \ +Shift: select-start() SelectPV(1) \n \ +Any: select-start() SelectPV(0) \n \ : extend-end() StopPV() \n"; void @@ -232,6 +233,7 @@ SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams) XawTextGetSelectionPos(w, &index, &dummy); XtSetArg(arg, XtNstring, &val); XtGetValues(w, &arg, 1); + shiftKey = strcmp(params[0], "0"); if(LoadMultiPV(x, y, val, index, &start, &end)) { XawTextSetSelection( outputField[currentPV][nMemo], start, end ); highTextStart[currentPV] = start; highTextEnd[currentPV] = end; -- 1.7.0.4