/* * 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, ' '); } } } }
/* * 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 */ static void print_item(WINDOW *win, char **items, int status, int choice, int selected) { int i; chtype attr = A_NORMAL; 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)", status ? 'X' : ' '); wattrset(win, menubox_attr); (void) waddch(win, ' '); if (strlen(ItemName(0)) != 0) { indx = dlg_index_wchars(ItemName(0)); limit = dlg_count_wchars(ItemName(0)); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); (void) waddnstr(win, ItemName(0), indx[1]); if ((int) strlen(ItemName(0)) > indx[1]) { limit = dlg_limit_columns(ItemName(0), (item_x - check_x - 6), 1); if (limit > 1) { wattrset(win, selected ? tag_selected_attr : tag_attr); (void) waddnstr(win, ItemName(0) + indx[1], indx[limit] - indx[1]); } } } if (strlen(ItemText(0)) != 0) { indx = dlg_index_wchars(ItemText(0)); limit = dlg_limit_columns(ItemText(0), (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, ItemText(0), indx[limit], &attr); } } if (selected) { dlg_item_help(ItemHelp(0)); } }
/* * Print a button */ static void print_button(WINDOW *win, char *label, int y, int x, int selected) { int i; int state = 0; const int *indx = dlg_index_wchars(label); int limit = dlg_count_wchars(label); chtype key_attr = (selected ? button_key_active_attr : button_key_inactive_attr); chtype label_attr = (selected ? button_label_active_attr : button_label_inactive_attr); (void) wmove(win, y, x); wattrset(win, selected ? button_active_attr : button_inactive_attr); (void) waddstr(win, "<"); wattrset(win, label_attr); for (i = 0; i < limit; ++i) { int first = indx[i]; int last = indx[i + 1]; switch (state) { case 0: #ifdef USE_WIDE_CURSES if ((last - first) != 1) { const char *temp = (label + first); int cmp = string_to_char(&temp); if (dlg_isupper(cmp)) { wattrset(win, key_attr); state = 1; } break; } #endif if (dlg_isupper(UCH(label[first]))) { wattrset(win, key_attr); state = 1; } break; case 1: wattrset(win, label_attr); state = 2; break; } waddnstr(win, label + first, last - first); } wattrset(win, selected ? button_active_attr : button_inactive_attr); (void) waddstr(win, ">"); (void) wmove(win, y, x + ((int) strspn(label, " ")) + 1); }