Automaticaly install Java engines
[xboard.git] / winboard / wedittags.c
index 0cf3ca3..bd34038 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
  * wedittags.c -- EditTags window for WinBoard\r
  *\r
- * Copyright 1995, 2009, 2010 Free Software Foundation, Inc.\r
+ * Copyright 1995, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
@@ -42,7 +42,7 @@
 #define _(s) T_(s)\r
 \r
 /* Module globals */\r
-static char *editTagsText;\r
+static char *editTagsText, **resPtr;\r
 BOOL editTagsUp = FALSE;\r
 BOOL canEditTags = FALSE;\r
 \r
@@ -73,6 +73,10 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     EnableWindow(GetDlgItem(hDlg, OPT_TagsCancel), canEditTags);\r
     EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags);\r
     SendMessage(hwndText, EM_SETREADONLY, !canEditTags, 0);\r
+    if (bookUp) {\r
+      SetWindowText(hDlg, _("Edit Book"));\r
+      SetFocus(hwndText);\r
+    } else\r
     if (canEditTags) {\r
       SetWindowText(hDlg, _("Edit Tags"));\r
       SetFocus(hwndText);\r
@@ -114,6 +118,7 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND:\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
+    case OPT_TagsSave:\r
       if (canEditTags) {\r
        char *p, *q;\r
        /* Read changed options from the dialog box */\r
@@ -122,18 +127,20 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        GetWindowText(hwndText, str, len + 1);\r
        p = q = str;\r
        while (*q) {\r
-         if (*q == '\r'|| *q == '\n')\r
+         if (*q == '\r')\r
            q++;\r
          else\r
            *p++ = *q++;\r
        }\r
-       *p = NULLCHAR;\r
+       *p = NULLCHAR; err = 0;\r
+        if(resPtr) *resPtr = strdup(str); else\r
+       if(bookUp) SaveToBook(str), DisplayBook(currentMove); else\r
        err = ReplaceTags(str, &gameInfo);\r
        if (err) DisplayError(_("Error replacing tags."), err);\r
 \r
        free(str);\r
       }\r
-      TagsPopDown();\r
+      if(LOWORD(wParam) == IDOK) TagsPopDown();\r
       return TRUE;\r
       \r
     case IDCANCEL:\r
@@ -172,7 +179,7 @@ VOID TagsPopDown(void)
 {\r
   if (editTagsDialog) ShowWindow(editTagsDialog, SW_HIDE);\r
   CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_UNCHECKED);\r
-  editTagsUp = FALSE;\r
+  editTagsUp = bookUp = FALSE;\r
 }\r
 \r
 \r
@@ -205,6 +212,7 @@ VOID EitherTagsPopUp(char *tags, char *msg, BOOLEAN edit)
   if (editTagsDialog) {\r
     SendMessage(editTagsDialog, WM_INITDIALOG, 0, 0);\r
     ShowWindow(editTagsDialog, SW_SHOW);\r
+    if(bookUp) SetFocus(hwndMain);\r
   } else {\r
     lpProc = MakeProcInstance((FARPROC)EditTagsDialog, hInst);\r
     CreateDialog(hInst, MAKEINTRESOURCE(DLG_EditTags),\r
@@ -221,14 +229,15 @@ VOID TagsPopUp(char *tags, char *msg)
   SetActiveWindow(hwnd);\r
 }\r
 \r
-VOID EditTagsPopUp(char *tags)\r
+VOID EditTagsPopUp(char *tags, char **dest)\r
 {\r
+  resPtr = dest;\r
   EitherTagsPopUp(tags, "", TRUE);\r
 }\r
 \r
 VOID EditTagsProc()\r
 {\r
-  if (editTagsUp) {\r
+  if (editTagsUp && !bookUp) {\r
     TagsPopDown();\r
   } else {\r
     EditTagsEvent();\r