X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=884c85cc0ae5e3cc7c8d3903936692cb72f6c5b1;hb=bdd61153a00af769f75d1f20d7938642592cbce9;hp=bcd0c9ca37434402af6e488b05a9d54fec25ca6f;hpb=a5acdedf686f954492492595b327089f15de76a0;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index bcd0c9c..884c85c 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1392,6 +1392,7 @@ ArgDescriptor argDescriptors[] = { { "firstNPS", ArgInt, (LPVOID) &appData.firstNPS, FALSE }, { "secondNPS", ArgInt, (LPVOID) &appData.secondNPS, FALSE }, { "noGUI", ArgTrue, (LPVOID) &appData.noGUI, FALSE }, + { "keepLineBreaksICS", ArgBoolean, (LPVOID) &appData.noJoin, TRUE }, // [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 @@ -5456,6 +5457,36 @@ LoadGameDialog(HWND hwnd, char* title) } } +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); + } +} + 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); } /*---------------------------------------------------------------------------*\ @@ -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); } @@ -9512,6 +9543,11 @@ DrawPosition(int fullRedraw, Board board) HDCDrawPosition(NULL, (BOOLEAN) fullRedraw, board); } +void NotifyFrontendLogin() +{ + if (hwndConsole) + UpdateICSWidth(GetDlgItem(hwndConsole, OPT_ConsoleText)); +} VOID ResetFrontEnd()