// [HGM] kibitz: write kibitz line; split window for it if necessary void OutputKibitz (int window, char *text) { static int currentLineEnd[2]; int where = 0; if(!EngineOutputIsUp()) return; if(!opponentKibitzes) { // on first kibitz of game, clear memos DoClearMemo(1); currentLineEnd[1] = 0; if(gameMode == IcsObserving) { DoClearMemo(0); currentLineEnd[0] = 0; } } opponentKibitzes = TRUE; // this causes split window DisplayMode in ICS modes. VerifyDisplayMode(); strncpy(text+strlen(text)-1, "\r\n",sizeof(text+strlen(text)-1)); // to not lose line breaks on copying if(gameMode == IcsObserving) { DoSetWindowText(0, nLabel, gameInfo.white); SetIcon( 0, nColorIcon, nColorWhite); SetIcon( 0, nStateIcon, nClear); } DoSetWindowText(1, nLabel, gameMode == IcsPlayingBlack ? gameInfo.white : gameInfo.black); // opponent name SetIcon( 1, nColorIcon, gameMode == IcsPlayingBlack ? nColorWhite : nColorBlack); SetIcon( 1, nStateIcon, nClear); if(strstr(text, "\\ ") == text) where = currentLineEnd[window-1]; // continuation line //if(appData.debugMode) fprintf(debugFP, "insert '%s' at %d (end = %d,%d)\n", text, where, currentLineEnd[0], currentLineEnd[1]); InsertIntoMemo(window-1, text, where); // [HGM] multivar: always at top currentLineEnd[window-1] = where + strlen(text); }
void EngineOutputPopDown () { Arg args[16]; int j; if (!engineOutputDialogUp) return; DoClearMemo(1); j = 0; XtSetArg(args[j], XtNx, &engineOutputX); j++; XtSetArg(args[j], XtNy, &engineOutputY); j++; XtSetArg(args[j], XtNwidth, &engineOutputW); j++; XtSetArg(args[j], XtNheight, &engineOutputH); j++; XtGetValues(engineOutputShell, args, j); wpEngineOutput.x = engineOutputX - 4; wpEngineOutput.y = engineOutputY - 23; wpEngineOutput.width = engineOutputW; wpEngineOutput.height = engineOutputH; XtPopdown(engineOutputShell); XSync(xDisplay, False); j=0; XtSetArg(args[j], XtNleftBitmap, None); j++; XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Engine Output"), args, j); engineOutputDialogUp = False; ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output }
// back end, now the front-end wrapper ClearMemo is used, and ed no longer contains handles. void SetProgramStats (FrontEndProgramStats * stats) // now directly called by back-end { EngineOutputData ed; int clearMemo = FALSE; int which, depth, multi; ChessMove moveType; int ff, ft, rf, rt; char pc; if( stats == 0 ) { SetEngineState( 0, STATE_IDLE, "" ); SetEngineState( 1, STATE_IDLE, "" ); return; } if(gameMode == IcsObserving && !appData.icsEngineAnalyze) return; // [HGM] kibitz: shut up engine if we are observing an ICS game which = stats->which; depth = stats->depth; if( which < 0 || which > 1 || depth < 0 || stats->time < 0 || stats->pv == 0 ) { return; } if( !EngineOutputDialogExists() ) { return; } VerifyDisplayMode(); ed.which = which; ed.depth = depth; ed.nodes = stats->nodes; ed.score = stats->score; ed.time = stats->time; ed.pv = stats->pv; ed.hint = stats->hint; ed.an_move_index = stats->an_move_index; ed.an_move_count = stats->an_move_count; /* Get target control. [HGM] this is moved to front end, which get them from a table */ if( which == 0 ) { ed.name = first.tidy; } else { ed.name = second.tidy; } if( ed.pv != 0 && ed.pv[0] == ' ' ) { if( strncmp( ed.pv, " no PV", 6 ) == 0 ) { /* Hack on hack! :-O */ ed.pv = ""; } } /* Clear memo if needed */ if( lastDepth[which] > depth || (lastDepth[which] == depth && depth <= 1 && ed.pv[0]) ) { // no reason to clear if we won't add line clearMemo = TRUE; } if( lastForwardMostMove[which] != forwardMostMove ) { clearMemo = TRUE; } if( clearMemo ) { DoClearMemo(which); nrVariations[which] = 0; header[which][0] = NULLCHAR; if(gameMode == AnalyzeMode) { ChessProgramState *cps = (which ? &second : &first); if((multi = MultiPV(cps)) >= 0) { snprintf(header[which], MSG_SIZ, "\t%s viewpoint\t\tfewer / Multi-PV setting = %d / more\n", appData.whitePOV || appData.scoreWhite ? "white" : "mover", cps->option[multi].value); } if(!which) snprintf(header[which]+strlen(header[which]), MSG_SIZ-strlen(header[which]), "%s", exclusionHeader); InsertIntoMemo( which, header[which], 0); } else if(appData.ponderNextMove && lastLine[which][0]) { InsertIntoMemo( which, lastLine[which], 0 ); InsertIntoMemo( which, "\n", 0 ); } } if(ed.pv && ed.pv[0] && ParseOneMove(ed.pv, currentMove, &moveType, &ff, &rf, &ft, &rt, &pc)) ed.moveKey = (ff<<24 | rf << 16 | ft << 8 | rt) ^ pc*87161; else ed.moveKey = ed.nodes; // kludge to get unique key unlikely to match any move /* Update */ lastDepth[which] = depth == 1 && ed.nodes == 0 ? 0 : depth; // [HGM] info-line kudge lastForwardMostMove[which] = forwardMostMove; UpdateControls( &ed ); }