From: H.G. Muller Date: Tue, 23 Mar 2010 22:22:46 +0000 (+0100) Subject: Display PV from Engine-Output window (XBoard) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=93f3da9125302932c4aaf6bb8a93a2fc5a3a96fa;p=xboard.git Display PV from Engine-Output window (XBoard) Translations are added to bind button 3 to the PV walk for the memo widgets, and the corresponding handlers are ported from wengineoutput.c. --- diff --git a/xboard.c b/xboard.c index add80c7..bc3a757 100644 --- a/xboard.c +++ b/xboard.c @@ -262,6 +262,10 @@ void AnimateUserMove P((Widget w, XEvent * event, String * params, Cardinal * nParams)); void HandlePV P((Widget w, XEvent * event, String * params, Cardinal * nParams)); +void SelectPV P((Widget w, XEvent * event, + String * params, Cardinal * nParams)); +void StopPV P((Widget w, XEvent * event, + String * params, Cardinal * nParams)); void WhiteClock P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void BlackClock P((Widget w, XEvent *event, @@ -850,7 +854,8 @@ XtActionsRec boardActions[] = { { "HandleUserMove", HandleUserMove }, { "AnimateUserMove", AnimateUserMove }, { "HandlePV", HandlePV }, - { "UnLoadPV", UnLoadPV }, + { "SelectPV", SelectPV }, + { "StopPV", StopPV }, { "FileNameAction", FileNameAction }, { "AskQuestionProc", AskQuestionProc }, { "AskQuestionReplyAction", AskQuestionReplyAction }, diff --git a/xengineoutput.c b/xengineoutput.c index de62d98..2d2a9a7 100644 --- a/xengineoutput.c +++ b/xengineoutput.c @@ -131,6 +131,7 @@ static int engineOutputDialogUp; /* Module variables */ int windowMode = 1; +static int currentPV, highTextStart[2], highTextEnd[2]; typedef struct { char * name; @@ -192,8 +193,11 @@ void InsertIntoMemo( int which, char * text, int where ) t.ptr = text; t.firstPos = 0; t.length = strlen(text); t.format = XawFmt8Bit; edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text"); XawTextReplace(edit, where, where, &t); -// XtSetArg(arg, XtNstring, (XtArgVal) text); -// XtSetValues(outputField[which][nMemo], &arg, 1); + if(where < highTextStart[which]) { // [HGM] multiPVdisplay: move highlighting + int len = strlen(text); + highTextStart[which] += len; highTextEnd[which] += len; + XawTextSetSelection( outputField[which][nMemo], highTextStart[which], highTextEnd[which] ); + } } void SetIcon( int which, int field, int nIcon ) @@ -227,7 +231,38 @@ Boolean SendPositionSelection(Widget w, Atom *selection, Atom *target, void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b); // from xoptions.c char memoTranslations[] = -":Ctrlc: CopyMemoProc() \n"; +":Ctrlc: CopyMemoProc() \n \ +: HandlePV() \n \ +: select-start() SelectPV() \n \ +: extend-end() StopPV() \n"; + +void +SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams) +{ // [HGM] pv: translate click to PV line, and load it for display + String val; + int start, end, memo, j; + XawTextPosition index, dummy; + int x, y; + Arg arg; + + x = event->xmotion.x; y = event->xmotion.y; + currentPV = (w == outputField[1][nMemo]); + XawTextGetSelectionPos(w, &index, &dummy); + XtSetArg(arg, XtNstring, &val); + XtGetValues(w, &arg, 1); + if(LoadMultiPV(x, y, val, index, &start, &end)) { + XawTextSetSelection( outputField[currentPV][nMemo], start, end ); + highTextStart[currentPV] = start; highTextEnd[currentPV] = end; + } +} + +void +StopPV (Widget w, XEvent * event, String * params, Cardinal * nParams) +{ // [HGM] pv: on right-button release, stop displaying PV + XawTextUnsetSelection( w ); + highTextStart[currentPV] = highTextEnd[currentPV] = 0; + UnLoadPV(); +} static void MemoCB(Widget w, XtPointer client_data, Atom *selection,