Lines Matching full:m

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