From 0e642a2b9658ccaef62bf668f9d51598ee3a7deb Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 18 Feb 2010 16:05:35 +0100 Subject: [PATCH] Add Annotate item in Step menu This does the same as Revert, except that it adds the destroyed variation as comment to the original movem in PGN variation format. RevertEvent now has an argument to indicate if it should add the comment, or not. Comments in the abandoned variation are included in the varriation command to the main line. (The exact layout of the variation comment that results leaves still to be desired.) --- backend.c | 5 +++-- backend.h | 2 +- winboard/resource.h | 1 + winboard/winboard.c | 11 +++++++++-- winboard/winboard.rc | 1 + xboard.c | 23 ++++++++++++++++++++++- 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/backend.c b/backend.c index e2dddbc..932e5bb 100644 --- a/backend.c +++ b/backend.c @@ -12667,9 +12667,9 @@ ToNrEvent(int to) } void -RevertEvent() +RevertEvent(Boolean annotate) { - if(PopTail(TRUE)) { // [HGM] vari: restore old game tail + if(PopTail(annotate)) { // [HGM] vari: restore old game tail return; } if (gameMode != IcsExamining) { @@ -15055,6 +15055,7 @@ PopTail(Boolean annotate) sprintf(moveBuf, " %d. %s", i+2>>1, SavePart(parseList[i])); else sprintf(moveBuf, " %s", SavePart(parseList[i])); strcat(buf, moveBuf); + if(commentList[i]) { strcat(buf, " "); strcat(buf, commentList[i]); } if(!--cnt) { strcat(buf, "\n"); cnt = 10; } } strcat(buf, ")"); diff --git a/backend.h b/backend.h index 3aeb318..aac6ab1 100644 --- a/backend.h +++ b/backend.h @@ -154,7 +154,7 @@ void BackwardEvent P((void)); void ToEndEvent P((void)); void ToStartEvent P((void)); void ToNrEvent P((int to)); -void RevertEvent P((void)); +void RevertEvent P((Boolean annotate)); void RetractMoveEvent P((void)); void MoveNowEvent P((void)); void TruncateGameEvent P((void)); diff --git a/winboard/resource.h b/winboard/resource.h index f6a1f5f..9699ddd 100644 --- a/winboard/resource.h +++ b/winboard/resource.h @@ -54,6 +54,7 @@ #define IDM_Debug 174 #define IDM_AnalysisMode 177 #define IDM_AnalyzeFile 178 +#define IDM_Annotate 179 #define IDM_CopyGame 180 #define IDM_PasteGame 181 #define IDM_CopyPosition 182 diff --git a/winboard/winboard.c b/winboard/winboard.c index 8053123..e0a6969 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -867,7 +867,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) if(q) *q++ = 0; if(*p) ChatPopUp(p); } while(p=q); -// Sleep(1000); } SetActiveWindow(hwndConsole); } @@ -4665,7 +4664,11 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_Revert: - RevertEvent(); + RevertEvent(FALSE); + break; + + case IDM_Annotate: // [HGM] vari: revert with annotation + RevertEvent(TRUE); break; case IDM_TruncateGame: @@ -7307,6 +7310,7 @@ GreyRevert(Boolean grey) { // [HGM] vari: for retracting variations in local mode HMENU hmenu = GetMenu(hwndMain); EnableMenuItem(hmenu, IDM_Revert, MF_BYCOMMAND|(grey ? MF_GRAYED : MF_ENABLED)); + EnableMenuItem(hmenu, IDM_Annotate, MF_BYCOMMAND|(grey ? MF_GRAYED : MF_ENABLED)); } VOID @@ -7330,6 +7334,7 @@ Enables gnuEnables[] = { { IDM_StopObserving, MF_BYCOMMAND|MF_GRAYED }, { IDM_Upload, MF_BYCOMMAND|MF_GRAYED }, { IDM_Revert, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, { IDM_NewChat, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -7350,6 +7355,7 @@ Enables icsEnables[] = { { IDM_IcsOptions, MF_BYCOMMAND|MF_ENABLED }, { IDM_Engine1Options, MF_BYCOMMAND|MF_GRAYED }, { IDM_Engine2Options, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -7374,6 +7380,7 @@ Enables ncpEnables[] = { { IDM_IcsClient, MF_BYCOMMAND|MF_GRAYED }, { ACTION_POS, MF_BYPOSITION|MF_GRAYED }, { IDM_Revert, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, { IDM_MoveNow, MF_BYCOMMAND|MF_GRAYED }, { IDM_RetractMove, MF_BYCOMMAND|MF_GRAYED }, { IDM_TimeControl, MF_BYCOMMAND|MF_GRAYED }, diff --git a/winboard/winboard.rc b/winboard/winboard.rc index 35f202f..d945a95 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -1160,6 +1160,7 @@ BEGIN MENUITEM "Back to &Start\tAlt+Home", IDM_ToStart MENUITEM "Forward to &End\tAlt+End", IDM_ToEnd MENUITEM "Re&vert", IDM_Revert + MENUITEM "&Annotate", IDM_Annotate MENUITEM "&Truncate Game", IDM_TruncateGame MENUITEM SEPARATOR MENUITEM "&Move Now\tCtrl+M", IDM_MoveNow diff --git a/xboard.c b/xboard.c index 55cb8d9..1cf2ef2 100644 --- a/xboard.c +++ b/xboard.c @@ -369,6 +369,7 @@ void ForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void ToStartProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void ToEndProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void RevertProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void AnnotateProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void TruncateGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void RetractMoveProc P((Widget w, XEvent *event, String *prms, @@ -657,6 +658,7 @@ MenuItem stepMenu[] = { {N_("Back to Start"), ToStartProc}, {N_("Forward to End"), ToEndProc}, {N_("Revert"), RevertProc}, + {N_("Annotate"), AnnotateProc}, {N_("Truncate Game"), TruncateGameProc}, {"----", NothingProc}, {N_("Move Now"), MoveNowProc}, @@ -914,6 +916,7 @@ XtActionsRec boardActions[] = { { "ToStartProc", ToStartProc }, { "ToEndProc", ToEndProc }, { "RevertProc", RevertProc }, + { "AnnotateProc", AnnotateProc }, { "TruncateGameProc", TruncateGameProc }, { "MoveNowProc", MoveNowProc }, { "RetractMoveProc", RetractMoveProc }, @@ -2624,6 +2627,12 @@ GreyRevert(grey) } else { XtSetSensitive(w, !grey); } + w = XtNameToWidget(menuBarWidget, "menuStep.Annotate"); + if (w == NULL) { + DisplayError("menuStep.Annotate", 0); + } else { + XtSetSensitive(w, !grey); + } } void @@ -2659,6 +2668,7 @@ Enables icsEnables[] = { { "menuOptions.Hide Thinking", False }, { "menuOptions.Ponder Next Move", False }, #endif + { "menuStep.Annotate", False }, { NULL, False } }; @@ -2674,6 +2684,7 @@ Enables ncpEnables[] = { { "menuMode.ICS Input Box", False }, { "Action", False }, { "menuStep.Revert", False }, + { "menuStep.Annotate", False }, { "menuStep.Move Now", False }, { "menuStep.Retract Move", False }, { "menuOptions.Auto Comment", False }, @@ -2704,6 +2715,7 @@ Enables gnuEnables[] = { { "menuAction.Stop Observing", False }, { "menuAction.Upload to Examine", False }, { "menuStep.Revert", False }, + { "menuStep.Annotate", False }, { "menuOptions.Auto Comment", False }, { "menuOptions.Auto Observe", False }, { "menuOptions.Auto Raise Board", False }, @@ -6247,7 +6259,16 @@ void RevertProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - RevertEvent(); + RevertEvent(False); +} + +void AnnotateProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + RevertEvent(True); } void TruncateGameProc(w, event, prms, nprms) -- 1.7.0.4