X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xengineoutput.c;h=8ba8a7ecbfe8768b7e5ba36bcb9c9095c0d0223c;hb=8c94141e6c30dc94777dee5824cfbf027a18f940;hp=54c885935508482273c0e549c7e3a9ed3905ca37;hpb=044c57fe38b45daa427c1374c8765ecd55778832;p=xboard.git diff --git a/xengineoutput.c b/xengineoutput.c index 54c8859..8ba8a7e 100644 --- a/xengineoutput.c +++ b/xengineoutput.c @@ -132,7 +132,7 @@ Pixmap icons[8]; // [HGM] this front-end array translates back-end icon indicato Widget outputField[2][7]; // [HGM] front-end array to translate output field to window handle void EngineOutputPopDown(); -void engineOutputPopUp(char *title, char *text); +void engineOutputPopUp(); int EngineOutputIsUp(); static void SetEngineColorIcon( int which ); @@ -188,9 +188,9 @@ typedef struct { int an_move_count; } EngineOutputData; -static int VerifyDisplayMode(); +static void VerifyDisplayMode(); static void UpdateControls( EngineOutputData * ed ); -static SetEngineState( int which, int state, char * state_data ); +static void SetEngineState( int which, int state, char * state_data ); void ReadIcon(char *pixData[], int iconNr) { @@ -226,13 +226,13 @@ void DoSetWindowText(int which, int field, char *s_label) XtSetValues(outputField[which][field], &arg, 1); } -static void InsertIntoMemo( int which, char * text ) +static void InsertIntoMemo( int which, char * text, int where ) { Arg arg; XawTextBlock t; Widget edit; t.ptr = text; t.firstPos = 0; t.length = strlen(text); t.format = XawFmt8Bit; edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text"); - XawTextReplace(edit, 0, 0, &t); + XawTextReplace(edit, where, where, &t); // XtSetArg(arg, XtNstring, (XtArgVal) text); // XtSetValues(outputField[which][nMemo], &arg, 1); } @@ -349,13 +349,9 @@ void PositionControlSet(which, form, bw_width) XtSetArg(args[j], XtNright, XtChainRight); j++; XtSetArg(args[j], XtNresizable, True); j++; XtSetArg(args[j], XtNwidth, bw_width); j++; /*force wider than buttons*/ -#if 0 - XtSetArg(args[j], XtNscrollVertical, XawtextScrollWhenNeeded); j++; -#else /* !!Work around an apparent bug in XFree86 4.0.1 (X11R6.4.3) */ XtSetArg(args[j], XtNscrollVertical, XawtextScrollAlways); j++; XtSetArg(args[j], XtNscrollHorizontal, XawtextScrollWhenNeeded); j++; -#endif // XtSetArg(args[j], XtNautoFill, True); j++; // XtSetArg(args[j], XtNwrap, XawtextWrapWord); j++; outputField[which][nMemo] = edit = @@ -385,7 +381,11 @@ Widget EngineOutputCreate(name, text) j = 0; XtSetArg(args[j], XtNresizable, True); j++; shell = +#if TOPLEVEL + XtCreatePopupShell(name, topLevelShellWidgetClass, +#else XtCreatePopupShell(name, transientShellWidgetClass, +#endif shellWidget, args, j); layout = XtCreateManagedWidget(layoutName, formWidgetClass, shell, @@ -417,20 +417,8 @@ Widget EngineOutputCreate(name, text) Window junk; Dimension pw_height; Dimension ew_height; -#if 0 - j = 0; - XtSetArg(args[j], XtNheight, &ew_height); j++; - XtGetValues(edit, args, j); - - j = 0; - XtSetArg(args[j], XtNheight, &pw_height); j++; - XtGetValues(shell, args, j); - engineOutputH = pw_height + (lines - 1) * ew_height; - engineOutputW = bw_width - 16; -#else engineOutputH = bw_height/2; engineOutputW = bw_width-16; -#endif XSync(xDisplay, False); #ifdef NOTDEF @@ -499,12 +487,13 @@ void ResizeWindowControls(shell, mode) } } -void EngineOutputPopUp(title, text) - char *title, *text; +void +EngineOutputPopUp() { Arg args[16]; int j; Widget edit; + static char *title = _("Engine output"), *text = _("This feature is experimental"); if (engineOutputShell == NULL) { engineOutputShell = @@ -569,8 +558,11 @@ void EngineOutputPopDown() //------------------------ pure back-end routines ------------------------------- +#define MAX_VAR 400 +static int scores[MAX_VAR], textEnd[MAX_VAR], curDepth[2], nrVariations[2]; + // back end, due to front-end wrapper for SetWindowText, and new SetIcon arguments -static SetEngineState( int which, int state, char * state_data ) +static void SetEngineState( int which, int state, char * state_data ) { int x_which = 1 - which; @@ -756,7 +748,7 @@ static void SetDisplayMode( int mode ) } // pure back end -int VerifyDisplayMode() +void VerifyDisplayMode() { int mode; @@ -803,6 +795,38 @@ static void SetEngineColorIcon( int which ) #define MAX_NAME_LENGTH 32 +// [HGM] multivar: sort Thinking Output within one depth on score + +static int InsertionPoint( int len, EngineOutputData * ed ) +{ + int i, offs = 0, newScore = ed->score, n = ed->which; + + if(ed->nodes == 0 && ed->score == 0 && ed->time == 0) + newScore = 1e6; // info lines inserted on top + if(ed->depth != curDepth[n]) { // depth has changed + curDepth[n] = ed->depth; + nrVariations[n] = 0; // throw away everything we had + } + // loop through all lines. Note even / odd used for different panes + for(i=nrVariations[n]-2; i>=0; i-=2) { + // put new item behind those we haven't looked at + offs = textEnd[i+n]; + textEnd[i+n+2] = offs + len; + scores[i+n+2] = newScore; + if(newScore < scores[i+n]) break; + // if it had higher score as previous, move previous in stead + scores[i+n+2] = scores[i+n]; + textEnd[i+n+2] = textEnd[i+n] + len; + } + if(i<0) { + offs = 0; + textEnd[n] = offs + len; + scores[n] = newScore; + } + nrVariations[n] += 2; + return offs; +} + // pure back end, now SetWindowText is called via wrapper DoSetWindowText static void UpdateControls( EngineOutputData * ed ) { @@ -862,7 +886,8 @@ static void UpdateControls( EngineOutputData * ed ) strncpy( mov, ed->hint, sizeof(mov) ); mov[ sizeof(mov)-1 ] = '\0'; - sprintf( buf, "%d/%d: %s [%02d:%02d:%02d]", ed->an_move_index, ed->an_move_count, mov, time_mins / 60, time_mins % 60, time_secs % 60 ); + sprintf( buf, "[%d] %d/%d: %s [%02d:%02d:%02d]", ed->depth, ed->an_move_index, + ed->an_move_count, mov, time_mins / 60, time_mins % 60, time_secs % 60 ); } SetEngineState( ed->which, STATE_ANALYZING, buf ); @@ -930,7 +955,7 @@ static void UpdateControls( EngineOutputData * ed ) strcat( buf + buflen, "\n" ); /* Update memo */ - InsertIntoMemo( ed->which, buf ); + InsertIntoMemo( ed->which, buf, InsertionPoint(strlen(buf), ed) ); } /* Colors */ @@ -953,7 +978,7 @@ EngineOutputProc(w, event, prms, nprms) if (engineOutputDialogUp) { EngineOutputPopDown(); } else { - EngineOutputPopUp(_("engine output"),_("This feature is experimental")); + EngineOutputPopUp(); } // ToNrEvent(currentMove); } @@ -976,5 +1001,5 @@ void OutputKibitz(int window, char *text) DoSetWindowText(1, nLabel, gameMode == IcsPlayingBlack ? gameInfo.white : gameInfo.black); // opponent name SetIcon( 1, nColorIcon, gameMode == IcsPlayingBlack ? nColorWhite : nColorBlack); SetIcon( 1, nStateIcon, nClear); - InsertIntoMemo(window-1, text); + InsertIntoMemo(window-1, text, 0); }