X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=24fd967df54780be9da6bdc0cd0dd3106e5ebf7a;hb=8e0e2f1c14e76ea660f7bff6a104baed0f0048df;hp=4ab4f93e06102cac56aaf1f4d5b118a5bdec454c;hpb=8e5273b69c00339351adf894ded9297a86729315;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 4ab4f93..24fd967 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1393,7 +1393,9 @@ ArgDescriptor argDescriptors[] = { { "secondNPS", ArgInt, (LPVOID) &appData.secondNPS, FALSE }, { "noGUI", ArgTrue, (LPVOID) &appData.noGUI, FALSE }, { "keepLineBreaksICS", ArgBoolean, (LPVOID) &appData.noJoin, TRUE }, - + { "wrapContinuationSequence", ArgString, (LPVOID) &appData.wrapContSeq, FALSE }, + { "useInternalWrap", ArgTrue, (LPVOID) &appData.useInternalWrap, FALSE }, /* noJoin usurps this if set */ + // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others { "minX", ArgZ, (LPVOID) &minX, FALSE }, // [HGM] placement: to make suer auxialary windows can be placed { "minY", ArgZ, (LPVOID) &minY, FALSE }, @@ -1494,6 +1496,10 @@ ParseFontName(char *name, MyFontParams *mfp) mfp->italic = (strchr(p, 'i') != NULL); mfp->underline = (strchr(p, 'u') != NULL); mfp->strikeout = (strchr(p, 's') != NULL); + mfp->charset = DEFAULT_CHARSET; + q = strchr(p, 'c'); + if (q) + mfp->charset = (BYTE) atoi(q+1); } /* Color name parser. @@ -1868,7 +1874,7 @@ LFfromMFP(LOGFONT* lf, MyFontParams *mfp) lf->lfItalic = mfp->italic; lf->lfUnderline = mfp->underline; lf->lfStrikeOut = mfp->strikeout; - lf->lfCharSet = DEFAULT_CHARSET; + lf->lfCharSet = mfp->charset; lf->lfOutPrecision = OUT_DEFAULT_PRECIS; lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; lf->lfQuality = DEFAULT_QUALITY; @@ -2491,13 +2497,14 @@ SaveSettings(char* name) for (bs=0; bsargLoc]->mfp; fprintf(f, "/size=%s ", sizeInfo[bs].name); - fprintf(f, "/%s=\"%s:%g%s%s%s%s%s\"\n", + fprintf(f, "/%s=\"%s:%g%s%s%s%s%sc%d\"\n", ad->argName, mfp->faceName, mfp->pointSize, mfp->bold || mfp->italic || mfp->underline || mfp->strikeout ? " " : "", mfp->bold ? "b" : "", mfp->italic ? "i" : "", mfp->underline ? "u" : "", - mfp->strikeout ? "s" : ""); + mfp->strikeout ? "s" : "", + (int)mfp->charset); } } break; @@ -5277,34 +5284,55 @@ LoadGameDialog(HWND hwnd, char* title) } } +int get_term_width() +{ + HDC hdc; + TEXTMETRIC tm; + RECT rc; + HFONT hfont, hold_font; + LOGFONT lf; + HWND hText; + + if (hwndConsole) + hText = GetDlgItem(hwndConsole, OPT_ConsoleText); + else + return 79; + + // get the text metrics + hdc = GetDC(hText); + lf = font[boardSize][CONSOLE_FONT]->lf; + if (consoleCF.dwEffects & CFE_BOLD) + lf.lfWeight = FW_BOLD; + if (consoleCF.dwEffects & CFE_ITALIC) + lf.lfItalic = TRUE; + if (consoleCF.dwEffects & CFE_STRIKEOUT) + lf.lfStrikeOut = TRUE; + if (consoleCF.dwEffects & CFE_UNDERLINE) + lf.lfUnderline = TRUE; + hfont = CreateFontIndirect(&lf); + 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); + + return (rc.right-rc.left) / tm.tmAveCharWidth; +} + void UpdateICSWidth(HWND hText) { - HDC hdc; - TEXTMETRIC tm; - RECT rc; - HFONT hfont, hold_font; - LONG old_width, new_width; - - // get the text metrics - hdc = GetDC(hText); - hfont = CreateFontIndirect(&font[boardSize][CONSOLE_FONT]->lf); - 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); - } + LONG old_width, new_width; + + new_width = get_term_width(hText, FALSE); + old_width = GetWindowLong(hText, GWL_USERDATA); + if (new_width != old_width) + { + ics_update_width(new_width); + SetWindowLong(hText, GWL_USERDATA, new_width); + } } VOID @@ -5400,7 +5428,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) JAWS_ALT_INTERCEPT - if (appData.icsActive && (char)wParam > ' ' && !((char)wParam >= '1' && (char)wParam <= '9')) { + if (appData.icsActive && ((char)wParam == '\r' || (char)wParam > ' ' && !((char)wParam >= '1' && (char)wParam <= '9'))) { // [HGM] movenum: for non-zero digits we always do type-in dialog HWND h = GetDlgItem(hwndConsole, OPT_ConsoleInput); if (IsIconic(hwndConsole)) ShowWindow(hwndConsole, SW_RESTORE); @@ -8026,7 +8054,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } // Allow hText to highlight URLs and send notifications on them - wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); + wMask = (WORD) 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 @@ -10340,6 +10368,11 @@ RemoveInputSource(InputSourceRef isr) } } +int no_wrap(char *message, int count) +{ + ConsoleOutput(message, count, FALSE); + return count; +} int OutputToProcess(ProcRef pr, char *message, int count, int *outError) @@ -10348,11 +10381,32 @@ OutputToProcess(ProcRef pr, char *message, int count, int *outError) int outCount = SOCKET_ERROR; ChildProc *cp = (ChildProc *) pr; static OVERLAPPED ovl; + static int line = 0; - if (pr == NoProc) { - ConsoleOutput(message, count, FALSE); - return count; - } + if (pr == NoProc) + { + if (appData.noJoin || !appData.useInternalWrap) + return no_wrap(message, count); + else + { + int width = get_term_width(); + int len = wrap(NULL, message, count, width, &line); + char *msg = malloc(len); + int dbgchk; + + if (!msg) + return no_wrap(message, count); + else + { + dbgchk = wrap(msg, message, count, width, &line); + if (dbgchk != len && appData.debugMode) + fprintf(debugFP, "wrap(): dbgchk(%d) != len(%d)\n", dbgchk, len); + ConsoleOutput(msg, len, FALSE); + free(msg); + return len; + } + } + } if (ovl.hEvent == NULL) { ovl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);