*** winboard/winboard.c Sat Feb 2 00:59:38 2002 --- winboard.c Tue Mar 5 03:29:42 2002 *************** *** 5586,5591 **** --- 5586,5693 ---- SendMessage(hCons, WM_INITDIALOG, 0, 0); } + BOOL httpseglight_continued = FALSE; + + char *spitlight(HWND hText, char *p, ColorClass cc, CHARRANGE *sel) { + + int effects; + + char *urlstart = p; + char backup; + + httpseglight_continued = TRUE; + + backup = 0; + while (*p) { + switch(*p) { + case '\n': case '\r': case ' ': case '\t': + backup = *p; *p = 0; httpseglight_continued = FALSE; break; + default: p++; + } + } + + effects = consoleCF.dwEffects; + + consoleCF.crTextColor = textAttribs[ColorKibitz].color; + consoleCF.dwEffects |= CFM_UNDERLINE; + + SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)sel); + SendMessage(hText, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&consoleCF); + + SendMessage(hText, EM_REPLACESEL, 0, (LPARAM) urlstart); + sel->cpMax = sel->cpMin += p - urlstart; + + consoleCF.crTextColor = textAttribs[currentColorClass].color; + consoleCF.dwEffects = effects; + + SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)sel); + SendMessage(hText, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&consoleCF); + + *p = backup; + + return p; + + } + + inline char *strnpstr(char *p, char *needle, char *end) { + + char *loc; + char *o = needle; + + while (p < end) { + + if (*p == *o) { + if (o==needle) loc = p; + o++; + } else o = needle; + + if (*o == 0) return loc; + + p++; + + } + + return p=NULL; + + } + + int seglight(HWND hText, char *p, char *end, char *seg, int seglen, ColorClass cc, CHARRANGE *sel) { + + char *op, *urlstart; + + if (p==NULL || seg == NULL || sel == NULL) return -1; + + if (httpseglight_continued) { + + p = spitlight(hText, p, cc, sel); + + } + + while (end-p >= seglen && (urlstart = strnpstr(p, seg, end)) != NULL) { + + op = urlstart; + + *op = 0; + SendMessage(hText, EM_REPLACESEL, 0, (LPARAM) p); + sel->cpMax = sel->cpMin += op - p; + + *op = seg[0]; + p = spitlight(hText, op, cc, sel); + + } + + if (end-p>0) { + + SendMessage(hText, EM_REPLACESEL, 0, (LPARAM) p); + sel->cpMax = sel->cpMin += end-p; + + } + + return 0; + + } + + VOID ConsoleOutput(char* data, int length, int forceVisible) *************** *** 5650,5656 **** sel.cpMax = exlen; SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); SendMessage(hText, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&consoleCF); ! SendMessage(hText, EM_REPLACESEL, 0, (LPARAM) buf); if (forceVisible || exlen == 0 || (rect.left <= pEnd.x && pEnd.x < rect.right && rect.top <= pEnd.y && pEnd.y < rect.bottom)) { --- 5752,5761 ---- sel.cpMax = exlen; SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); SendMessage(hText, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&consoleCF); ! ! /* append text while checking for and highlight links */ ! seglight(hText, buf, q, "http://", 7, ColorKibitz, &sel); ! if (forceVisible || exlen == 0 || (rect.left <= pEnd.x && pEnd.x < rect.right && rect.top <= pEnd.y && pEnd.y < rect.bottom)) {