Lines Matching +full:0 +full:m

89 build_privatemenu(struct bsddialog_conf *conf, struct privatemenu *m,
102 m->nitems = 0;
103 for (i = 0; i < (int)ngroups; i++) {
105 m->nitems += (int)groups[i].nitems;
109 m->pritems = calloc(m->nitems, sizeof (struct privateitem));
110 if (m->pritems == NULL)
112 m->hasbottomdesc = false;
113 abs = 0;
114 for (i = 0; i < (int)ngroups; i++) {
116 for (j = 0; j < (int)groups[i].nitems; j++) {
118 pritem = &m->pritems[abs];
121 m->pritems[abs].on = false;
123 m->pritems[abs].on = onetrue ? false : item->on;
124 if (m->pritems[abs].on)
127 m->pritems[abs].on = item->on;
139 m->hasbottomdesc = true;
149 m->xselector = m->xname = m->xdesc = m->line = 0;
150 maxsepstr = maxprefix = selectorlen = maxdepth = maxname = maxdesc = 0;
151 for (i = 0; i < m->nitems; i++) {
152 if (m->pritems[i].type == RADIOLISTMODE ||
153 m->pritems[i].type == CHECKLISTMODE)
156 if (m->pritems[i].type == SEPARATORMODE) {
158 strcols(m->pritems[i].name) +
159 strcols(m->pritems[i].desc));
163 maxprefix = MAX(maxprefix, strcols(m->pritems[i].prefix));
164 maxdepth = MAX(maxdepth, m->pritems[i].depth);
165 maxname = MAX(maxname, strcols(m->pritems[i].name));
166 maxdesc = MAX(maxdesc, strcols(m->pritems[i].desc));
168 maxname = conf->menu.no_name ? 0 : maxname;
169 maxdesc = conf->menu.no_desc ? 0 : maxdesc;
171 m->xselector = maxprefix + (maxprefix != 0 ? 1 : 0);
172 m->xname = m->xselector + selectorlen;
173 m->xdesc = maxdepth + m->xname + maxname;
174 m->xdesc += (maxname != 0 ? 1 : 0);
175 m->line = MAX(maxsepstr + 3, m->xdesc + maxdesc);
177 return (0);
181 set_return_on(struct privatemenu *m, struct bsddialog_menugroup *groups)
186 for (i = 0; i < m->nitems; i++) {
187 if (m->pritems[i].type == SEPARATORMODE)
189 pritem = &m->pritems[i];
198 for (i = abs - 1; i >= 0; i--) {
226 if ((abs = getnext(npritems, pritems, -1)) < 0)
231 if (*focusgroup < 0 || *focusgroup >= ngroups)
235 if (*focusitem < 0 || *focusitem >= (int)groups[*focusgroup].nitems)
258 } while (abs != a && abs < start + menurows && i > 0);
274 } while (abs != a && abs > start - menurows && i > 0);
285 for (i = 0; i < npritems; i++) {
299 static void drawseparators(struct bsddialog_conf *conf, struct privatemenu *m)
304 for (i = 0; i < m->nitems; i++) {
305 if (m->pritems[i].type != SEPARATORMODE)
308 wattron(m->pad, t.menu.desccolor);
310 mvwhline(m->pad, i, 0, '-', m->line);
312 mvwhline_set(m->pad, i, 0, WACS_HLINE, m->line);
313 wattroff(m->pad, t.menu.desccolor);
315 name = m->pritems[i].name;
316 desc = m->pritems[i].desc;
317 realw = m->xe - m->xs;
319 wmove(m->pad, i, (labellen < realw) ? realw/2 - labellen/2 : 0);
320 wattron(m->pad, t.menu.sepnamecolor);
321 waddstr(m->pad, name);
322 wattroff(m->pad, t.menu.sepnamecolor);
323 if (strcols(name) > 0 && strcols(desc) > 0)
324 waddch(m->pad, ' ');
325 wattron(m->pad, t.menu.sepdesccolor);
326 waddstr(m->pad, desc);
327 wattroff(m->pad, t.menu.sepdesccolor);
332 drawitem(struct bsddialog_conf *conf, struct privatemenu *m, int y, bool focus)
337 pritem = &m->pritems[y];
340 wattron(m->pad, focus ? t.menu.f_prefixcolor : t.menu.prefixcolor);
341 mvwaddstr(m->pad, y, 0, pritem->prefix);
342 wattroff(m->pad, focus ? t.menu.f_prefixcolor : t.menu.prefixcolor);
345 wmove(m->pad, y, m->xselector);
346 wattron(m->pad, focus ? t.menu.f_selectorcolor : t.menu.selectorcolor);
348 wprintw(m->pad, "[%c]", pritem->on ? 'X' : ' ');
350 wprintw(m->pad, "(%c)", pritem->on ? '*' : ' ');
351 wattroff(m->pad, focus ? t.menu.f_selectorcolor : t.menu.selectorcolor);
356 wattron(m->pad, colorname);
357 mvwaddstr(m->pad, y, m->xname + pritem->depth, pritem->name);
358 wattroff(m->pad, colorname);
368 wattron(m->pad, colordesc);
370 mvwaddstr(m->pad, y, m->xname + pritem->depth,
373 mvwaddstr(m->pad, y, m->xdesc, pritem->desc);
374 wattroff(m->pad, colordesc);
381 wattron(m->pad, colorshortcut);
382 mvwaddwch(m->pad, y, m->xname + pritem->depth, pritem->shortcut);
383 wattroff(m->pad, colorshortcut);
387 if (m->hasbottomdesc) {
399 static void update_menubox(struct bsddialog_conf *conf, struct privatemenu *m)
403 draw_borders(conf, m->box, LOWERED);
404 getmaxyx(m->box, h, w);
406 if (m->nitems > (int)m->menurows) {
407 wattron(m->box, t.dialog.arrowcolor);
408 if (m->ypad > 0)
409 mvwhline(m->box, 0, 2, UARROW(conf), 3);
411 if ((m->ypad + (int)m->menurows) < m->nitems)
412 mvwhline(m->box, h-1, 2, DARROW(conf), 3);
414 mvwprintw(m->box, h-1, w-6, "%3d%%",
415 100 * (m->ypad + m->menurows) / m->nitems);
416 wattroff(m->box, t.dialog.arrowcolor);
420 static int menu_size_position(struct dialog *d, struct privatemenu *m)
424 if (set_widget_size(d->conf, d->rows, d->cols, &d->h, &d->w) != 0)
427 hmenu = (int)(m->menurows == BSDDIALOG_AUTOSIZE) ?
428 (int)m->nitems : (int)m->menurows;
435 d->text, &htext, &d->bs, hmenu, m->line + 4) != 0)
439 m->menurows = (m->nitems > 0) ? 1 : 0; /* widget_checksize() */
441 m->menurows = MIN(d->h - BORDERS - htext - HBUTTONS, hmenu) - 2;
448 2 /* border box */ + MIN(m->menurows, 1), 0) != 0)
451 if (set_widget_position(d->conf, &d->y, &d->x, d->h, d->w) != 0)
454 return (0);
457 static int mixedlist_redraw(struct dialog *d, struct privatemenu *m)
463 m->menurows = m->apimenurows;
464 if (menu_size_position(d, m) != 0)
466 if (draw_dialog(d) != 0)
470 TEXTPAD(d, 2/*bmenu*/ + m->menurows + HBUTTONS);
473 if (m->ypad > m->sel && m->ypad > 0)
474 m->ypad = m->sel;
475 if ((int)(m->ypad + m->menurows) <= m->sel)
476 m->ypad = m->sel - m->menurows + 1;
478 if (m->ypad > 0 && (m->nitems - m->ypad) < (int)m->menurows)
479 m->ypad = m->nitems - m->menurows;
481 update_box(d->conf, m->box, d->y + d->h - 5 - m->menurows, d->x + 2,
482 m->menurows+2, d->w-4, LOWERED);
483 update_menubox(d->conf, m);
484 wnoutrefresh(m->box);
486 m->ys = d->y + d->h - 5 - m->menurows + 1;
487 m->ye = d->y + d->h - 5 ;
488 if (d->conf->menu.align_left || (int)m->line > d->w - 6) {
489 m->xs = d->x + 3;
490 m->xe = m->xs + d->w - 7;
492 m->xs = d->x + 3 + (d->w-6)/2 - m->line/2;
493 m->xe = m->xs + d->w - 5;
495 drawseparators(d->conf, m); /* uses xe - xs */
496 pnoutrefresh(m->pad, m->ypad, 0, m->ys, m->xs, m->ye, m->xe);
498 return (0);
509 struct privatemenu m;
512 if (prepare_dialog(conf, text, rows, cols, &d) != 0)
518 if (build_privatemenu(conf, &m, mode, ngroups, groups) != 0)
521 if ((m.box = newwin(1, 1, 1, 1)) == NULL)
523 wbkgd(m.box, t.dialog.color);
524 m.pad = newpad(m.nitems, m.line);
525 wbkgd(m.pad, t.dialog.color);
527 for (i = 0; i < m.nitems; i++)
528 drawitem(conf, &m, i, false);
529 m.sel = getfirst_with_default(m.nitems, m.pritems, ngroups, groups,
531 if (m.sel >= 0)
532 drawitem(d.conf, &m, m.sel, true);
533 m.ypad = 0;
534 m.apimenurows = menurows;
535 if (mixedlist_redraw(&d, &m) != 0)
548 if (m.sel >= 0 && m.pritems[m.sel].type == MENUMODE)
549 m.pritems[m.sel].on = true;
555 if (m.sel >= 0 &&
556 m.pritems[m.sel].type == MENUMODE)
557 m.pritems[m.sel].on = true;
568 if (d.bs.curr < 0)
576 if (f1help_dialog(conf) != 0)
578 if (mixedlist_redraw(&d, &m) != 0)
583 if (mixedlist_redraw(&d, &m) != 0)
588 if (m.sel < 0)
592 next = getnext(m.nitems, m.pritems, -1);
593 changeitem = next != m.sel;
598 next = getprev(m.pritems, m.sel);
599 changeitem = next != m.sel;
602 next = getfastprev(m.menurows, m.pritems, m.sel);
603 changeitem = next != m.sel;
606 next = getprev(m.pritems, m.nitems);
607 changeitem = next != m.sel;
612 next = getnext(m.nitems, m.pritems, m.sel);
613 changeitem = next != m.sel;
616 next = getfastnext(m.menurows, m.nitems, m.pritems, m.sel);
617 changeitem = next != m.sel;
620 if (m.pritems[m.sel].type == MENUMODE) {
622 m.pritems[m.sel].on = true;
624 } else if (m.pritems[m.sel].type == CHECKLISTMODE) {
625 m.pritems[m.sel].on = !m.pritems[m.sel].on;
627 for (i = m.sel - m.pritems[m.sel].index;
628 i < m.nitems &&
629 m.pritems[i].group == m.pritems[m.sel].group;
631 if (i != m.sel && m.pritems[i].on) {
632 m.pritems[i].on = false;
633 drawitem(conf, &m, i, false);
636 m.pritems[m.sel].on = !m.pritems[m.sel].on;
638 drawitem(conf, &m, m.sel, true);
639 pnoutrefresh(m.pad, m.ypad, 0, m.ys, m.xs, m.ye, m.xe);
647 if (m.pritems[m.sel].type == MENUMODE)
648 m.pritems[m.sel].on = true;
655 next = getnextshortcut(m.nitems, m.pritems, m.sel,
657 changeitem = next != m.sel;
661 drawitem(conf, &m, m.sel, false);
662 m.sel = next;
663 drawitem(conf, &m, m.sel, true);
664 if (m.ypad > m.sel && m.ypad > 0)
665 m.ypad = m.sel;
666 if ((int)(m.ypad + m.menurows) <= m.sel)
667 m.ypad = m.sel - m.menurows + 1;
668 update_menubox(conf, &m);
669 wnoutrefresh(m.box);
670 pnoutrefresh(m.pad, m.ypad, 0, m.ys, m.xs, m.ye, m.xe);
675 set_return_on(&m, groups);
678 *focuslist = m.sel < 0 ? -1 : m.pritems[m.sel].group;
680 *focusitem = m.sel < 0 ? -1 : m.pritems[m.sel].index;
682 if (m.hasbottomdesc && conf->clear) {
686 delwin(m.pad);
687 delwin(m.box);
689 free(m.pritems);
713 int retval, focuslist = 0;
715 BSDDIALOG_CHECKLIST /* unused */, nitems, items, 0};
729 int retval, focuslist = 0;
731 BSDDIALOG_CHECKLIST /* unused */, nitems, items, 0};
745 int retval, focuslist = 0;
747 BSDDIALOG_RADIOLIST /* unused */, nitems, items, 0};