Allow adding played move to book
[xboard.git] / dialogs.c
index 0e15c59..fdf6d11 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -1171,6 +1171,8 @@ EditCommentProc ()
 static void changeTags P((int n));
 static char *tagsText, **resPtr;
 
+static int TagsClick P((Option *opt, int n, int x, int y, char *val, int index));
+
 static int
 NewTagsCallback (int n)
 {
@@ -1180,13 +1182,27 @@ NewTagsCallback (int n)
     return 1;
 }
 
+static void
+NewMove ()
+{
+    addToBookFlag = !addToBookFlag;
+}
+
 static Option tagsOptions[] = {
 {   0,   0,   0, NULL, NULL, NULL, NULL, Label,  NULL },
-{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, "", NULL, TextBox, "" },
-{   0,   0, 100, NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") },
+{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, "", (char **) &TagsClick, TextBox, "" },
+{   0,   0, 100, NULL, (void*) &NewMove,    NULL, NULL, Button, N_("add next move") },
+{ 0,SAME_ROW,100,NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") },
 { 0,SAME_ROW, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" }
 };
 
+static int TagsClick (Option *opt, int n, int x, int y, char *val, int index)
+{
+    if(!bookUp || n != 3) return FALSE; // only button-3 press in Edit Book is of interest
+    PlayBookMove(val, index);
+    return TRUE;
+}
+
 static void
 changeTags (int n)
 {
@@ -1201,6 +1217,7 @@ NewTagsPopup (char *text, char *msg)
 {
     char *title = bookUp ? _("Edit book") : _("Tags");
 
+    tagsOptions[2].type = bookUp ? Button : Skip;
     if(DialogExists(TagsDlg)) { // if already exists, alter title and content
        SetWidgetText(&tagsOptions[1], text, TagsDlg);
        SetDialogTitle(TagsDlg, title);
@@ -1237,6 +1254,12 @@ EditTagsProc ()
   if (bookUp || !PopDown(TagsDlg)) EditTagsEvent();
 }
 
+void
+AddBookMove (char *text)
+{
+    AppendText(&tagsOptions[1], text);
+}
+
 //---------------------------------------------- ICS Input Box ----------------------------------
 
 char *icsText;