/* * Print a new line of text. */ static void print_line(MY_OBJ * obj, int row, int width) { if (wmove(obj->text, row, 0) != ERR) { int i, y, x; char *line = get_line(obj); const int *cols = dlg_index_columns(line); const int *indx = dlg_index_wchars(line); int limit = dlg_count_wchars(line); int first = 0; int last = limit; if (width > getmaxx(obj->text)) width = getmaxx(obj->text); --width; /* for the leading ' ' */ for (i = 0; i <= limit && cols[i] < obj->hscroll; ++i) first = i; for (i = first; (i <= limit) && ((cols[i] - cols[first]) < width); ++i) last = i; (void) waddch(obj->text, ' '); (void) waddnstr(obj->text, line + indx[first], indx[last] - indx[first]); getyx(obj->text, y, x); if (y == row) { /* Clear 'residue' of previous line */ for (i = 0; i <= width - x; i++) { (void) waddch(obj->text, ' '); } } } }
/* * If we have help-line text, e.g., from "--hline", draw it between the other * decorations at the bottom of the dialog window. */ void dlg_draw_helpline(WINDOW *win, bool decorations) { int cur_x, cur_y; int bottom; if (dialog_vars.help_line != 0 && (bottom = getmaxy(win) - 1) > 0) { chtype attr = A_NORMAL; const int *cols = dlg_index_columns(dialog_vars.help_line); int other = decorations ? (ON_LEFT + ON_RIGHT) : 0; int avail = (getmaxx(win) - other - 2); int limit = dlg_count_real_columns(dialog_vars.help_line) + 2; if (limit < avail) { getyx(win, cur_y, cur_x); other = decorations ? ON_LEFT : 0; (void) wmove(win, bottom, other + (avail - limit) / 2); waddch(win, '['); dlg_print_text(win, dialog_vars.help_line, cols[limit], &attr); waddch(win, ']'); wmove(win, cur_y, cur_x); } } }
/* * Print the tag of a menu-item */ static void print_tag(WINDOW *win, char **items, int choice, int selected) { int my_x = item_x; int my_y = ItemToRow(choice); int tag_width = (my_x - tag_x - GUTTER); const int *cols; const int *indx; int limit; unsigned prefix; cols = dlg_index_columns(ItemName(0)); indx = dlg_index_wchars(ItemName(0)); limit = dlg_count_wchars(ItemName(0)); prefix = indx[1] - indx[0]; /* highlight first char of the tag to be special */ (void) wmove(win, my_y, tag_x); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); if (strlen(ItemName(0)) != 0) (void) waddnstr(win, ItemName(0), prefix); /* print rest of the string */ wattrset(win, selected ? tag_selected_attr : tag_attr); if (strlen(ItemName(0)) > prefix) { limit = dlg_limit_columns(ItemName(0), tag_width, 1); if (limit > 0) (void) waddnstr(win, ItemName(0) + indx[1], indx[limit] - indx[1]); } }
/* * Print list item. The 'selected' parameter is true if 'choice' is the * current item. That one is colored differently from the other items. */ static void print_item(WINDOW *win, DIALOG_LISTITEM * item, const char *states, int choice, int selected) { chtype save = dlg_get_attrs(win); int i; chtype attr = A_NORMAL; const int *cols; const int *indx; int limit; /* Clear 'residue' of last item */ wattrset(win, menubox_attr); (void) wmove(win, choice, 0); for (i = 0; i < list_width; i++) (void) waddch(win, ' '); (void) wmove(win, choice, check_x); wattrset(win, selected ? check_selected_attr : check_attr); (void) wprintw(win, (checkflag == FLAG_CHECK) ? "[%c]" : "(%c)", states[item->state]); wattrset(win, menubox_attr); (void) waddch(win, ' '); if (strlen(item->name) != 0) { indx = dlg_index_wchars(item->name); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); (void) waddnstr(win, item->name, indx[1]); if ((int) strlen(item->name) > indx[1]) { limit = dlg_limit_columns(item->name, (item_x - check_x - 6), 1); if (limit > 1) { wattrset(win, selected ? tag_selected_attr : tag_attr); (void) waddnstr(win, item->name + indx[1], indx[limit] - indx[1]); } } } if (strlen(item->text) != 0) { cols = dlg_index_columns(item->text); limit = dlg_limit_columns(item->text, (getmaxx(win) - item_x + 1), 0); if (limit > 0) { (void) wmove(win, choice, item_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, item->text, cols[limit], &attr); } } if (selected) { dlg_item_help(item->help); } wattrset(win, save); }