Lines Matching +full:0 +full:d
137 memset(&mbs, 0, sizeof(mbs));
138 while ((charlen = mbrlen(pmbstring, MB_CUR_MAX, &mbs)) != 0 &&
155 ws[0] = wch;
156 ws[1] = L'\0';
171 ncol = 0;
172 memset(&mbs, 0, sizeof(mbs));
173 while ((charlen = mbrlen(mbstring, mb_cur_max, &mbs)) != 0 &&
175 if (mbtowc(&wch, mbstring, mb_cur_max) < 0)
178 ncol += (w < 0) ? 0 : w;
189 return (0);
201 ncol = 0;
202 memset(&mbs, 0, sizeof(mbs));
203 while ((charlen = mbrlen(mbstring, mb_cur_max, &mbs)) != 0 &&
205 if (mbtowc(&wch, mbstring, mb_cur_max) < 0)
206 return (0);
208 ncol += (w < 0) ? 0 : w;
223 if (bs->nbuttons > 0)
268 void draw_buttons(struct dialog *d)
273 y = d->h - 2;
275 newmargin = d->w - BORDERS - (d->bs.nbuttons * d->bs.sizebutton);
276 newmargin /= (d->bs.nbuttons + 1);
278 if (newmargin == 0) {
280 wbuttons = buttons_min_width(&d->bs);
283 wbuttons = d->bs.nbuttons * d->bs.sizebutton;
284 wbuttons += (d->bs.nbuttons + 1) * margin;
287 startx = d->w/2 - wbuttons/2 + newmargin;
288 for (i = 0; i < (int)d->bs.nbuttons; i++) {
289 x = i * (d->bs.sizebutton + margin);
290 draw_button(d->widget, y, startx + x, d->bs.sizebutton,
291 d->bs.label[i], d->bs.first[i], i == d->bs.curr,
292 d->bs.shortcut);
297 set_buttons(struct dialog *d, bool shortcut, const char *oklabel,
306 d->bs.nbuttons = 0;
307 d->bs.curr = 0;
308 d->bs.sizebutton = 0;
309 d->bs.shortcut = shortcut;
311 if (d->conf->button.left1_label != NULL) {
312 d->bs.label[d->bs.nbuttons] = d->conf->button.left1_label;
313 d->bs.value[d->bs.nbuttons] = BSDDIALOG_LEFT1;
314 d->bs.nbuttons += 1;
317 if (d->conf->button.left2_label != NULL) {
318 d->bs.label[d->bs.nbuttons] = d->conf->button.left2_label;
319 d->bs.value[d->bs.nbuttons] = BSDDIALOG_LEFT2;
320 d->bs.nbuttons += 1;
323 if (d->conf->button.left3_label != NULL) {
324 d->bs.label[d->bs.nbuttons] = d->conf->button.left3_label;
325 d->bs.value[d->bs.nbuttons] = BSDDIALOG_LEFT3;
326 d->bs.nbuttons += 1;
329 if (oklabel != NULL && d->conf->button.without_ok == false) {
330 d->bs.label[d->bs.nbuttons] = d->conf->button.ok_label != NULL ?
331 d->conf->button.ok_label : oklabel;
332 d->bs.value[d->bs.nbuttons] = BSDDIALOG_OK;
333 d->bs.nbuttons += 1;
336 if (d->conf->button.with_extra) {
337 d->bs.label[d->bs.nbuttons] = d->conf->button.extra_label != NULL ?
338 d->conf->button.extra_label : "Extra";
339 d->bs.value[d->bs.nbuttons] = BSDDIALOG_EXTRA;
340 d->bs.nbuttons += 1;
343 if (cancellabel != NULL && d->conf->button.without_cancel == false) {
344 d->bs.label[d->bs.nbuttons] = d->conf->button.cancel_label ?
345 d->conf->button.cancel_label : cancellabel;
346 d->bs.value[d->bs.nbuttons] = BSDDIALOG_CANCEL;
347 if (d->conf->button.default_cancel)
348 d->bs.curr = d->bs.nbuttons;
349 d->bs.nbuttons += 1;
352 if (d->conf->button.with_help) {
353 d->bs.label[d->bs.nbuttons] = d->conf->button.help_label != NULL ?
354 d->conf->button.help_label : "Help";
355 d->bs.value[d->bs.nbuttons] = BSDDIALOG_HELP;
356 d->bs.nbuttons += 1;
359 if (d->conf->button.right1_label != NULL) {
360 d->bs.label[d->bs.nbuttons] = d->conf->button.right1_label;
361 d->bs.value[d->bs.nbuttons] = BSDDIALOG_RIGHT1;
362 d->bs.nbuttons += 1;
365 if (d->conf->button.right2_label != NULL) {
366 d->bs.label[d->bs.nbuttons] = d->conf->button.right2_label;
367 d->bs.value[d->bs.nbuttons] = BSDDIALOG_RIGHT2;
368 d->bs.nbuttons += 1;
371 if (d->conf->button.right3_label != NULL) {
372 d->bs.label[d->bs.nbuttons] = d->conf->button.right3_label;
373 d->bs.value[d->bs.nbuttons] = BSDDIALOG_RIGHT3;
374 d->bs.nbuttons += 1;
377 if (d->bs.nbuttons == 0) {
378 d->bs.label[0] = DEFAULT_BUTTON_LABEL;
379 d->bs.value[0] = DEFAULT_BUTTON_VALUE;
380 d->bs.nbuttons = 1;
383 for (i = 0; i < (int)d->bs.nbuttons; i++) {
384 mbtowc(&first, d->bs.label[i], MB_CUR_MAX);
385 d->bs.first[i] = first;
388 if (d->conf->button.default_label != NULL) {
389 for (i = 0; i < (int)d->bs.nbuttons; i++) {
390 if (strcmp(d->conf->button.default_label,
391 d->bs.label[i]) == 0)
392 d->bs.curr = i;
396 d->bs.sizebutton = MAX(SIZEBUTTON - 2, strcols(d->bs.label[0]));
397 for (i = 1; i < (int)d->bs.nbuttons; i++)
398 d->bs.sizebutton = MAX(d->bs.sizebutton, strcols(d->bs.label[i]));
399 d->bs.sizebutton += 2;
408 for (i = 0; i < bs->nbuttons; i++) {
427 if (maxheight <= 0)
428 RETURN_ERROR("Terminal too small, screen lines - shadow <= 0");
430 if (conf->y != BSDDIALOG_CENTER && conf->auto_topmargin > 0)
431 RETURN_ERROR("conf.y > 0 and conf->auto_topmargin > 0");
434 if (maxheight <= 0)
436 "margins <= 0");
437 } else if (conf->y > 0) {
439 if (maxheight <= 0)
441 "shadow - y <= 0");
445 if (maxheight <= 0)
447 "<= 0");
457 if (maxwidth <= 0)
458 RETURN_ERROR("Terminal too small, screen cols - shadow <= 0");
460 if (conf->x > 0) {
462 if (maxwidth <= 0)
464 "- x <= 0");
476 if (wtext[0] != L'\\' || wtext[1] != L'Z')
504 tablen = (conf->text.tablen == 0) ? TABSIZE : (int)conf->text.tablen;
516 tp->nword = 0;
517 tp->maxline = 0;
518 tp->maxwordcols = 0;
520 currlinecols = 0;
521 wordcols = 0;
522 l = 0;
523 for (i = 0; i < wtextlen; i++) {
540 if (wordcols != 0) {
546 wordcols = 0;
560 currlinecols = 0;
579 if (wordcols != 0) {
589 return (0);
599 tablen = (conf->text.tablen == 0) ? TABSIZE : (int)conf->text.tablen;
609 x = 0;
611 line=0;
612 l = 0;
613 for (i = 0; i < tp->nword; i++) {
616 for (j = 0; j < tablen; j++) {
618 x = 0;
626 x = 0;
631 x = 0;
638 for (z = 0 ; z != tp->words[i]; l++ )
643 for (z = 0 ; z != tp->words[i]; l++ )
646 for (j = tp->words[i]; j > 0; ) {
647 y = (x == 0) ? y : y + 1;
648 z = 0;
671 *h = (tp->nword == 0) ? 0 : y;
674 return (0);
685 wbuttons = 0;
686 if (bs->nbuttons > 0)
695 if (bs->nbuttons > 0)
697 if (maxhtext <= 0)
712 if (startwtext <= 0 && changewtext)
716 if (text_properties(conf, text, &tp) != 0)
718 if (tp.nword > 0 && startwtext <= 0)
720 "needed at least %d cols to draw text",
723 wtext) != 0)
729 return (0);
764 min = 0;
767 if (bs->nbuttons > 0)
771 if (wtext > 0)
779 delimtitle = t.dialog.delimtitle ? 2 : 0;
825 return (0);
838 &htext, &wtext) != 0)
845 *h = widget_min_height(conf, htext, hnotext, bs->nbuttons > 0);
854 return (0);
862 if (bs->nbuttons > 0)
865 RETURN_FMTERROR("Current rows: %d, needed at least: %d",
868 minwidth = 0;
869 if (bs->nbuttons > 0)
874 RETURN_FMTERROR("Current cols: %d, nedeed at least %d",
877 return (0);
883 int hshadow = conf->shadow ? (int)t.shadow.y : 0;
884 int wshadow = conf->shadow ? (int)t.shadow.x : 0;
918 return (0);
921 int dialog_size_position(struct dialog *d, int hnotext, int minw, int *htext)
923 if (set_widget_size(d->conf, d->rows, d->cols, &d->h, &d->w) != 0)
925 if (set_widget_autosize(d->conf, d->rows, d->cols, &d->h, &d->w,
926 d->text, htext, &d->bs, hnotext, minw) != 0)
928 if (widget_checksize(d->h, d->w, &d->bs, hnotext, minw) != 0)
930 if (set_widget_position(d->conf, &d->y, &d->x, d->h, d->w) != 0)
933 return (0);
939 int hide_dialog(struct dialog *d)
943 if ((clear = newwin(d->h, d->w, d->y, d->x)) == NULL)
948 if (d->conf->shadow) {
949 mvwin(clear, d->y + t.shadow.y, d->x + t.shadow.x);
955 return (0);
974 output = bsddialog_msgbox(&hconf, conf->key.f1_message, 0, 0);
977 output = bsddialog_textbox(&hconf, conf->key.f1_file, 0, 0);
979 return (output == BSDDIALOG_ERROR ? BSDDIALOG_ERROR : 0);
993 setcchar(&hline, L"|", 0, 0, NULL);
995 setcchar(&vline, L"-", 0, 0, NULL);
997 setcchar(&corner, L"+", 0, 0, NULL);
1019 mvwadd_wch(win, 0, w-1, tr);
1037 rtextpad(struct dialog *d, int ytext, int xtext, int upnotext, int downnotext)
1039 pnoutrefresh(d->textpad, ytext, xtext,
1040 d->y + BORDER + upnotext,
1041 d->x + BORDER + TEXTHMARGIN,
1042 d->y + d->h - 1 - downnotext - BORDER,
1043 d->x + d->w - TEXTHMARGIN - BORDER);
1049 void end_dialog(struct dialog *d)
1051 if (d->conf->sleep > 0)
1052 sleep(d->conf->sleep);
1054 delwin(d->textpad);
1055 delwin(d->widget);
1056 if (d->conf->shadow)
1057 delwin(d->shadow);
1059 if (d->conf->clear)
1060 hide_dialog(d);
1062 if (d->conf->get_height != NULL)
1063 *d->conf->get_height = d->h;
1064 if (d->conf->get_width != NULL)
1065 *d->conf->get_width = d->w;
1075 if ((wtext[2] >= L'0') && (wtext[2] <= L'7')) {
1077 wattron(win, bsddialog_color(wtext[2] - L'0', bg, 0));
1092 case L'd':
1095 case L'D':
1134 ws[1] = L'\0';
1138 strwidth = 0;
1139 i=0;
1151 i = 0;
1154 if (*x != 0)
1160 *x = 0;
1173 ws[0] = str[i];
1197 tablen = (conf->text.tablen == 0) ? TABSIZE : (int)conf->text.tablen;
1199 i = j = x = y = 0;
1204 if (wcschr(L"\n\t ", string[j]) != NULL || string[j] == L'\0') {
1205 string[j] = L'\0';
1211 case L'\0':
1215 x = 0;
1220 for (z = 0; z < tablen; z++) {
1222 x = 0;
1232 x = 0;
1250 return (0);
1253 int draw_dialog(struct dialog *d)
1258 if (d->conf->ascii_lines) {
1259 setcchar(&ts, L"-", 0, 0, NULL);
1260 setcchar(<ee, L"+", 0, 0,NULL);
1261 setcchar(&rtee, L"+", 0, 0, NULL);
1268 if (d->conf->shadow) {
1269 wclear(d->shadow);
1270 wresize(d->shadow, d->h, d->w);
1271 mvwin(d->shadow, d->y + t.shadow.y, d->x + t.shadow.x);
1272 wnoutrefresh(d->shadow);
1275 wclear(d->widget);
1276 wresize(d->widget, d->h, d->w);
1277 mvwin(d->widget, d->y, d->x);
1278 draw_borders(d->conf, d->widget, RAISED);
1280 if (d->conf->title != NULL) {
1281 if ((wtitle = strcols(d->conf->title)) < 0)
1283 if (t.dialog.delimtitle && d->conf->no_lines == false) {
1284 wattron(d->widget, t.dialog.lineraisecolor);
1285 mvwadd_wch(d->widget, 0, d->w/2 - wtitle/2 -1, &rtee);
1286 wattroff(d->widget, t.dialog.lineraisecolor);
1288 wattron(d->widget, t.dialog.titlecolor);
1289 mvwaddstr(d->widget, 0, d->w/2 - wtitle/2, d->conf->title);
1290 wattroff(d->widget, t.dialog.titlecolor);
1291 if (t.dialog.delimtitle && d->conf->no_lines == false) {
1292 wattron(d->widget, t.dialog.lineraisecolor);
1293 wadd_wch(d->widget, <ee);
1294 wattroff(d->widget, t.dialog.lineraisecolor);
1298 if (d->bs.nbuttons > 0) {
1299 if (d->conf->no_lines == false) {
1300 wattron(d->widget, t.dialog.lineraisecolor);
1301 mvwadd_wch(d->widget, d->h-3, 0, <ee);
1302 mvwhline_set(d->widget, d->h-3, 1, &ts, d->w-2);
1303 wattroff(d->widget, t.dialog.lineraisecolor);
1305 wattron(d->widget, t.dialog.linelowercolor);
1306 mvwadd_wch(d->widget, d->h-3, d->w-1, &rtee);
1307 wattroff(d->widget, t.dialog.linelowercolor);
1309 draw_buttons(d);
1312 if (d->conf->bottomtitle != NULL) {
1313 if ((wbottomtitle = strcols(d->conf->bottomtitle)) < 0)
1315 wattron(d->widget, t.dialog.bottomtitlecolor);
1316 wmove(d->widget, d->h - 1, d->w/2 - wbottomtitle/2 - 1);
1317 waddch(d->widget, ' ');
1318 waddstr(d->widget, d->conf->bottomtitle);
1319 waddch(d->widget, ' ');
1320 wattroff(d->widget, t.dialog.bottomtitlecolor);
1323 wnoutrefresh(d->widget);
1325 wclear(d->textpad);
1326 /* `infobox "" 0 2` fails but text is empty and textpad remains 1 1 */
1327 wresize(d->textpad, 1, d->w - BORDERS - TEXTHMARGINS);
1329 if (print_textpad(d->conf, d->textpad, d->text) != 0)
1332 d->built = true;
1334 return (0);
1339 int cols, struct dialog *d)
1343 d->built = false;
1344 d->conf = conf;
1345 d->rows = rows;
1346 d->cols = cols;
1347 d->text = CHECK_STR(text);
1348 d->bs.nbuttons = 0;
1350 if (d->conf->shadow) {
1351 if ((d->shadow = newwin(1, 1, 1, 1)) == NULL)
1353 wbkgd(d->shadow, t.shadow.color);
1356 if ((d->widget = newwin(1, 1, 1, 1)) == NULL)
1358 wbkgd(d->widget, t.dialog.color);
1361 if ((d->textpad = newpad(1, 1)) == NULL)
1363 wbkgd(d->textpad, t.dialog.color);
1365 return (0);