Lines Matching +full:offset +full:- +full:y
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()
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()
479 * implementation of alternate-screen in rxvt, etc., which clear in dlg_keep_tite()
498 static int defined_colors = 1; /* pair-0 is reserved */
515 #define C_ATTR(x,y) (((x) != 0 ? A_BOLD : 0) | COLOR_PAIR((y))) in dlg_color_setup() argument
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()
1046 int y = MARGIN; in justify_text() local
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()
1064 while (y <= bm && *prompt) { in justify_text()
1068 while (*prompt == '\n' && y < bm) { in justify_text()
1070 ++y; in justify_text()
1072 (void) wmove(win, y, lm); in justify_text()
1077 (void) wmove(win, y, lm); in justify_text()
1085 ++y; in justify_text()
1087 (void) wmove(win, y, lm); in justify_text()
1097 *high = y; in justify_text()
1127 int offset, in dlg_print_scrolled() argument
1140 int wide = width - (2 * MARGIN); in dlg_print_scrolled()
1159 int y, x; in dlg_print_scrolled() local
1165 getyx(dummy, y, x); in dlg_print_scrolled()
1170 offset + MARGIN, /* sminrow */ in dlg_print_scrolled()
1181 if (y > 0 && wide > 4) { in dlg_print_scrolled()
1182 int percent = (int) ((height + offset) * 100.0 / y); in dlg_print_scrolled()
1189 if (offset != 0 || percent != 100) { 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()
1207 (void) offset; in dlg_print_scrolled()
1217 dlg_check_scrolled(int key, int last, int page, bool * show, int *offset) in dlg_check_scrolled() argument
1225 if (*offset > 0) { in dlg_check_scrolled()
1226 *offset = 0; in dlg_check_scrolled()
1231 if (*offset < last) { in dlg_check_scrolled()
1232 *offset = last; in dlg_check_scrolled()
1237 if (*offset > 0) { in dlg_check_scrolled()
1238 --(*offset); in dlg_check_scrolled()
1243 if (*offset < last) { in dlg_check_scrolled()
1244 ++(*offset); in dlg_check_scrolled()
1249 if (*offset > 0) { in dlg_check_scrolled()
1250 *offset -= page; in dlg_check_scrolled()
1251 if (*offset < 0) in dlg_check_scrolled()
1252 *offset = 0; in dlg_check_scrolled()
1257 if (*offset < last) { in dlg_check_scrolled()
1258 *offset += page; in dlg_check_scrolled()
1259 if (*offset > last) in dlg_check_scrolled()
1260 *offset = last; 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()
1351 int y = (dialog_vars.begin_set ? dialog_vars.begin_y : 1); in real_auto_size() local
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()
1491 long offset; in dlg_auto_sizefile() local
1496 offset = 0; in dlg_auto_sizefile()
1499 offset += dialog_state.tab_len - (offset % dialog_state.tab_len); in dlg_auto_sizefile()
1501 offset++; in dlg_auto_sizefile()
1505 if (offset > len) in dlg_auto_sizefile()
1506 len = (int) offset; 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),
1539 dlg_draw_box2(WINDOW *win, int y, int x, int height, int width, in dlg_draw_box2() argument
1547 (void) wmove(win, y + i, x); in dlg_draw_box2()
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()
1572 dlg_draw_box(WINDOW *win, int y, int x, int height, int width, in dlg_draw_box() argument
1575 dlg_draw_box2(win, y, x, height, width, boxchar, borderchar, boxchar); in dlg_draw_box()
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
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.
1635 in_window(WINDOW *win, int y, int x) in in_window() argument
1643 if (y >= y_base && y <= y_last && x >= x_base && x <= x_last) in in_window()
1649 window_at_cell(DIALOG_WINDOWS * dw, int y, int x) in window_at_cell() argument
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
1678 y += getbegy(shadow); in in_shadow()
1681 if (y >= ybase + SHADOW_ROWS in in_shadow()
1682 && y < ylast + SHADOW_ROWS in in_shadow()
1685 /* in the right-side */ in in_shadow()
1687 } else if (y >= ylast in in_shadow()
1688 && y < ylast + SHADOW_ROWS in in_shadow()
1704 last_shadow(DIALOG_WINDOWS * dw, int y, int x) in last_shadow() argument
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()
1720 repaint_cell(DIALOG_WINDOWS * dw, bool draw, int y, int x) in repaint_cell() argument
1722 WINDOW *win = dw->shadow; in repaint_cell()
1726 if ((cellwin = window_at_cell(dw, y, x)) != 0 in repaint_cell()
1727 && (draw || last_shadow(dw, y, x)) 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()
1752 #define RepaintCell(dw, draw, y, x) repaint_cell(dw, draw, y, x) argument
1755 repaint_shadow(DIALOG_WINDOWS * dw, bool draw, int y, int x, int height, int width) in repaint_shadow() argument
1761 chtype save = dlg_get_attrs(dw->shadow); in repaint_shadow()
1762 dlg_attrset(dw->shadow, draw ? shadow_attr : screen_attr); in repaint_shadow()
1766 RepaintCell(dw, draw, i + y + height, j + x + SHADOW_COLS); in repaint_shadow()
1771 RepaintCell(dw, draw, i + y + SHADOW_ROWS, j + x + width); 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()
1820 dlg_draw_shadow(WINDOW *win, int y, int x, int height, int width) in dlg_draw_shadow() argument
1822 repaint_shadow(SearchTopWindows(win), TRUE, y, x, height, width); in dlg_draw_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()
2219 int y; in dlg_box_y_ordinate() local
2222 y = dialog_vars.begin_y; in dlg_box_y_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()
2227 return y; 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()
2329 dlg_new_window(int height, int width, int y, int x) in dlg_new_window() argument
2331 return dlg_new_modal_window(stdscr, height, width, y, x); in dlg_new_window()
2339 dlg_new_modal_window(WINDOW *parent, int height, int width, int y, int x) in dlg_new_modal_window() argument
2346 || (win = newwin(height, width, y, x)) == 0) { in dlg_new_modal_window()
2348 y, x, height, width); in dlg_new_modal_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()
2413 dlg_move_window(WINDOW *win, int height, int width, int y, int x) in dlg_move_window() argument
2422 (void) mvwin(win, y, x); in dlg_move_window()
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()
2476 dlg_der_window(WINDOW *parent, int height, int width, int y, int x) in dlg_der_window() argument
2483 if ((win = derwin(parent, height, width, y, x)) != 0) { in dlg_der_window()
2491 dlg_sub_window(WINDOW *parent, int height, int width, int y, int x) in dlg_sub_window() argument
2495 if ((win = subwin(parent, height, width, y, x)) == 0) { in dlg_sub_window()
2496 dlg_exiterr("Can't make sub-window at (%d,%d), size (%d,%d).\n", in dlg_sub_window()
2497 y, x, height, width); 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()
2560 int y, x; in dlg_item_help() local
2562 getyx(stdscr, y, x); in dlg_item_help()
2563 (void) y; 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.
2967 int y, x; in dlg_getbegx() local
2968 getbegyx(win, y, x); in dlg_getbegx()
2974 int y, x; in dlg_getbegy() local
2975 getbegyx(win, y, x); in dlg_getbegy()
2976 return y; in dlg_getbegy()
2984 int y, x; in dlg_getcurx() local
2985 getyx(win, y, x); in dlg_getcurx()
2991 int y, x; in dlg_getcury() local
2992 getyx(win, y, x); in dlg_getcury()
2993 return y; in dlg_getcury()
3001 int y, x; in dlg_getmaxx() local
3002 getmaxyx(win, y, x); in dlg_getmaxx()
3008 int y, x; in dlg_getmaxy() local
3009 getmaxyx(win, y, x); in dlg_getmaxy()
3010 return y; in dlg_getmaxy()
3018 int y, x; in dlg_getparx() local
3019 getparyx(win, y, x); in dlg_getparx()
3025 int y, x; in dlg_getpary() local
3026 getparyx(win, y, x); in dlg_getpary()
3027 return y; in dlg_getpary()
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()