Lines Matching +full:normal +full:-
4 * util.c -- miscellaneous utilities for dialog
6 * Copyright 2000-2020,2021 Thomas E. Dickey
116 #define UseShadow(dw) ((dw) != 0 && (dw)->normal != 0 && (dw)->shadow != 0)
123 /* *INDENT-OFF* */
155 DATA(A_NORMAL, ITEMHELP, itemhelp, "Item help-text"),
166 /* *INDENT-ON* */
178 p->normal = parent; in add_subwindow()
179 p->shadow = child; in add_subwindow()
180 p->getc_timeout = WTIMEOUT_OFF; in add_subwindow()
181 p->next = dialog_state.all_subwindows; in add_subwindow()
194 if (p->normal == parent) { in del_subwindows()
195 delwin(p->shadow); in del_subwindows()
196 r = p->next; in del_subwindows()
200 q->next = r; in del_subwindows()
206 p = p->next; in del_subwindows()
225 dlg_print_text(stdscr, dialog_vars.backtitle, COLS - 2, &attr); in dlg_put_backtitle()
226 for (i = 0; i < COLS - backwidth; i++) in dlg_put_backtitle()
229 for (i = 0; i < COLS - 2; i++) in dlg_put_backtitle()
277 * directly when stdout is redirected. By default we require the "--stdout"
321 * --input-fd option is used, it may be anything.
324 * if --stdout or --output-fd is used, it may be anything. We are concerned
346 if (dlg_parse_rc() == -1) /* Read the configuration file */ in init_dialog()
353 * pipe would get in the way of curses' normal reading stdin for getch. in init_dialog()
355 * As in the --stdout (see below), reopening the terminal does not always in init_dialog()
356 * work properly. dialog provides a --pipe-fd option for this purpose. We in init_dialog()
370 dlg_exiterr("cannot open tty-input"); in init_dialog()
378 dlg_exiterr("cannot open tty-input"); in init_dialog()
388 * If stdout is not a tty and dialog is called with the --stdout option, we in init_dialog()
403 * from the login user to another non-privileged user. in init_dialog()
414 dlg_exiterr("cannot open tty-output"); in init_dialog()
449 * Cancel xterm's alternate-screen mode. in dlg_keep_tite()
472 * Prevent ncurses from switching "back" to the normal screen when in dlg_keep_tite()
479 * implementation of alternate-screen in rxvt, etc., which clear in dlg_keep_tite()
498 static int defined_colors = 1; /* pair-0 is reserved */
643 * terminal cursor at the lower-left corner of the screen. in end_dialog()
673 result -= hidden; in dlg_count_real_columns()
685 left = (width - need) / 2 - 1; in centered()
707 *combined = (int) len - 1; in is_combining()
713 *combined -= 1; in is_combining()
754 indx[limit] - indx[1]); in dlg_print_listitem()
818 *attr |= define_color(win, code - '0'); in dlg_print_text()
899 tabbed += (x_after - x_before); in dlg_print_text()
953 && !isblank(UCH(prompt[indx[n - 1]]))) { in dlg_print_line()
959 n += (ESCAPE_LEN - 1); in dlg_print_line()
974 while (wrap_inx > 0 && isblank(UCH(prompt[indx[wrap_inx - 1]]))) { in dlg_print_line()
975 wrap_inx--; in dlg_print_line()
1000 hidden -= ESCAPE_LEN; in dlg_print_line()
1004 hidden -= ESCAPE_LEN; in dlg_print_line()
1017 dlg_print_text(win, prompt, (cols[wrap_inx] - hidden), attr); in dlg_print_line()
1025 *x -= hidden; in dlg_print_line()
1048 int lm = (2 * MARGIN); /* left margin (box-border plus a space) */ in justify_text()
1056 rm -= (2 * MARGIN); in justify_text()
1057 bm -= (2 * MARGIN); in justify_text()
1140 int wide = width - (2 * MARGIN); in dlg_print_scrolled()
1193 (void) wmove(win, MARGIN + height, wide - 4); in dlg_print_scrolled()
1198 whline(win, dlg_boxchar(ACS_HLINE), 4 - len); in dlg_print_scrolled()
1202 last = (y - height); in dlg_print_scrolled()
1238 --(*offset); in dlg_check_scrolled()
1250 *offset -= page; in dlg_check_scrolled()
1265 code = -1; in dlg_check_scrolled()
1282 int max_y = SLINES - 1; in auto_size_preformatted()
1283 int max_x = SCOLS - 2; in auto_size_preformatted()
1341 * if (height or width == -1) Maximize()
1361 *height = -1; in real_auto_size()
1363 *width = -1; in real_auto_size()
1372 high = SLINES - y; in real_auto_size()
1392 wide = SCOLS - x; in real_auto_size()
1418 *height = SLINES - (dialog_vars.begin_set ? dialog_vars.begin_y : 0); in real_auto_size()
1420 *width = SCOLS - (dialog_vars.begin_set ? dialog_vars.begin_x : 0); in real_auto_size()
1453 * if (height or width == -1) Maximize()
1476 if ((*height == -1) || (*width == -1)) { in dlg_auto_sizefile()
1477 *height = SLINES - (dialog_vars.begin_set ? dialog_vars.begin_y : 0); in dlg_auto_sizefile()
1478 *width = SCOLS - (dialog_vars.begin_set ? dialog_vars.begin_x : 0); in dlg_auto_sizefile()
1499 offset += dialog_state.tab_len - (offset % dialog_state.tab_len); in dlg_auto_sizefile()
1516 textbox-like widgets don't put all <file> on the screen. in dlg_auto_sizefile()
1517 Msgbox-like widget instead have to put all <text> correctly. */ in dlg_auto_sizefile()
1527 * boxchar is used to color the right/lower edges. It also is fill-color used
1531 * boxchar, and menubox_attr for borderchar since the scroll-arrows are drawn
1535 * If you want a raised effect (and are not going to use the scroll-arrows),
1551 else if (i == height - 1 && !j) in dlg_draw_box2()
1553 else if (!i && j == width - 1) in dlg_draw_box2()
1555 else if (i == height - 1 && j == width - 1) in dlg_draw_box2()
1559 else if (i == height - 1) in dlg_draw_box2()
1563 else if (j == width - 1) in dlg_draw_box2()
1580 * input-window, i.e., a window where we might use wgetch.
1582 * The all-windows list has normal- and shadow-windows. Since we never use the
1583 * shadow as an input window, normally we just look for the normal-window.
1585 * However, the all-subwindows list stores parent/child windows rather than
1586 * normal/shadow windows. When searching that list, we look for the child
1590 find_window(DIALOG_WINDOWS * list, WINDOW *win, bool normal) in find_window() argument
1595 for (p = list; p != 0; p = p->next) { in find_window()
1596 WINDOW *check = normal ? p->normal : p->shadow; in find_window()
1611 * against an asynchronous window-deletion that might invalidate the input
1627 * wide-character data.
1653 int y_want = y + getbegy(dw->shadow); in window_at_cell()
1654 int x_want = x + getbegx(dw->shadow); in window_at_cell()
1656 for (p = dialog_state.all_windows; p != 0; p = p->next) { in window_at_cell()
1657 if (dw->normal != p->normal in window_at_cell()
1658 && dw->shadow != p->normal in window_at_cell()
1659 && (result = in_window(p->normal, y_want, x_want)) != 0) { in window_at_cell()
1670 in_shadow(WINDOW *normal, WINDOW *shadow, int y, int x) in in_shadow() argument
1673 int ybase = getbegy(normal); in in_shadow()
1674 int ylast = getmaxy(normal) + ybase; in in_shadow()
1675 int xbase = getbegx(normal); in in_shadow()
1676 int xlast = getmaxx(normal) + xbase; in in_shadow()
1685 /* in the right-side */ in in_shadow()
1709 for (p = dialog_state.all_windows; p != 0; p = p->next) { in last_shadow()
1710 if (p->normal != dw->normal in last_shadow()
1711 && in_shadow(p->normal, dw->shadow, y, x)) { in last_shadow()
1722 WINDOW *win = dw->shadow; in repaint_cell()
1728 && (y2 = (y + getbegy(win) - getbegy(cellwin))) >= 0 in repaint_cell()
1729 && (x2 = (x + getbegx(win) - getbegx(cellwin))) >= 0 in repaint_cell()
1761 chtype save = dlg_get_attrs(dw->shadow); in repaint_shadow()
1762 dlg_attrset(dw->shadow, draw ? shadow_attr : screen_attr); in repaint_shadow()
1774 (void) wnoutrefresh(dw->shadow); in repaint_shadow()
1776 dlg_attrset(dw->shadow, save); in repaint_shadow()
1782 * Draw a shadow on the parent window corresponding to the right- and
1783 * bottom-edge of the child window, to give a 3-dimensional look.
1791 getbegy(dw->normal) - getbegy(dw->shadow), in draw_childs_shadow()
1792 getbegx(dw->normal) - getbegx(dw->shadow), in draw_childs_shadow()
1793 getmaxy(dw->normal), in draw_childs_shadow()
1794 getmaxx(dw->normal)); in draw_childs_shadow()
1799 * Erase a shadow on the parent window corresponding to the right- and
1800 * bottom-edge of the child window.
1808 getbegy(dw->normal) - getbegy(dw->shadow), in erase_childs_shadow()
1809 getbegx(dw->normal) - getbegx(dw->shadow), in erase_childs_shadow()
1810 getmaxy(dw->normal), in erase_childs_shadow()
1811 getmaxx(dw->normal)); in erase_childs_shadow()
1833 /* *INDENT-OFF* */ in dlg_exit()
1847 /* *INDENT-ON* */ in dlg_exit()
1863 * Prior to 2004/12/19, a widget using --item-help would exit with "OK" in dlg_exit()
1886 * Just in case of using --input-fd option, do not in dlg_exit()
1904 /* *INDENT-OFF* */
1919 /* *INDENT-ON* */
2002 * the function-return. Use this when only values greater than zero are
2066 * If the --tab-correct was not selected, convert tabs to single spaces.
2085 int rows = SLINES - (dialog_vars.begin_set ? dialog_vars.begin_y : 0); in dlg_calc_listh()
2086 if (rows - (*height) > 0) { in dlg_calc_listh()
2087 if (rows - (*height) > item_no) in dlg_calc_listh()
2090 *list_height = rows - (*height); in dlg_calc_listh()
2173 result = '-'; in dlg_asciibox()
2210 /* center dialog box on screen unless --begin-set */ in dlg_box_x_ordinate()
2211 x = (SCOLS - width) / 2; in dlg_box_x_ordinate()
2224 /* center dialog box on screen unless --begin-set */ in dlg_box_y_ordinate()
2225 y = (SLINES - height) / 2; in dlg_box_y_ordinate()
2240 dlg_print_text(win, title, getmaxx(win) - x, &attr); in dlg_draw_title()
2254 (void) wmove(win, height - 3, 0); in dlg_draw_bottom_box2()
2256 for (i = 0; i < width - 2; i++) in dlg_draw_bottom_box2()
2261 (void) wmove(win, height - 2, 1); in dlg_draw_bottom_box2()
2262 for (i = 0; i < width - 2; i++) in dlg_draw_bottom_box2()
2282 * If --keep-window was set, do not delete/repaint the windows. in dlg_del_window()
2296 for (p = dialog_state.all_windows, q = r = 0; p != 0; r = p, p = p->next) { in dlg_del_window()
2297 if (p->normal == win) { in dlg_del_window()
2298 q = p; /* found a match - should be only one */ in dlg_del_window()
2300 dialog_state.all_windows = p->next; in dlg_del_window()
2302 r->next = p->next; in dlg_del_window()
2305 if (p->shadow != 0) { in dlg_del_window()
2306 touchwin(p->shadow); in dlg_del_window()
2307 wnoutrefresh(p->shadow); in dlg_del_window()
2309 touchwin(p->normal); in dlg_del_window()
2310 wnoutrefresh(p->normal); in dlg_del_window()
2317 del_subwindows(q->normal); in dlg_del_window()
2318 dlg_unregister_window(q->normal); in dlg_del_window()
2319 delwin(q->normal); in dlg_del_window()
2335 * "Modal" windows differ from normal ones by having a shadow in a window
2350 p->next = dialog_state.all_windows; in dlg_new_modal_window()
2351 p->normal = win; in dlg_new_modal_window()
2352 p->getc_timeout = WTIMEOUT_OFF; in dlg_new_modal_window()
2356 p->shadow = parent; in dlg_new_modal_window()
2366 * dlg_getc() uses the return-value to determine how to handle an ERR return
2367 * from a non-blocking read:
2370 * b) if zero, it was a non-blocking read, or
2391 p->getc_timeout = interval; in dlg_set_timeout()
2402 wtimeout(win, p->getc_timeout); in dlg_reset_timeout()
2424 if (p->shadow != 0) { in dlg_move_window()
2426 (void) mvwin(p->shadow, y + SHADOW_ROWS, x + SHADOW_COLS); in dlg_move_window()
2428 p->shadow = 0; in dlg_move_window()
2496 dlg_exiterr("Can't make sub-window at (%d,%d), size (%d,%d).\n", in dlg_sub_window()
2532 while (items->name != 0) { in dlg_default_listitem()
2533 if (!strcmp(dialog_vars.default_item, items->name)) { in dlg_default_listitem()
2554 (void) wmove(stdscr, LINES - 1, 0); in dlg_item_help()
2557 dlg_print_text(stdscr, txt, COLS - 1, &attr); in dlg_item_help()
2586 cmp = ac - bc; in dlg_strcmp()
2603 while (dst-- != base) { in trim_blank()
2660 if (!isblank(UCH(*(s - 1)))) { in dlg_trim_string()
2668 else if (!isblank(UCH(*(s - 1)))) { in dlg_trim_string()
2728 * Setup a fixed-buffer for the result.
2797 * These are characters that (aside from the quote-delimiter) will have to
2798 * be escaped in a single- or double-quoted string.
2804 * Returns the quote-delimiter.
2863 * When adding a result, make that depend on whether "--quoted" is used.
2905 if (USE_ITEM_HELP(item->help)) { in dlg_add_help_listitem()
2906 *tag = dialog_vars.help_tags ? item->name : item->help; in dlg_add_help_listitem()
2909 *tag = item->name; in dlg_add_help_listitem()
2917 if (USE_ITEM_HELP(item->help)) { in dlg_add_help_formitem()
2918 *tag = dialog_vars.help_tags ? item->name : item->help; in dlg_add_help_formitem()
2921 *tag = item->name; in dlg_add_help_formitem()
2926 * Some widgets support only one value of a given variable - save/restore the
2936 * Most of the data in DIALOG_VARS is normally set by command-line options.
3039 for (p = dialog_state.all_subwindows; p != 0; p = p->next) { in dlg_wgetparent()
3040 if (p->shadow == win) { in dlg_wgetparent()
3041 result = p->normal; in dlg_wgetparent()