From 1f84be6944ee48b72a33cf064661fa1a2129b885 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 22 Oct 2010 20:30:06 +0200 Subject: [PATCH] Make starting new variation dependent on shift key The shift key is read during mouse events, and posted in a global variable, which can then be used by the back-end. The decision to start a new variation (pushing the game tail rather than clipping it off) when entring a move in Edit Game or Analyze mode is made dependent on this. The move-typein also records the shift-key state. --- backend.c | 3 ++- frontend.h | 1 + winboard/winboard.c | 5 ++++- xboard.c | 6 ++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index 8a63a43..ea13ca8 100644 --- a/backend.c +++ b/backend.c @@ -449,6 +449,7 @@ int adjudicateLossPlies = 6; char white_holding[64], black_holding[64]; TimeMark lastNodeCountTime; long lastNodeCount=0; +int shiftKey; // [HGM] set by mouse handler int have_sent_ICS_logon = 0; int sending_ICS_login = 0; @@ -6160,7 +6161,7 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) the previous line in Analysis Mode */ if ((gameMode == AnalyzeMode || gameMode == EditGame) && currentMove < forwardMostMove) { - if(appData.variations) PushTail(currentMove, forwardMostMove); // [HGM] vari: save tail of game + if(appData.variations && shiftKey) PushTail(currentMove, forwardMostMove); // [HGM] vari: save tail of game else forwardMostMove = currentMove; } diff --git a/frontend.h b/frontend.h index 15a955c..14fa176 100644 --- a/frontend.h +++ b/frontend.h @@ -160,6 +160,7 @@ void CmailSigHandlerCallBack P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); extern ProcRef cmailPR; +extern int shiftKey; /* in xgamelist.c or winboard.c */ void GLT_ClearList(); diff --git a/winboard/winboard.c b/winboard/winboard.c index 50102ca..afef6ae 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -4073,6 +4073,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) x = BOARD_WIDTH - 1 - x; } + shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status + switch (message) { case WM_LBUTTONDOWN: if (PtInRect((LPRECT) &whiteRect, pt)) { @@ -6365,7 +6367,8 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: + case IDOK: + shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); { int n; Board board; // [HGM] FENedit diff --git a/xboard.c b/xboard.c index d9f382a..80e622e 100644 --- a/xboard.c +++ b/xboard.c @@ -1079,8 +1079,9 @@ char globalTranslations[] = \"Send to second chess program:\",,2) \n"; char boardTranslations[] = - ": HandleUserMove() \n \ - : HandleUserMove() \n \ + ": HandleUserMove(0) \n \ + Shift: HandleUserMove(1) \n \ + : HandleUserMove(0) \n \ : AnimateUserMove() \n \ : HandlePV() \n \ : PieceMenuPopup(menuB) \n \ @@ -4651,6 +4652,7 @@ void HandleUserMove(w, event, prms, nprms) Cardinal *nprms; { if (w != boardWidget || errorExitStatus != -1) return; + if(nprms) shiftKey = !strcmp(prms[0], "1"); if (promotionUp) { if (event->type == ButtonPress) { -- 1.7.0.4