char *getstring (int w, char *str, char *head, char *mesg) { register r, c, h; int len; BOX *box; static char buf [81]; len = strlen (mesg); if (len > w) w = len; len = strlen (head); if (len > w) w = len; h = 4; w += 4; r = LINES/4; c = (78 - w) / 2; box = VGetBox (r-1, c-2, h+2, w+4); /* save box */ VStandOut (); VSetDim (); VFillBox (r-1, c-2, h+2, w+4, ' '); /* clear */ VDrawBox (r, c, h, w); /* draw margins */ VMPutString (r, c + (w-strlen(head)) / 2, head); /* head */ VMPutString (r+1, c+2, mesg); /* message */ VStandEnd (); VSetNormal (); strncpy (buf, str ? str : "", 80); str = editstring (r+2, c+2, w-4, buf, 0); VUngetBox (box); VFreeBox (box); return (str); }
void runhelp (char *name) { register r, c, w, h; BOX *box; register struct helptab *p; struct help *hp; hp = findhelp (name); if (! hp) return; p = hp->htab; if (! p->str) inithelp (hp); w = 72; h = 21; r = 2; c = 4; box = VGetBox (r, c-1, h, w+2); /* save box */ VStandOut (); VSetDim (); VFillBox (r, c-1, h, w+2, ' '); /* clear */ VDrawBox (r, c, h, w); /* draw margins */ VMPutString (r, c + (w-6) / 2, " Help "); /* head */ for (; p->row; ++p) { if (p->row >= h) continue; if (p->bold) { VSetBold (); VStandEnd (); } if (! p->col) VMPutString (r+p->row, c + (w-strlen(p->str))/2, p->str); else VMPutString (r+p->row, c + p->col, p->str); if (p->bold) { VSetDim (); VStandOut (); } } VStandEnd (); VSetNormal (); for (;;) { hidecursor (); VSync (); switch (KeyGet ()) { default: break; case cntrl (']'): /* redraw screen */ VRedraw (); continue; } break; } VUngetBox (box); VFreeBox (box); }
void big_menu (m) { struct b_field *b; register i, j = 1; BOX *left_box; b = batch_entry[batch_n]; lines = cols = wid_h = wid_e = 0; for (i = 0; b[i].header != NULL; i++) { lines++; wid_h = max( wid_h, (int) strlen( b[i].header )); wid_e = max( wid_e, b[i].width ); } cols = wid_h + 2 + wid_e; cols = max (cols, (int) strlen(batch_name[batch_n])); r = (LINES - lines) - 5; c = m ? 3 : (COLS - cols) - 5; endmesg (); if (m) { if (lines == 0) return; left_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4); } else { if (right_box != 0) { VUngetBox (right_box); VFreeBox (right_box); } right_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4); } VStandOut (); VFillBox (r - 1, c - 1, lines + 4, cols + 4, ' '); VStandEnd (); VDrawBox (r, c, lines+2, cols+2); VMPutString (r, (c + (cols + 2 - strlen(batch_name[batch_n])) / 2), batch_name[batch_n]); if (lines == 0) return; drawhdr (b); if (m) { for (i = 0; j != 0; i += j) { if (i >= lines) i = 0; else if (i < 0) i = lines - 1; j = editval1 (b + i, i); VStandOut (); printval (b + i, i); VStandEnd (); } VUngetBox (left_box); VFreeBox (left_box); } VSync (); }
static char *runudm (char *scale) { /* user defined menu */ register key, cm; BOX *box, *curbox; box = VGetBox (menurow-2, menucol-4, nm+4, menuwid+8); VSetDim (); VStandOut (); VFillBox (menurow-2, menucol-4, nm+4, menuwid+8, ' '); VDrawBox (menurow-1, menucol-1, nm+2, menuwid+2); mvcaddstr (menurow-1, 40, " User Menu "); printudm (); VSetNormal (); VStandEnd (); cm = 0; for (;;) { curbox = VGetBox (menurow+cm, menucol, 1, menuwid); VPrintBox (curbox); hidecursor (); VSync (); key = KeyGet (); VUngetBox (curbox); VFreeBox (curbox); switch (key) { default: findmenu: if (key>0 && key<0200 && scale [key] < MENUSZ) { cm = scale [key]; break; } VBeep (); continue; case meta ('A'): key = 1; goto findmenu; case meta ('B'): key = 2; goto findmenu; case meta ('C'): key = 3; goto findmenu; case meta ('D'): key = 4; goto findmenu; case meta ('E'): key = 5; goto findmenu; case meta ('F'): key = 6; goto findmenu; case meta ('G'): key = 7; goto findmenu; case meta ('H'): key = 8; goto findmenu; case meta ('I'): key = 9; goto findmenu; case cntrl (']'): /* redraw screen */ VRedraw (); continue; case cntrl ('M'): case cntrl ('J'): break; case cntrl ('C'): case cntrl ('['): case meta ('J'): /* f0 */ cm = -1; break; case meta ('u'): /* up */ if (--cm < 0) cm = nm-1; continue; case meta ('d'): /* down */ if (++cm >= nm) cm = 0; continue; } break; } VUngetBox (box); VFreeBox (box); if (cm >= 0 && um[cm].cex) { if (um[cm].menu) return (um[cm].cex); /* execute command from menu */ expand (command, um[cm].cex, cur->cat[cur->curfile].name); cpos = strlen (command); if (command [0]) execmd (um[cm].wait, um[cm].hist); } return ((char *) 0); }
int getchoice (int bold, char *head, char *msg, char *mesg2, char *c1, char *c2, char *c3) { int len, ch; int isattr; register r, c, w, h; BOX *box; char mesg[67]; strncpy(mesg, msg, sizeof (mesg)); mesg[sizeof(mesg)-1] = 0; w = strlen (mesg); if (mesg2) { len = strlen (mesg2); if (len > w) w = len; } len = strlen (head); if (len > w) w = len; len = 0; if (c1) len += strlen (c1); if (c2) len += strlen (c2); if (c3) len += strlen (c3); if (len > w) w = len; h = 6; w += 10; if (bold) r = LINES/2; else r = LINES/4; c = (80 - w) / 2; box = VGetBox (r-1, c-2, h+2, w+4); /* save box */ isattr = VStandOut (); if (bold) VSetBold (); else VSetDim (); VFillBox (r-1, c-2, h+2, w+4, ' '); /* clear */ VDrawBox (r, c, h, w); /* draw margins */ VMPutString (r, c + (w-strlen(head)) / 2, head); /* head */ if (mesg2) { VMPutString (r+1, c + (w-strlen(mesg)) / 2, mesg); VMPutString (r+2, c + (w-strlen(mesg2)) / 2, mesg2); } else VMPutString (r+2, c + (w-strlen(mesg)) / 2, mesg); if (c1) { if (isattr) { attron = VStandEnd; attroff = VStandOut; } else { attron = 0; attroff = 0; } initchoice (r+4, c+w/2, c1, c2, c3); ch = menuchoice (); VStandEnd (); VSetNormal (); VUngetBox (box); VFreeBox (box); return (ch); } else { /* message */ VStandEnd (); VSetNormal (); mbox = box; hidecursor (); VSync (); #ifdef DOC KeyGet (); #endif return (0); } }