From: Arun Persaud Date: Wed, 14 Oct 2009 04:17:33 +0000 (-0700) Subject: Merge branch 'master' into gtk X-Git-Tag: gtk-20091122~15 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=31fcc3f34eacc04811cbfc3165a5e839aa81f015;hp=fc82040aea466a4b122305b8c74d8122f4ba035a;p=xboard.git Merge branch 'master' into gtk Conflicts: backend.c xboard.c --- diff --git a/backend.c b/backend.c index dc61e33..1074107 100644 --- a/backend.c +++ b/backend.c @@ -77,6 +77,7 @@ #if STDC_HEADERS # include # include +# include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include @@ -147,6 +148,7 @@ void read_from_player P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); void read_from_ics P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); +void ics_printf P((char *format, ...)); void SendToICS P((char *s)); void SendToICSDelayed P((char *s, long msdelay)); void SendMoveToICS P((ChessMove moveType, int fromX, int fromY, @@ -229,6 +231,7 @@ char *GetInfoFromComment( int, char * ); // [HGM] PV time: returns stripped comm void InitEngineUCI( const char * iniDir, ChessProgramState * cps ); // [HGM] moved here from winboard.c char *ProbeBook P((int moveNr, char *book)); // [HGM] book: returns a book move char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book +void ics_update_width P((int new_width)); extern char installDir[MSG_SIZ]; extern int tinyLayout, smallLayout; @@ -1418,6 +1421,19 @@ KeepAlive() if(appData.keepAlive) ScheduleDelayedEvent(KeepAlive, appData.keepAlive*60*1000); } +/* added routine for printf style output to ics */ +void ics_printf(char *format, ...) +{ + char buffer[MSG_SIZ]; + va_list args; + + va_start(args, format); + vsnprintf(buffer, sizeof(buffer), format, args); + buffer[sizeof(buffer)-1] = '\0'; + SendToICS(buffer); + va_end(args); +} + void SendToICS(s) char *s; @@ -1536,6 +1552,10 @@ StringToVariant(e) while( *e++ != '_'); } + if(StrCaseStr(e, "misc/")) { // [HGM] on FICS, misc/shogi is not shogi + v = VariantNormal; + found = TRUE; + } else for (i=0; i gameInfo.holdingsWidth) { - for(i=0; i=BOARD_LEFT; j--) - board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = - board[i][j]; - for(i=0; i gameInfo.holdingsWidth) { + for(i=0; i=BOARD_LEFT; j--) + board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = + board[i][j]; + for(i=0; i= 5 && buf[buf_len-5]=='\n' && buf[buf_len-4]=='\\' && + if(!appData.noJoin && buf_len >= 5 && buf[buf_len-5]=='\n' && buf[buf_len-4]=='\\' && buf[buf_len-3]==' ' && buf[buf_len-2]==' ' && buf[buf_len-1]==' ') { buf_len -= 5; // [HGM] ICS: join continuation line of Lasker 2.2.3 server with previous if(buf_len == 0 || buf[buf_len-1] != ' ') @@ -2201,7 +2224,8 @@ read_from_ics(isr, closure, data, count, error) sprintf(str, "/set-quietly interface %s\n/set-quietly style 12\n", programVersion); - + if (!appData.noJoin) + strcat(str, "/set-quietly wrap 0\n"); } else if (ics_type == ICS_CHESSNET) { sprintf(str, "/style 12\n"); } else { @@ -2211,9 +2235,12 @@ read_from_ics(isr, closure, data, count, error) #ifdef WIN32 strcat(str, "$iset nohighlight 1\n"); #endif + if (!appData.noJoin) + strcat(str, "$iset nowrap 1\n"); strcat(str, "$iset lock 1\n$style 12\n"); } SendToICS(str); + NotifyFrontendLogin(); intfSet = TRUE; } @@ -3929,6 +3956,12 @@ AnalysisPeriodicEvent(force) programStats.ok_to_send = 0; } +void ics_update_width(new_width) + int new_width; +{ + ics_printf("set width %d\n", new_width); +} + void SendMoveToProgram(moveNum, cps) int moveNum; @@ -9649,7 +9682,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, numtext); + fprintf(f, "%s", numtext); linelen += numlen; /* Get move */ @@ -9667,7 +9700,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, move_buffer); + fprintf(f, "%s", move_buffer); linelen += movelen; /* [AS] Add PV info if present */ @@ -9711,7 +9744,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, move_buffer); + fprintf(f, "%s", move_buffer); linelen += movelen; } @@ -10374,8 +10407,7 @@ AnalyzeModeEvent() first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp(_("Analysis"), - _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); + EngineOutputPopUp(); } if (!appData.icsEngineAnalyze) gameMode = AnalyzeMode; pausing = FALSE; @@ -10401,8 +10433,7 @@ AnalyzeFileEvent() first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp(_("Analysis"), - _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); + EngineOutputPopUp(); } gameMode = AnalyzeFile; pausing = FALSE; @@ -10900,7 +10931,7 @@ ExitAnalyzeMode() SendToProgram("exit\n", &first); first.analyzing = FALSE; } - AnalysisPopDown(); + EngineOutputPopDown(); thinkOutput[0] = NULLCHAR; } @@ -12744,12 +12775,10 @@ void DisplayAnalysisText(text) char *text; { - char buf[MSG_SIZ]; - - if (gameMode == AnalyzeMode || gameMode == AnalyzeFile - || appData.icsEngineAnalyze) { - sprintf(buf, "Analysis (%s)", first.tidy); - AnalysisPopUp(buf, text); + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile + || appData.icsEngineAnalyze) + { + EngineOutputPopUp(); } } @@ -13552,6 +13581,14 @@ PositionToFEN(move, overrideCastling) } else { *p++ = '-'; } + } else if(move == backwardMostMove) { + // [HGM] perhaps we should always do it like this, and forget the above? + if(epStatus[move] >= 0) { + *p++ = epStatus[move] + AAA; + *p++ = whiteToPlay ? '6'+BOARD_HEIGHT-8 : '3'; + } else { + *p++ = '-'; + } } else { *p++ = '-'; } diff --git a/backend.h b/backend.h index 4cc8646..7b6c08e 100644 --- a/backend.h +++ b/backend.h @@ -258,7 +258,7 @@ char * GameListLineFull P(( int, GameInfo *)); extern char* StripHighlight P((char *)); /* returns static data */ extern char* StripHighlightAndTitle P((char *)); /* returns static data */ - +extern void ics_update_width P((int new_width)); typedef enum { CheckBox, ComboBox, TextBox, Button, Spin, ResetButton, SaveButton, FileName, PathName, Slider, Message } Control; diff --git a/backendz.h b/backendz.h index eb8df7d..51d4780 100644 --- a/backendz.h +++ b/backendz.h @@ -64,6 +64,7 @@ extern ProcRef firstProgramPR; extern int startedFromSetupPosition; extern int firstMove; extern GameInfo gameInfo; +extern void ics_printf P((char *format, ...)); extern void SendToICS P((char *s)); extern int looking_at P((char *, int *, char *)); extern void SendToProgram P((char *message, ChessProgramState *cps)); diff --git a/callback.c b/callback.c index 14cfcc1..9abeca0 100644 --- a/callback.c +++ b/callback.c @@ -491,7 +491,7 @@ ResetProc (object, user_data) gpointer user_data; { ResetGameEvent(); - AnalysisPopDown(); + EngineOutputPopDown(); } void WhiteClockProc(object, user_data) diff --git a/common.h b/common.h index 83c6837..9ab3048 100644 --- a/common.h +++ b/common.h @@ -602,6 +602,7 @@ typedef struct { char *fenOverride2; Boolean keepAlive; /* [HGM] alive */ Boolean forceIllegal;/*[HGM] illegal */ + Boolean noJoin; /* [HGM] join */ } AppData, *AppDataPtr; /* [AS] PGN tags (for showing in the game list) */ diff --git a/frontend.h b/frontend.h index 314176b..29425f1 100644 --- a/frontend.h +++ b/frontend.h @@ -85,6 +85,7 @@ void AskQuestion P((String title, String question, String replyPrefix, void DisplayIcsInteractionTitle P((String title)); void DrawPosition P((int fullRedraw, Board board)); void ResetFrontEnd P((void)); +void NotifyFrontendLogin P((void)); void CommentPopUp P((String title, String comment)); void CommentPopDown P((void)); void EditCommentPopUp P((int index, String title, String text)); @@ -159,8 +160,6 @@ void TagsPopDown P((void)); void ICSInitScript P((void)); void StartAnalysisClock P((void)); -void AnalysisPopUp P((char *title, char *label)); -void AnalysisPopDown P((void)); void SetHighlights P((int fromX, int fromY, int toX, int toY)); void ClearHighlights P((void)); diff --git a/pixmaps/asdd72.xpm b/pixmaps/asdd72.xpm index 313020b..65f0a0a 100644 --- a/pixmaps/asdd72.xpm +++ b/pixmaps/asdd72.xpm @@ -1,9 +1,10 @@ /* XPM */ static char *asdd72[] = { /* columns rows colors chars-per-pixel */ -"72 72 2 1", +"72 72 3 1", " c black s dark_piece", ". c green s dark_square", +"X c white s light_piece", /* pixels */ "........................................................................", "........................................................................", @@ -18,51 +19,51 @@ static char *asdd72[] = { "........ ........................ .........", "........ ...................... .........", "........ .................... .........", -"........ . .................. .........", -"........ .. ................ . .........", -"........ .. .............. .. .........", -"........ .. ............ .. .........", -"........ .. .......... .. .........", -"........ .. ........ .. .........", -"........ .. ...... .. .........", -"........ .. .... .. .........", -"......... .. .. .. .........", -".......... .. .. ..........", -"........... .. .. .. ...........", -"............ .. .. .. ............", -"............. .. .. .. .............", -".............. .. .. .. ..............", -"............... .. .. ...............", -"................ .. .. ................", -"................. .. .. .................", -".................. .. .. ..................", -"................... .. .. ...................", -".................... .. .. ....................", -"..................... .. .. .....................", -"...................... .. ......................", -"....................... .. .......................", -"...................... .. ......................", -"........ .......... .. .. .......... ........", -"....... ........ .. .. ........ .......", -"...... ...... .. .. ...... ......", -"..... .... .. .. .... .....", -".... .. .. .. .. ....", -".... .. .. .. .. ....", -".... .. .. .. .. ....", -".... .. . .. .. .. ....", -"..... .. .. .. .. .. .....", -"...... .. . .. . .. ......", -"....... .. . .. .......", -"........ .. .. ........", -"......... .. .. .. .........", -"............ .. .... .. ............", -"............. .. ...... .. .............", -"............ . .. ........ .. . ............", -"........... . .. .......... .. . ...........", -".......... . ................ . ..........", -"......... . .............. . .........", -"........ . ............ . ........", -"....... . .......... . .......", +"........ X .................. .........", +"........ XX ................ X .........", +"........ XX .............. XX .........", +"........ XX ............ XX .........", +"........ XX .......... XX .........", +"........ XX ........ XX .........", +"........ XX ...... XX .........", +"........ XX .... XX .........", +"......... XX .. XX .........", +".......... XX XX ..........", +"........... XX XX XX ...........", +"............ XX XX XX ............", +"............. XX XX XX .............", +".............. XX XX XX ..............", +"............... XX XX ...............", +"................ XX XX ................", +"................. XX XX .................", +".................. XX XX ..................", +"................... XX XX ...................", +".................... XX XX ....................", +"..................... XX XX .....................", +"...................... XX ......................", +"....................... XX .......................", +"...................... XX ......................", +"........ .......... XX XX .......... ........", +"....... ........ XX XX ........ .......", +"...... ...... XX XX ...... ......", +"..... .... XX XX .... .....", +".... .. XX XX .. ....", +".... XX XX XX XX ....", +".... XX XX XX XX ....", +".... XX X XX XX XX ....", +"..... XX XX XX XX XX .....", +"...... XX X XX X XX ......", +"....... XX X XX .......", +"........ XX XX ........", +"......... XX .. XX .........", +"............ XX .... XX ............", +"............. XX ...... XX .............", +"............ X XX ........ XX X ............", +"........... X XX .......... XX X ...........", +".......... X XX............XX X ..........", +"......... X .............. X .........", +"........ X ............ X ........", +"....... X .......... X .......", "...... . ........ . ......", "..... .. ...... .. .....", ".... .... .... .... ....", diff --git a/pixmaps/asdl72.xpm b/pixmaps/asdl72.xpm index 7f987f2..6dcd22e 100644 --- a/pixmaps/asdl72.xpm +++ b/pixmaps/asdl72.xpm @@ -1,9 +1,10 @@ /* XPM */ static char *asdl72[] = { /* columns rows colors chars-per-pixel */ -"72 72 2 1", +"72 72 3 1", " c black s dark_piece", ". c gray s light_square", +"X c white s light_piece", /* pixels */ "........................................................................", "........................................................................", @@ -18,51 +19,51 @@ static char *asdl72[] = { "........ ........................ .........", "........ ...................... .........", "........ .................... .........", -"........ . .................. .........", -"........ .. ................ . .........", -"........ .. .............. .. .........", -"........ .. ............ .. .........", -"........ .. .......... .. .........", -"........ .. ........ .. .........", -"........ .. ...... .. .........", -"........ .. .... .. .........", -"......... .. .. .. .........", -".......... .. .. ..........", -"........... .. .. .. ...........", -"............ .. .. .. ............", -"............. .. .. .. .............", -".............. .. .. .. ..............", -"............... .. .. ...............", -"................ .. .. ................", -"................. .. .. .................", -".................. .. .. ..................", -"................... .. .. ...................", -".................... .. .. ....................", -"..................... .. .. .....................", -"...................... .. ......................", -"....................... .. .......................", -"...................... .. ......................", -"........ .......... .. .. .......... ........", -"....... ........ .. .. ........ .......", -"...... ...... .. .. ...... ......", -"..... .... .. .. .... .....", -".... .. .. .. .. ....", -".... .. .. .. .. ....", -".... .. .. .. .. ....", -".... .. . .. .. .. ....", -"..... .. .. .. .. .. .....", -"...... .. . .. . .. ......", -"....... .. . .. .......", -"........ .. .. ........", -"......... .. .. .. .........", -"............ .. .... .. ............", -"............. .. ...... .. .............", -"............ . .. ........ .. . ............", -"........... . .. .......... .. . ...........", -".......... . ................ . ..........", -"......... . .............. . .........", -"........ . ............ . ........", -"....... . .......... . .......", +"........ X .................. .........", +"........ XX ................ X .........", +"........ XX .............. XX .........", +"........ XX ............ XX .........", +"........ XX .......... XX .........", +"........ XX ........ XX .........", +"........ XX ...... XX .........", +"........ XX .... XX .........", +"......... XX .. XX .........", +".......... XX XX ..........", +"........... XX XX XX ...........", +"............ XX XX XX ............", +"............. XX XX XX .............", +".............. XX XX XX ..............", +"............... XX XX ...............", +"................ XX XX ................", +"................. XX XX .................", +".................. XX XX ..................", +"................... XX XX ...................", +".................... XX XX ....................", +"..................... XX XX .....................", +"...................... XX ......................", +"....................... XX .......................", +"...................... XX ......................", +"........ .......... XX XX .......... ........", +"....... ........ XX XX ........ .......", +"...... ...... XX XX ...... ......", +"..... .... XX XX .... .....", +".... .. XX XX .. ....", +".... XX XX XX XX ....", +".... XX XX XX XX ....", +".... XX X XX XX XX ....", +"..... XX XX XX XX XX .....", +"...... XX X XX X XX ......", +"....... XX X XX .......", +"........ XX XX ........", +"......... XX .. XX .........", +"............ XX .... XX ............", +"............. XX ...... XX .............", +"............ X XX ........ XX X ............", +"........... X XX .......... XX X ...........", +".......... X XX............XX X ..........", +"......... X .............. X .........", +"........ X ............ X ........", +"....... X .......... X .......", "...... . ........ . ......", "..... .. ...... .. .....", ".... .... .... .... ....", diff --git a/pixmaps/convert.c b/pixmaps/convert.c index dcdcd47..3118808 100644 --- a/pixmaps/convert.c +++ b/pixmaps/convert.c @@ -54,6 +54,19 @@ void Paint(char dest[130][130], char src[130][130], int size, char c) for(i=0; i 0) FloodFill(a, size, x-1, y); + if(y > 0) FloodFill(a, size, x, y-1); + if(x < size-1) FloodFill(a, size, x+1, y); + if(y < size-1) FloodFill(a, size, x, y+1); + } + +} + void Save(FILE *f, char *name, char data[130][130], int size, char *col, int depth) { // write out data in source format for d x d pixmap with specified square color int i, j; @@ -79,9 +92,11 @@ char data[130][130], oData[130][130], sData[130][130], wData[130][130]; main(int argc, char **argv) { - int i, j, k, d, cnt, p, s, t; char c, h, w, *name, buf[80]; + int i, j, k, d, cnt, p, s, t; char c, h, w, *name, buf[80], transparent; FILE *f; + transparent = argc > 1 && !strcmp(argv[1], "-t"); + for(s=0; s<18; s++) for(p=0; pieceList[p] != NULL; p++) { // Load the 3 kinds of Windows monochrome bitmaps (outline, solid, white fill) @@ -107,19 +122,26 @@ main(int argc, char **argv) printf("%s loaded\n", buf); // construct pixmaps as character arrays d = sizeList[s]; - for(i=0; ilf); + hold_font = SelectObject(hdc, hfont); + GetTextMetrics(hdc, &tm); + SelectObject(hdc, hold_font); + DeleteObject(hfont); + ReleaseDC(hText, hdc); + + // get the rectangle + SendMessage(hText, EM_GETRECT, 0, (LPARAM)&rc); + + // update the width + new_width = (rc.right-rc.left) / tm.tmAveCharWidth; + old_width = GetWindowLong(hText, GWL_USERDATA); + if (new_width != old_width) + { + ics_update_width(new_width); + SetWindowLong(hText, GWL_USERDATA, new_width); + } +} + VOID ChangedConsoleFont() { @@ -5495,6 +5526,7 @@ ChangedConsoleFont() paraf.dxOffset = WRAP_INDENT; SendMessage(hText, EM_SETPARAFORMAT, 0, (LPARAM) ¶f); SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); + UpdateICSWidth(hText); } /*---------------------------------------------------------------------------*\ @@ -5599,14 +5631,14 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch (wmId) { case IDM_NewGame: ResetGameEvent(); - AnalysisPopDown(); + EngineOutputPopDown(); SAY("new game enter a move to play against the computer with white"); break; case IDM_NewGameFRC: if( NewGameFRC() == 0 ) { ResetGameEvent(); - AnalysisPopDown(); + EngineOutputPopDown(); } break; @@ -8099,12 +8131,15 @@ LRESULT CALLBACK ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static SnapData sd; - static HWND hText, hInput /*, hFocus*/; -// InputSource *is = consoleInputSource; + HWND hText, hInput; RECT rect; static int sizeX, sizeY; int newSizeX, newSizeY; MINMAXINFO *mmi; + WORD wMask; + + hText = GetDlgItem(hDlg, OPT_ConsoleText); + hInput = GetDlgItem(hDlg, OPT_ConsoleInput); switch (message) { case WM_NOTIFY: @@ -8113,21 +8148,18 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ENLINK *pLink = (ENLINK*)lParam; if (pLink->msg == WM_LBUTTONUP) { - TEXTRANGE tr; - - tr.chrg = pLink->chrg; - tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); - hText = GetDlgItem(hDlg, OPT_ConsoleText); - SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); - free(tr.lpstrText); + TEXTRANGE tr; + + tr.chrg = pLink->chrg; + tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); + SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); + free(tr.lpstrText); } } break; case WM_INITDIALOG: /* message: initialize dialog box */ hwndConsole = hDlg; - hText = GetDlgItem(hDlg, OPT_ConsoleText); - hInput = GetDlgItem(hDlg, OPT_ConsoleInput); SetFocus(hInput); consoleTextWindowProc = (WNDPROC) SetWindowLong(hText, GWL_WNDPROC, (LONG) ConsoleTextSubclass); @@ -8175,6 +8207,12 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetWindowPlacement(hDlg, &wp); } + // Allow hText to highlight URLs and send notifications on them + wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); + SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); + SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); + SetWindowLong(hText, GWL_USERDATA, 79); // initialize the text window's width + return FALSE; case WM_SETFOCUS: @@ -8234,6 +8272,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return OnMoving( &sd, hDlg, wParam, lParam ); case WM_EXITSIZEMOVE: + UpdateICSWidth(hText); return OnExitSizeMove( &sd, hDlg, wParam, lParam ); } @@ -8244,18 +8283,10 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) VOID ConsoleCreate() { - HWND hCons, hText; - WORD wMask; + HWND hCons; if (hwndConsole) return; hCons = CreateDialog(hInst, szConsoleName, 0, NULL); SendMessage(hCons, WM_INITDIALOG, 0, 0); - - - // make the text item in the console do URL links - hText = GetDlgItem(hCons, OPT_ConsoleText); - wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); - SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); - SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); } @@ -8711,6 +8742,7 @@ Enables gnuEnables[] = { { IDM_StopExamining, MF_BYCOMMAND|MF_GRAYED }, { IDM_StopObserving, MF_BYCOMMAND|MF_GRAYED }, { IDM_Revert, MF_BYCOMMAND|MF_GRAYED }, + { IDM_NewChat, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -8720,6 +8752,7 @@ Enables icsEnables[] = { { IDM_MachineWhite, MF_BYCOMMAND|MF_GRAYED }, { IDM_MachineBlack, MF_BYCOMMAND|MF_GRAYED }, { IDM_TwoMachines, MF_BYCOMMAND|MF_GRAYED }, + { IDM_MachineBoth, MF_BYCOMMAND|MF_GRAYED }, { IDM_AnalysisMode, MF_BYCOMMAND|MF_ENABLED }, { IDM_AnalyzeFile, MF_BYCOMMAND|MF_GRAYED }, { IDM_TimeControl, MF_BYCOMMAND|MF_GRAYED }, @@ -8727,6 +8760,8 @@ Enables icsEnables[] = { { IDM_Hint, MF_BYCOMMAND|MF_GRAYED }, { IDM_Book, MF_BYCOMMAND|MF_GRAYED }, { IDM_IcsOptions, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Engine1Options, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Engine2Options, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -8735,6 +8770,7 @@ Enables zippyEnables[] = { { IDM_MoveNow, MF_BYCOMMAND|MF_ENABLED }, { IDM_Hint, MF_BYCOMMAND|MF_ENABLED }, { IDM_Book, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Engine1Options, MF_BYCOMMAND|MF_ENABLED }, { -1, -1 } }; #endif @@ -8755,6 +8791,10 @@ Enables ncpEnables[] = { { IDM_TimeControl, MF_BYCOMMAND|MF_GRAYED }, { IDM_Hint, MF_BYCOMMAND|MF_GRAYED }, { IDM_Book, MF_BYCOMMAND|MF_GRAYED }, + { IDM_MachineBoth, MF_BYCOMMAND|MF_GRAYED }, + { IDM_NewChat, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Engine1Options, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Engine2Options, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -9512,6 +9552,11 @@ DrawPosition(int fullRedraw, Board board) HDCDrawPosition(NULL, (BOOLEAN) fullRedraw, board); } +void NotifyFrontendLogin() +{ + if (hwndConsole) + UpdateICSWidth(GetDlgItem(hwndConsole, OPT_ConsoleText)); +} VOID ResetFrontEnd() @@ -10654,51 +10699,6 @@ AnalysisDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } VOID -AnalysisPopUp(char* title, char* str) -{ - FARPROC lpProc; - char *p, *q; - - /* [AS] */ - EngineOutputPopUp(); - return; - - if (str == NULL) str = ""; - p = (char *) malloc(2 * strlen(str) + 2); - q = p; - while (*str) { - if (*str == '\n') *q++ = '\r'; - *q++ = *str++; - } - *q = NULLCHAR; - if (analysisText != NULL) free(analysisText); - analysisText = p; - - if (analysisDialog) { - SetWindowText(analysisDialog, title); - SetDlgItemText(analysisDialog, OPT_AnalysisText, analysisText); - ShowWindow(analysisDialog, SW_SHOW); - } else { - analysisTitle = title; - lpProc = MakeProcInstance((FARPROC)AnalysisDialog, hInst); - CreateDialog(hInst, MAKEINTRESOURCE(DLG_Analysis), - hwndMain, (DLGPROC)lpProc); - FreeProcInstance(lpProc); - } - analysisDialogUp = TRUE; -} - -VOID -AnalysisPopDown() -{ - if (analysisDialog) { - ShowWindow(analysisDialog, SW_HIDE); - } - analysisDialogUp = FALSE; -} - - -VOID SetHighlights(int fromX, int fromY, int toX, int toY) { highlightInfo.sq[0].x = fromX; diff --git a/winboard/wsettings.c b/winboard/wsettings.c index 2992165..fc0dc12 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -9,9 +9,9 @@ * that generates the actual dialog box from it. */ -//#include "config.h" #include "config.h" +#include #include #include #include "common.h" diff --git a/xboard.c b/xboard.c index a99967d..03261ad 100644 --- a/xboard.c +++ b/xboard.c @@ -245,6 +245,7 @@ typedef struct { int main P((int argc, char **argv)); RETSIGTYPE CmailSigHandler P((int sig)); RETSIGTYPE IntSigHandler P((int sig)); +RETSIGTYPE TermSizeSigHandler P((int sig)); void CreateGCs P((void)); void CreateXIMPieces P((void)); void CreateXPMPieces P((void)); @@ -380,7 +381,8 @@ void TimeControlPopDown P(()); void NewVariantPopDown P(()); void SettingsPopDown P(()); void SetMenuEnables P((Enables *enab)); - +void update_ics_width P(()); +int get_term_width P(()); /* * XBoard depends on Xt R4 or higher */ @@ -1404,6 +1406,9 @@ XtResource clientResources[] = { { "forceIllegalMoves", "forceIllegalMoves", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, forceIllegal), XtRImmediate, (XtPointer) False}, + { "keepLineBreaksICS", "keepLineBreaksICS", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, noJoin), + XtRImmediate, (XtPointer) True}, }; XrmOptionDescRec shellOptions[] = { @@ -1773,6 +1778,7 @@ XrmOptionDescRec shellOptions[] = { { "-secondNeedsNoncompliantFEN", "secondNeedsNoncompliantFEN", XrmoptionSepArg, NULL }, { "-keepAlive", "keepAlive", XrmoptionSepArg, NULL }, { "-forceIllegalMoves", "forceIllegalMoves", XrmoptionNoArg, "True" }, + { "-keepLineBreaksICS", "keepLineBreaksICS", XrmoptionSepArg, NULL }, }; @@ -1877,7 +1883,7 @@ XtActionsRec boardActions[] = { { "TagsPopDown", (XtActionProc) TagsPopDown }, { "ErrorPopDown", (XtActionProc) ErrorPopDown }, { "ICSInputBoxPopDown", (XtActionProc) ICSInputBoxPopDown }, - { "AnalysisPopDown", (XtActionProc) AnalysisPopDown }, + { "EngineOutputPopDown", (XtActionProc) EngineOutputPopDown }, { "FileNamePopDown", (XtActionProc) FileNamePopDown }, { "AskQuestionPopDown", (XtActionProc) AskQuestionPopDown }, { "GameListPopDown", (XtActionProc) GameListPopDown }, @@ -2725,6 +2731,11 @@ ShutDownFrontEnd() unlink(gamePasteFilename); } +RETSIGTYPE TermSizeSigHandler(int sig) +{ + update_ics_width(); +} + RETSIGTYPE IntSigHandler(sig) int sig; @@ -4614,37 +4625,6 @@ void CommentPopUp(title, text) commentUp = True; } -void AnalysisPopUp(title, text) - char *title, *text; -{ - Arg args[16]; - int j; - Widget edit; - - if (analysisShell == NULL) { - analysisShell = MiscCreate(title, text, False, NULL, 4); - XtRealizeWidget(analysisShell); - CatchDeleteWindow(analysisShell, "AnalysisPopDown"); - - } else { - edit = XtNameToWidget(analysisShell, "*form.text"); - j = 0; - XtSetArg(args[j], XtNstring, text); j++; - XtSetValues(edit, args, j); - j = 0; - XtSetArg(args[j], XtNiconName, (XtArgVal) title); j++; - XtSetArg(args[j], XtNtitle, (XtArgVal) title); j++; - XtSetValues(analysisShell, args, j); - } - - if (!analysisUp) { - XtPopup(analysisShell, XtGrabNone); - } - XSync(xDisplay, False); - - analysisUp = True; -} - void CommentCallback(w, client_data, call_data) Widget w; XtPointer client_data, call_data; @@ -4683,16 +4663,6 @@ void CommentPopDown() commentUp = False; } -void AnalysisPopDown() -{ - if (!analysisUp) return; - XtPopdown(analysisShell); - XSync(xDisplay, False); - analysisUp = False; - if (appData.icsEngineAnalyze) ExitAnalyzeMode(); /* [DM] icsEngineAnalyze */ -} - - void FileNamePopUp(label, def, proc, openMode) char *label; char *def; @@ -6704,6 +6674,10 @@ int StartChildProcess(cmdLine, dir, pr) SetUpChildIO(to_prog, from_prog); + #ifdef SIGWINCH + signal(SIGWINCH, TermSizeSigHandler); + #endif + if ((pid = fork()) == 0) { /* Child process */ // [HGM] PSWBTM: made order resistant against case where fd of created pipe was 0 or 1 @@ -7841,3 +7815,38 @@ SetProgramStats( FrontEndProgramStats * stats ) // [HGM] done, but perhaps backend should call this directly? EngineOutputUpdate( stats ); } + +#include +int get_term_width() +{ + int fd, default_width; + + fd = STDIN_FILENO; + default_width = 79; // this is FICS default anyway... + +#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE) + struct ttysize win; + if (!ioctl(fd, TIOCGSIZE, &win)) + default_width = win.ts_cols; +#elif defined(TIOCGWINSZ) + struct winsize win; + if (!ioctl(fd, TIOCGWINSZ, &win)) + default_width = win.ws_col; +#endif + return default_width; +} + +void update_ics_width() +{ + static int old_width = 0; + int new_width = get_term_width(); + + if (old_width != new_width) + ics_printf("set width %d\n", new_width); + old_width = new_width; +} + +void NotifyFrontendLogin() +{ + update_ics_width(); +} diff --git a/xoptions.c b/xoptions.c index 969a97d..514c9d6 100644 --- a/xoptions.c +++ b/xoptions.c @@ -142,7 +142,7 @@ void ShuffleCallback(w, client_data, call_data) ShufflePopDown(); shuffleOpenings = False; // [HGM] should be moved to New Variant menu, once we have it! ResetGameEvent(); - AnalysisPopDown(); + EngineOutputPopDown(); return; } if (strcmp(name, _("random")) == 0) { @@ -164,7 +164,7 @@ void ShuffleCallback(w, client_data, call_data) shuffleOpenings = True; ShufflePopDown(); ResetGameEvent(); - AnalysisPopDown(); + EngineOutputPopDown(); return; } } diff --git a/zippy.c b/zippy.c index 2900a24..2698ac5 100644 --- a/zippy.c +++ b/zippy.c @@ -412,10 +412,6 @@ int ZippyControl(buf, i) char *player, *p; char reply[MSG_SIZ]; -#if TRIVIA -#include "trivia.c" -#endif - /* Possibly reject Crafty as opponent */ if (appData.zippyPlay && appData.zippyNoplayCrafty && forwardMostMove < 4 && looking_at(buf, i, "* kibitzes: Hello from Crafty"))