Lines Matching +full:1 +full:d

9  * 1. Redistributions of source code must retain the above copyright
39 * -1- Error and diagnostic
59 * set_buttons(); (to call 1 time after prepare_dialog()).
100 * -1- Error and diagnostic
113 strncpy(errorbuffer, str, ERRBUFLEN-1);
121 vsnprintf(errorbuffer, ERRBUFLEN-1, fmt, arg_ptr);
135 nchar = 1;
139 charlen != (size_t)-1 && charlen != (size_t)-2) {
156 ws[1] = L'\0';
174 charlen != (size_t)-1 && charlen != (size_t)-2) {
176 return (-1);
179 if (w > 1 && wch != L'\t')
204 charlen != (size_t)-1 && charlen != (size_t)-2) {
224 width += (bs->nbuttons - 1) * t.button.minmargin;
249 for (i = 1; i < size - 1; i++)
256 x = x + 1 + ((size - 2 - strcols(text))/2);
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);
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;
476 if (wtext[0] != L'\\' || wtext[1] != L'Z')
484 #define NL -1
525 i += 2; /* +1 for update statement */
529 if (tp->nword + 1 >= maxwords) {
545 tp->nword += 1;
566 currlinecols += 1;
571 tp->nword += 1;
581 tp->nword += 1;
610 y = 1;
647 y = (x == 0) ? y : y + 1;
698 maxhtext = 1; /* text_autosize() computes always htext */
713 startwtext = 1;
720 "needed at least %d cols to draw text",
721 BORDERS + TEXTHMARGINS + 1);
809 RETURN_ERROR("Negative (less than -1) height");
820 RETURN_ERROR("Negative (less than -1) width");
865 RETURN_FMTERROR("Current rows: %d, needed at least: %d",
874 RETURN_FMTERROR("Current cols: %d, nedeed at least %d",
894 RETURN_ERROR("Negative begin y (less than -1)");
908 RETURN_ERROR("Negative begin x (less than -1)");
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)
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);
1019 mvwadd_wch(win, 0, w-1, tr);
1020 mvwvline_set(win, 1, w-1, rs, h-2);
1021 mvwadd_wch(win, h-1, w-1, br);
1022 mvwhline_set(win, h-1, 1, bs, w-2);
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;
1092 case L'd':
1095 case L'D':
1134 ws[1] = L'\0';
1155 *y = *y + 1;
1157 *rows = *y + 1;
1193 if ((string = calloc(wcslen(wtext) + 1, sizeof(wchar_t))) == NULL)
1217 j = -1;
1227 j = -1;
1235 j = -1;
1239 rows = y + 1;
1253 int draw_dialog(struct dialog *d)
1258 if (d->conf->ascii_lines) {
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, &ltee);
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, &ltee);
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;
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);