/* --------- BUILDMENU Message --------- */ static void BuildMenuMsg(WINDOW wnd, PARAM p1) { int offset = 3; reset_menubar(wnd); mctr = 0; ActiveMenuBar = (MBAR *) p1; ActiveMenu = ActiveMenuBar->PullDown; while (ActiveMenu->Title != NULL && ActiveMenu->Title != (void*)-1) { char *cp; if (strlen(GetText(wnd)+offset) < strlen(ActiveMenu->Title)+3) break; GetText(wnd) = DFrealloc(GetText(wnd), strlen(GetText(wnd))+5); memmove(GetText(wnd) + offset+4, GetText(wnd) + offset, strlen(GetText(wnd))-offset+1); CopyCommand(GetText(wnd)+offset,ActiveMenu->Title,FALSE, wnd->WindowColors [STD_COLOR] [BG]); menu[mctr].x1 = offset; offset += strlen(ActiveMenu->Title) + (3+MSPACE); menu[mctr].x2 = offset-MSPACE; cp = strchr(ActiveMenu->Title, SHORTCUTCHAR); if (cp) menu[mctr].sc = tolower(*(cp+1)); mctr++; ActiveMenu++; } ActiveMenu = ActiveMenuBar->PullDown; }
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); }