int TextProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2) { int i, len; CTLWINDOW *ct = GetControl(wnd); char *cp, *cp2 = ct->itext; switch (msg) { case SETFOCUS: return TRUE; case LEFT_BUTTON: return TRUE; case PAINT: if (ct == NULL || ct->itext == NULL || GetText(wnd) != NULL) break; len = min(ct->dwnd.h, MsgHeight(cp2)); cp = cp2; for (i = 0; i < len; i++) { int mlen; char *txt = cp; char *cp1 = cp; char *np = strchr(cp, '\n'); if (np != NULL) *np = '\0'; mlen = strlen(cp); while ((cp1=strchr(cp1,SHORTCUTCHAR)) != NULL) { mlen += 3; cp1++; } if (np != NULL) *np = '\n'; txt = DFmalloc(mlen+1); CopyCommand(txt, cp, FALSE, WndBackground(wnd)); txt[mlen] = '\0'; SendMessage(wnd, ADDTEXT, (PARAM)txt, 0); if ((cp = strchr(cp, '\n')) != NULL) cp++; free(txt); } break; default: break; } return BaseWndProc(TEXT, wnd, msg, p1, p2); }
/* ---------- PAINT Message ---------- */ static void PaintMsg(WINDOW wnd) { if (Selecting) return; if (wnd == inFocus) SendMessage(GetParent(wnd), ADDSTATUS, 0, 0); twputs(wnd, GetText(wnd), 0, 0); if (ActiveMenuBar->ActiveSelection != -1 && (wnd == inFocus || mwnd != NULL)) { ATTRCHR *sel, *cp; int offset, offset1; int i; int len; sel = DFmalloc(200 * sizeof(ATTRCHR)); offset=menu[ActiveMenuBar->ActiveSelection].x1; offset1=menu[ActiveMenuBar->ActiveSelection].x2; GetText(wnd)[offset1].ch = '\0'; for (i=0; i < 200; i++) { sel[i].ch = 0; } len = offset1 - offset; memcpy(sel, GetText(wnd) + offset, (len + 1) * sizeof(ATTRCHR)); for (i=0; i < len + 1; i++) { sel[i].attrib = clr((sel[i].attrib & 0xf), SelectBackground(wnd)); } twputs(wnd, sel, offset, 0); GetText(wnd)[offset1].ch = ' '; if (mwnd == NULL && wnd == inFocus) { char *st = ActiveMenu [ActiveMenuBar->ActiveSelection].StatusText; if (st != NULL) SendMessage(GetParent(wnd), ADDSTATUS, (PARAM)st, 0); } free(sel); } }
/* ---------- PAINT Message ---------- */ static void PaintMsg(WINDOW wnd) { if (Selecting) return; if (wnd == inFocus) SendMessage(GetParent(wnd), ADDSTATUS, 0, 0); SetStandardColor(wnd); wputs(wnd, GetText(wnd), 0, 0); if (ActiveMenuBar->ActiveSelection != -1 && (wnd == inFocus || mwnd != NULL)) { char *sel, *cp; int offset, offset1; sel = DFmalloc(200); offset=menu[ActiveMenuBar->ActiveSelection].x1; offset1=menu[ActiveMenuBar->ActiveSelection].x2; GetText(wnd)[offset1] = '\0'; SetReverseColor(wnd); memset(sel, '\0', 200); strcpy(sel, GetText(wnd)+offset); cp = strchr(sel, CHANGECOLOR); if (cp != NULL) *(cp + 2) = background | 0x80; wputs(wnd, sel, offset-ActiveMenuBar->ActiveSelection*4, 0); GetText(wnd)[offset1] = ' '; if (mwnd == NULL && wnd == inFocus) { char *st = ActiveMenu [ActiveMenuBar->ActiveSelection].StatusText; if (st != NULL) SendMessage(GetParent(wnd), ADDSTATUS, (PARAM)st, 0); } free(sel); } }