moveList[endPV-1][3] = toY + ONE;
parseList[endPV-1][0] = NULLCHAR;
} while(valid);
+ currentMove = endPV;
+ if(currentMove == forwardMostMove) ClearPremoveHighlights(); else
+ SetPremoveHighlights(moveList[currentMove-1][0]-AAA, moveList[currentMove-1][1]-ONE,
+ moveList[currentMove-1][2]-AAA, moveList[currentMove-1][3]-ONE);
+ DrawPosition(TRUE, boards[currentMove]);
}
static int lastX, lastY;
Boolean
+LoadMultiPV(int x, int y, char *buf, int index, int *start, int *end)
+{
+ int startPV;
+
+ if(index < 0 || index >= strlen(buf)) return FALSE; // sanity
+ lastX = x; lastY = y;
+ while(index > 0 && buf[index-1] != '\n') index--; // beginning of line
+ startPV = index;
+ while(buf[index] != '\n') if(buf[index++] == '\t') startPV = index;
+ index = startPV;
+ while(buf[index] && buf[index] != '\n') index++;
+ buf[index] = 0;
+ ParsePV(buf+startPV);
+ *start = startPV; *end = index-1;
+ return TRUE;
+}
+
+Boolean
LoadPV(int x, int y)
{ // called on right mouse click to load PV
int which = gameMode == TwoMachinesPlay && (WhiteOnMove(forwardMostMove) == (second.twoMachinesColor[0] == 'w'));
lastX = x; lastY = y;
ParsePV(lastPV[which]); // load the PV of the thinking engine in the boards array.
- currentMove = endPV;
- if(currentMove == forwardMostMove) ClearPremoveHighlights(); else
- SetPremoveHighlights(moveList[currentMove-1][0]-AAA, moveList[currentMove-1][1]-ONE,
- moveList[currentMove-1][2]-AAA, moveList[currentMove-1][3]-ONE);
- DrawPosition(TRUE, boards[currentMove]);
return TRUE;
}
InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo2), NULL, FALSE );\r
}\r
\r
+static int currentPV, highTextStart[2], highTextEnd[2];\r
+extern RECT boardRect;\r
+\r
+VOID\r
+GetMemoLine(HWND hDlg, int x, int y)\r
+{ // [HGM] pv: translate click to PV line, and load it for display\r
+ char buf[10000];\r
+ int index, start, end, memo;\r
+ POINT pt;\r
+\r
+ pt.x = x; pt.y = y;\r
+ memo = currentPV ? IDC_EngineMemo2 : IDC_EngineMemo1;\r
+ index = SendDlgItemMessage( hDlg, memo, EM_CHARFROMPOS, 0, (LPARAM) &pt );\r
+ GetDlgItemText(hDlg, memo, buf, sizeof(buf));\r
+ if(LoadMultiPV(x, y, buf, index, &start, &end)) {\r
+ SetCapture(hDlg);\r
+ SendMessage( outputField[currentPV][nMemo], EM_SETSEL, (WPARAM)start, (LPARAM)end );\r
+ highTextStart[currentPV] = start; highTextEnd[currentPV] = end;\r
+ SetFocus(outputField[currentPV][nMemo]);\r
+ }\r
+}\r
+\r
// front end. Actual printing of PV lines into the output field\r
void InsertIntoMemo( int which, char * text, int where )\r
{\r
SendMessage( outputField[which][nMemo], EM_SETSEL, where, where ); // [HGM] multivar: choose insertion point\r
\r
SendMessage( outputField[which][nMemo], EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) text );\r
+ if(where < highTextStart[which]) { // [HGM] multiPVdisplay: move highlighting\r
+ int len = strlen(text);\r
+ highTextStart[which] += len; highTextEnd[which] += len;\r
+ SendMessage( outputField[which][nMemo], EM_SETSEL, highTextStart[which], highTextEnd[which] );\r
+ }\r
}\r
\r
// front end. Associates an icon with an output field ("control" in Windows jargon).\r
\r
ResizeWindowControls( windowMode );\r
\r
+ SendDlgItemMessage( hDlg, IDC_EngineMemo1, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );\r
+ SendDlgItemMessage( hDlg, IDC_EngineMemo2, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );\r
+\r
/* Set font */\r
SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo1, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo2, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
\r
break;\r
\r
+ case WM_MOUSEMOVE:\r
+ MovePV(LOWORD(lParam) - boardRect.left, HIWORD(lParam) - boardRect.top, boardRect.bottom - boardRect.top);\r
+ break;\r
+\r
+ case WM_RBUTTONUP:\r
+ ReleaseCapture();\r
+ SendMessage( outputField[currentPV][nMemo], EM_SETSEL, 0, 0 );\r
+ highTextStart[currentPV] = highTextEnd[currentPV] = 0;\r
+ UnLoadPV();\r
+ break;\r
+\r
+ case WM_NOTIFY:\r
+ if( wParam == IDC_EngineMemo1 || wParam == IDC_EngineMemo2 ) {\r
+ MSGFILTER * lpMF = (MSGFILTER *) lParam;\r
+ if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL | MK_SHIFT)) == 0 ) {\r
+ currentPV = (wParam == IDC_EngineMemo2);\r
+ GetMemoLine(hDlg, LOWORD(lpMF->lParam), HIWORD(lpMF->lParam));\r
+ }\r
+ }\r
+ break;\r
+\r
case WM_GETMINMAXINFO:\r
{\r
MINMAXINFO * mmi = (MINMAXINFO *) lParam;\r