void printmenuitem(const char *name, int sel) { #if !NO_MENU if (*name == '-') { putch(' '); if (!name[1]) putnchars('-', 16); else printstr(name); return; } #endif if (!sel) setcolorpair(MAGENTA_FG); else if (!_MONOCHROME) setcolorpair(WHITE_ON_BLUE); else setattr_standout(); if (sel && (textgfx_flags & TT_MONO)==TT_BLOCKS) { while (*name==' ') { putch(' '); name++; } putch('*'); } else putch(' '); printstr(name); putch(' '); setattr_normal(); movefwd(1); }
void printtextbox(const char *text, int pos) { int underscore; if (_WHITE_BG) underscore = textgfx_flags & (ASCII | GNOME_TERM) || !_XTERM; else underscore = textgfx_flags & (MONOCHROME | TT_BLOCKS); while (*text) { setattr_normal(); if (!pos) setattr_standout(); else { if (_WHITE_BG) { if (!underscore || textgfx_flags & GNOME_TERM) setattr_underline(); } else setcolorpair(WHITE_ON_BLUE); } if (*text == ' ' && underscore) putch('_'); else putch(*text); text++; pos--; } setattr_normal(); }
int dropdownlist(const char **items, int n, int i, int x, int y) { int w = getdropdownwidth(items, n); int j; while (is_outside_screen(0, y+n+1)) y--; setattr_standout(); drawbox(x, y, w+2, n+2, NULL); x++; y++; setcurs(x, y); for (j = 0; j < n; j++) { printdropdownitem(items[j], i==j, w); newln(x); } while (1) { setcurs(x-1, y+i); refreshwin(-1); switch (getkeypress_block(SINGLE_PL) & 0xFF) { case STARTBTN: case A_BTN: goto out; case 'q': exit(0); case MVUP: if (!i) continue; j = -1; break; case '\t': if (i == n-1) { j = -i; break; } case MVDOWN: if (i < n-1) { j = 1; break; } case MVRIGHT: continue; default: i = -1; goto out; } setcurs(x, y+i); printdropdownitem(items[i], 0, w); i += j; setcurs(x, y+i); printdropdownitem(items[i], 1, w); } out: clearbox(x-1, y-1, w+2, n+2); return i+1; }
static void printdropdownitem(const char *name, int sel, int w) { if (sel) { while (name[0]==' ' && name[1]==' ') { putch(' '); name++; w--; } setattr_normal(); } printstr(name); if (strlen(name) < w) putch(' '); if (sel) setattr_standout(); }
static void printsavebutton(int sel) { if (_MONOCHROME) { if (sel) setattr_standout(); else setattr_bold(); } else if (sel) { setcolorpair(YELLOW_ON_GREEN); } else { setcolorpair(4); putch('['); setcolorpair(YELLOW_ON_BLUE); printstr(" Save "); setcolorpair(4); putch(']'); goto out; } printstr("[ Save ]"); out: setattr_normal(); }
void printmenuitem_options(const char *str, int sel) { char buf[16]; const char *p = str; int ret; while (1) { if (p = strchr(str, ' ')) { memcpy(buf, str, p-str); buf[p-str] = '\0'; } else strcpy(buf, str); if (!sel) { setattr_standout(); ret = printstr(buf); setattr_normal(); } else ret = printstr(buf); if (!ret || !p) break; putch(' '); str = p+1; sel--; } }