Lines Matching +full:input +full:- +full:depth

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
46 unsigned int depth;
62 unsigned int xname; /* real x: xname + item.depth */
63 unsigned int xdesc; /* real x: xdesc + item.depth */
64 unsigned int line; /* wpad: prefix [] depth name desc */
69 int sel; /* current focus item, can be -1 */
102 m->nitems = 0;
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;
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;
129 pritem->group = i;
130 pritem->index = j;
131 pritem->type = getmode(mode, groups[i]);
133 pritem->prefix = CHECK_STR(item->prefix);
134 pritem->depth = item->depth;
135 pritem->name = CHECK_STR(item->name);
136 pritem->desc = CHECK_STR(item->desc);
137 pritem->bottomdesc = CHECK_STR(item->bottomdesc);
138 if (item->bottomdesc != NULL)
139 m->hasbottomdesc = true;
141 mbtowc(&pritem->shortcut, conf->menu.no_name ?
142 pritem->desc : pritem->name, MB_CUR_MAX);
149 m->xselector = m->xname = m->xdesc = m->line = 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);
186 for (i = 0; i < m->nitems; i++) {
187 if (m->pritems[i].type == SEPARATORMODE)
189 pritem = &m->pritems[i];
190 groups[pritem->group].items[pritem->index].on = pritem->on;
198 for (i = abs - 1; i >= 0; i--) {
226 if ((abs = getnext(npritems, pritems, -1)) < 0)
257 i--;
273 i--;
274 } while (abs != a && abs > start - menurows && i > 0);
284 next = -1;
291 if (i < abs && next == -1)
296 return (next != -1 ? next : abs);
304 for (i = 0; i < m->nitems; i++) {
305 if (m->pritems[i].type != SEPARATORMODE)
307 if (conf->no_lines == false) {
308 wattron(m->pad, t.menu.desccolor);
309 if (conf->ascii_lines)
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);
324 waddch(m->pad, ' ');
325 wattron(m->pad, t.menu.sepdesccolor);
326 waddstr(m->pad, desc);
327 wattroff(m->pad, t.menu.sepdesccolor);
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);
347 if (pritem->type == CHECKLISTMODE)
348 wprintw(m->pad, "[%c]", pritem->on ? 'X' : ' ');
349 if (pritem->type == RADIOLISTMODE)
350 wprintw(m->pad, "(%c)", pritem->on ? '*' : ' ');
351 wattroff(m->pad, focus ? t.menu.f_selectorcolor : t.menu.selectorcolor);
355 if (conf->menu.no_name == false) {
356 wattron(m->pad, colorname);
357 mvwaddstr(m->pad, y, m->xname + pritem->depth, pritem->name);
358 wattroff(m->pad, colorname);
362 if (conf->menu.no_name)
367 if (conf->menu.no_desc == false) {
368 wattron(m->pad, colordesc);
369 if (conf->menu.no_name)
370 mvwaddstr(m->pad, y, m->xname + pritem->depth,
371 pritem->desc);
373 mvwaddstr(m->pad, y, m->xdesc, pritem->desc);
374 wattroff(m->pad, colordesc);
378 if (conf->menu.shortcut_buttons == false) {
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) {
388 move(SCREENLINES - 1, 2);
392 addstr(pritem->bottomdesc);
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);
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;
434 if (set_widget_autosize(d->conf, d->rows, d->cols, &d->h, &d->w,
435 d->text, &htext, &d->bs, hmenu, m->line + 4) != 0)
438 if (d->h - BORDERS - htext - HBUTTONS <= 2 /* menuborders */)
439 m->menurows = (m->nitems > 0) ? 1 : 0; /* widget_checksize() */
441 m->menurows = MIN(d->h - BORDERS - htext - HBUTTONS, hmenu) - 2;
447 if (widget_checksize(d->h, d->w, &d->bs,
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)
459 if (d->built) {
463 m->menurows = m->apimenurows;
468 if (d->built)
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);
508 wint_t input;
514 set_buttons(&d, conf->menu.shortcut_buttons, OK_LABEL, CANCEL_LABEL);
515 if (d.conf->menu.no_name && d.conf->menu.no_desc)
542 if (get_wch(&input) == ERR)
544 switch(input) {
553 if (conf->key.enable_esc) {
567 d.bs.curr--;
569 d.bs.curr = d.bs.nbuttons - 1;
573 if (conf->key.f1_file == NULL &&
574 conf->key.f1_message == NULL)
590 switch(input) {
592 next = getnext(m.nitems, m.pritems, -1);
595 case '-':
627 for (i = m.sel - m.pritems[m.sel].index;
642 if (conf->menu.shortcut_buttons) {
643 if (shortcut_buttons(input, &d.bs)) {
656 input);
667 m.ypad = m.sel - m.menurows + 1;
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) {
683 move(SCREENLINES - 1, 2);