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