void EditBookEvent P((void));
Boolean DisplayBook P((int moveNr));
void SaveToBook P((char *text));
+void PlayBookMove P((char *text, int index));
void HoverEvent P((int hiX, int hiY, int x, int y));
int PackGame P((Board board));
Boolean ParseFEN P((Board board, int *blackPlaysFirst, char *fen, Boolean autoSize));
}
void
+PlayBookMove(char *text, int index)
+{
+ char *start = text+index, *end = start;
+ while(start > text && start[-1] != ' ' && start[-1] != '\t') start--;
+ while(*end && *++end != ' ' && *end != '\n'); *end = NULLCHAR; // find clicked word
+ if(start != end) TypeInDoneEvent(start); // fake it was typed in move type-in
+}
+
+void
FlushBook ()
{
FILE *f;
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)
{
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, "" },
+{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, "", (char **) &TagsClick, TextBox, "" },
{ 0, 0, 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)
{
GetClientRect(hDlg, &rect);\r
sizeX = rect.right;\r
sizeY = rect.bottom;\r
+ SendDlgItemMessage( hDlg, OPT_TagsText, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );\r
if (wpTags.x != CW_USEDEFAULT && wpTags.y != CW_USEDEFAULT &&\r
wpTags.width != CW_USEDEFAULT && wpTags.height != CW_USEDEFAULT) {\r
WINDOWPLACEMENT wp;\r
}\r
break;\r
\r
+ case WM_NOTIFY: // [HGM] vari: cloned from whistory.c\r
+ if( wParam == OPT_TagsText ) {\r
+ MSGFILTER * lpMF = (MSGFILTER *) lParam;\r
+\r
+ if( lpMF->msg == WM_RBUTTONDOWN ) {\r
+ POINTL pt;\r
+ LRESULT index;\r
+\r
+ pt.x = LOWORD( lpMF->lParam );\r
+ pt.y = HIWORD( lpMF->lParam );\r
+\r
+ index = SendDlgItemMessage( hDlg, OPT_TagsText, EM_CHARFROMPOS, 0, (LPARAM) &pt );\r
+\r
+ hwndText = GetDlgItem(hDlg, OPT_TagsText); // cloned from above\r
+ len = GetWindowTextLength(hwndText);\r
+ str = (char *) malloc(len + 1);\r
+ GetWindowText(hwndText, str, len + 1);\r
+ if(bookUp) PlayBookMove(str, index);\r
+ free(str);\r
+\r
+ /* Zap the message for good: apparently, returning non-zero is not enough */\r
+ lpMF->msg = WM_USER;\r
+\r
+ return TRUE;\r
+ }\r
+ }\r
+ break;\r
+\r
case WM_SIZE:\r
newSizeX = LOWORD(lParam);\r
newSizeY = HIWORD(lParam);\r