static void drawmenu (struct menu *m) { register i, reverse; VClearBox (1, m->col-1, m->hgh+3, m->wid+4); VSetBold (); VDrawBox (1, m->col, m->hgh+2, m->wid+2); VSetDim (); for (i=0; m->submenu[i].name; ++i) if (! m->submenu[i].name[0]) VHorLine (i+2, m->col+2, m->wid-2); VSetNormal (); for (i=0; m->submenu[i].name; ++i) { if (! m->submenu[i].name[0]) continue; reverse = 0; if (i == m->nsm) reverse = VStandOut (); else if (! m->submenu[i].active) VSetDim (); VMove (2+i, m->col+1); VPutChar (i==m->nsm && !reverse ? '[' : ' '); VPrint ("%c %-*s", m->submenu[i].tag ? '*' : ' ', m->wid-4, m->submenu[i].name); VPutChar (i==m->nsm && !reverse ? ']' : ' '); if (i == m->nsm) VStandEnd (); else if (! m->submenu[i].active) VSetNormal (); } }
static void drawhead (int nm) { register i, reverse; VSetDim (); reverse = VStandOut (); VMove (0, 0); for (i=0; i<80; ++i) VPutChar (' '); VMove (0, 2); for (i=0; menu[i].name; ++i) { if (i == nm) { VStandEnd (); VSetBold (); } VPutChar (' '); VPutChar (i==nm && !reverse ? '[' : ' '); VPutString (menu[i].name); VPutChar (i==nm && !reverse ? ']' : ' '); VPutChar (' '); if (i == nm) { VStandOut (); VSetDim (); } } VSetNormal (); VStandEnd (); }
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); }
drawcmd () { int c; CURSOR cursor; if (H==LINES-7 && strlen (cur->shortcwd) + 3 + esclen (command) > 79) { fullscreen (); draw (); } for (c=H+5; c<LINES-1; ++c) { VMove (c, 0); VClearLine (); } VSetDim (); VMPutString (H+5, 0, cur->shortcwd); VSetBold (); VPutString (" > "); VSetNormal (); cursor = VGetCursor (); putescstr (command); if (c = command [cpos]) { VSetCursor (cursor); command [cpos] = 0; putescstr (command); command [cpos] = c; } }
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); }
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); } }