X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwengineoutput.c;h=b9d13f59a051c6d42497377d9fadce54eae6d0eb;hb=HEAD;hp=bb51525be768546576c01c4a871349dfdc1f36da;hpb=891e6ae6b61cb387401b79ad75ae5b2c1d58da5e;p=xboard.git diff --git a/winboard/wengineoutput.c b/winboard/wengineoutput.c index bb51525..b9d13f5 100644 --- a/winboard/wengineoutput.c +++ b/winboard/wengineoutput.c @@ -5,6 +5,9 @@ * * Copyright 2005 Alessandro Scotti * + * Enhancements Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, + * 2016 Free Software Foundation, Inc. + * * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -223,12 +226,40 @@ void ResizeWindowControls( int mode ) InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo2), NULL, FALSE ); } +static int currentPV; +int highTextStart[2], highTextEnd[2]; +extern RECT boardRect; + +VOID +GetMemoLine(HWND hDlg, int x, int y) +{ // [HGM] pv: translate click to PV line, and load it for display + char buf[10000]; + int index, start, end, memo; + POINT pt; + + pt.x = x; pt.y = y; + memo = currentPV ? IDC_EngineMemo2 : IDC_EngineMemo1; + index = SendDlgItemMessage( hDlg, memo, EM_CHARFROMPOS, 0, (LPARAM) &pt ); + GetDlgItemText(hDlg, memo, buf, sizeof(buf)); + if(LoadMultiPV(x, y, buf, index, &start, &end, currentPV)) { + SetCapture(hDlg); + SendMessage( outputField[currentPV][nMemo], EM_SETSEL, (WPARAM)start, (LPARAM)end ); + highTextStart[currentPV] = start; highTextEnd[currentPV] = end; + SetFocus(outputField[currentPV][nMemo]); + } +} + // front end. Actual printing of PV lines into the output field void InsertIntoMemo( int which, char * text, int where ) { SendMessage( outputField[which][nMemo], EM_SETSEL, where, where ); // [HGM] multivar: choose insertion point SendMessage( outputField[which][nMemo], EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) text ); + if(where < highTextStart[which]) { // [HGM] multiPVdisplay: move highlighting + int len = strlen(text); + highTextStart[which] += len; highTextEnd[which] += len; + SendMessage( outputField[which][nMemo], EM_SETSEL, highTextStart[which], highTextEnd[which] ); + } } // front end. Associates an icon with an output field ("control" in Windows jargon). @@ -247,6 +278,11 @@ void DoSetWindowText(int which, int field, char *s_label) SetWindowText( outputField[which][field], s_label ); } +void SetEngineOutputTitle(char *title) +{ + SetWindowText( engineOutputDialog, title ); +} + // This seems pure front end LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { @@ -257,10 +293,14 @@ LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARA if( engineOutputDialog == NULL ) { engineOutputDialog = hDlg; + Translate(hDlg, DLG_EngineOutput); RestoreWindowPlacement( hDlg, &wpEngineOutput ); /* Restore window placement */ ResizeWindowControls( windowMode ); + SendDlgItemMessage( hDlg, IDC_EngineMemo1, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS ); + SendDlgItemMessage( hDlg, IDC_EngineMemo2, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS ); + /* Set font */ SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo1, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 )); SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo2, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 )); @@ -287,6 +327,28 @@ LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARA break; + case WM_MOUSEMOVE: + MovePV(LOWORD(lParam) - boardRect.left, HIWORD(lParam) - boardRect.top, boardRect.bottom - boardRect.top); + break; + + case WM_RBUTTONUP: + ReleaseCapture(); + SendMessage( outputField[currentPV][nMemo], EM_SETSEL, 0, 0 ); + highTextStart[currentPV] = highTextEnd[currentPV] = 0; + UnLoadPV(); + break; + + case WM_NOTIFY: + if( wParam == IDC_EngineMemo1 || wParam == IDC_EngineMemo2 ) { + MSGFILTER * lpMF = (MSGFILTER *) lParam; + if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL)) == 0 ) { + shiftKey = (lpMF->wParam & MK_SHIFT) != 0; // [HGM] remember last shift status + currentPV = (wParam == IDC_EngineMemo2); + GetMemoLine(hDlg, LOWORD(lpMF->lParam), HIWORD(lpMF->lParam)); + } + } + break; + case WM_GETMINMAXINFO: { MINMAXINFO * mmi = (MINMAXINFO *) lParam;