Lines Matching +full:no +full:- +full:dump +full:- +full:oops
4 * buildlist.c -- implements the buildlist dialog
6 * Copyright 2012-2019,2020 Thomas E. Dickey
31 #define sLEFT (-2)
32 #define sRIGHT (-1)
54 #define okIndex(all,index) ((index) >= 0 && (index) < (all)->item_no)
56 #define myItem(p,n) ((p)->ip)[n]
72 * Translate a choice from items[] to a row-number in an unbounded column,
78 MY_DATA *data = all->list + selected; in index2row()
79 int result = -1; in index2row()
84 for (row = 0; row < all->item_no; ++row) { in index2row()
86 choice, all->items + choice, in index2row()
88 if (myItem(data, row) == all->items + choice) { in index2row()
99 * Convert a row-number back to an item number, i.e., index into items[].
104 MY_DATA *data = all->list + selected; in row2index()
105 int result = -1; in row2index()
107 for (n = 0; n < all->item_no; ++n) { in row2index()
110 n, all->items + n)); in row2index()
111 if (myItem(data, row) == all->items + n) { in row2index()
135 int climit = (all->item_x - all->check_x - 1); in print_item()
137 ? item->name in print_item()
138 : item->text); in print_item()
146 (void) wmove(win, row, all->check_x); in print_item()
150 dlg_print_listitem(win, item->name, climit, first, selected); in print_item()
155 (void) wmove(win, row, all->item_x); in print_item()
156 climit = (getmaxx(win) - all->item_x + 1); in print_item()
160 dlg_item_help(item->help); in print_item()
173 MY_DATA *data = all->list + selected; in print_1_list()
175 ? all->items + choice in print_1_list()
177 WINDOW *win = data->win; in print_1_list()
180 int top_row = index2row(all, data->top_index, selected); in print_1_list()
207 * Return the previous item from the list, staying in the same column. If no
216 row--; in prev_item()
249 * Return the next item from the list, staying in the same column. If no
255 MY_DATA *data = all->list + selected; in next_item()
258 TRACE(("! given item %d, testing next-item on row %d\n", choice, row + 1)); in next_item()
262 TRACE(("! next_item(%d, %s) ->%d\n", choice, mySide(selected), result)); in next_item()
272 MY_DATA *data = all->list + selected; in first_item()
273 int result = -1; in first_item()
278 for (n = 0; n < all->item_no; ++n) { in first_item()
279 if (myItem(data, 0) == &all->items[n]) { in first_item()
295 MY_DATA *data = all->list + selected; in last_item()
296 int result = -1; in last_item()
312 MY_DATA *data = all->list + selected; in skip_rows()
318 for (n = row + 1; (n < all->item_no) && (n <= row + skip); ++n) { in skip_rows()
324 result -= skip; in skip_rows()
344 for (n = choice; n >= 0; --n) { in closest_item()
345 if ((all->items[n].state != 0) == selected) { in closest_item()
350 for (n = choice; n < all->item_no; ++n) { in closest_item()
351 if ((all->items[n].state != 0) == selected) { in closest_item()
359 if ((choice - prev) > (next - choice)) { in closest_item()
377 WINDOW *dialog = wgetparent(all->list[0].win); in print_both()
382 MY_DATA *data = all->list + selected; in print_both()
383 WINDOW *win = data->win; in print_both()
384 int thumb_top = index2row(all, data->top_index, selected); in print_both()
385 int thumb_max = index2row(all, -1, selected); in print_both()
392 (long) (data->top_index), in print_both()
396 data->box_x + all->check_x, in print_both()
397 data->box_x + getmaxx(win), in print_both()
398 data->box_y, in print_both()
399 data->box_y + getmaxy(win) + 1, in print_both()
410 if (choice != all->list[selected].top_index) { in set_top_item()
414 all->list[selected].top_index = choice; in set_top_item()
419 * Adjust the top-index as needed to ensure that it and the given item are
425 int top_item = all->list[selected].top_index; in fix_top_item()
431 } else if ((cur_row - top_row) >= all->use_height) { in fix_top_item()
432 top_item = row2index(all, cur_row + 1 - all->use_height, selected); in fix_top_item()
434 if (cur_row < all->use_height) { in fix_top_item()
437 DLG_TRACE(("# fix_top_item(cur_item %d, %s) ->top_item %d\n", in fix_top_item()
445 MY_DATA *data = &all->list[1]; in append_right_side()
447 for (j = 0; j < all->item_no; ++j) { in append_right_side()
449 myItem(data, j) = &all->items[choice]; in append_right_side()
458 MY_DATA *data = &all->list[1]; in amend_right_side()
460 for (j = 0; j < all->item_no; ++j) { in amend_right_side()
461 if (myItem(data, j) == &all->items[choice]) { in amend_right_side()
462 for (k = j; k < all->item_no; ++k) { in amend_right_side()
475 MY_DATA *data = all->list + selected; in fill_one_side()
477 for (i = j = 0; j < all->item_no; ++j) { in fill_one_side()
479 if ((all->items[j].state != 0) == selected) { in fill_one_side()
480 myItem(data, i) = all->items + j; in fill_one_side()
484 j, all->items + j)); in fill_one_side()
519 /* *INDENT-OFF* */ in dlg_buildlist()
533 DLG_KEYS_DATA( DLGK_ITEM_PREV, '-' ), in dlg_buildlist()
547 /* *INDENT-ON* */ in dlg_buildlist()
572 * Unlike other uses of --visit-items, we have two windows to visit. in dlg_buildlist()
644 list_width = (width - 6 * MARGIN - 2) / 2; in dlg_buildlist()
653 * Limit the list to avoid overwriting the ok-button. in dlg_buildlist()
655 all.use_height = height - MIN_HIGH - cur_y; in dlg_buildlist()
681 * one or both of them. If the name is no wider than 1/4 of the list, in dlg_buildlist()
684 all.use_width = (list_width - 6 * MARGIN); in dlg_buildlist()
700 text_width = all.use_width - name_width; in dlg_buildlist()
705 all.check_x = (all.use_width - full_width) / 2; in dlg_buildlist()
717 int top_item = cur_item - j + 1; in dlg_buildlist()
738 dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); in dlg_buildlist()
743 int at_top = index2row(&all, moi->top_index, which); in dlg_buildlist()
744 int at_end = index2row(&all, -1, which); in dlg_buildlist()
749 cur_item, item_no - 1, in dlg_buildlist()
750 moi->top_index, in dlg_buildlist()
760 if (button < 0) { /* --visit-items */ in dlg_buildlist()
766 cur_y -= at_top; in dlg_buildlist()
781 key -= M_EVENT; in dlg_buildlist()
786 i = (key - 2 * KEY_MAX) % (1 + all.use_height); in dlg_buildlist()
787 j = (key - 2 * KEY_MAX) / (1 + all.use_height); in dlg_buildlist()
789 DLG_TRACE(("# MOUSE column %d, row %d ->item %d\n", j, i, k)); in dlg_buildlist()
799 at_top = index2row(&all, moi->top_index, which); in dlg_buildlist()
812 key = KEY_RIGHTCOL; /* switch to right-column */ in dlg_buildlist()
815 key -= KEY_MAX; in dlg_buildlist()
819 key = KEY_LEFTCOL; /* switch to left-column */ in dlg_buildlist()
828 * the next available item in the same column. But if there are no in dlg_buildlist()
839 /* FIXME - how to test and handle multiple states? */ in dlg_buildlist()
854 if (cur_item == moi->top_index) { in dlg_buildlist()
901 * A single digit (1-9) positions the selection to that line in the in dlg_buildlist()
907 && (key - '1' < at_bot)) { in dlg_buildlist()
909 i = key - '1'; in dlg_buildlist()
920 dlg_draw_buttons(dialog, height - 2, 0, buttons, button, in dlg_buildlist()
935 dlg_draw_buttons(dialog, height - 2, 0, buttons, button, in dlg_buildlist()
964 if (cur_item > moi->top_index) { in dlg_buildlist()
965 i = moi->top_index; in dlg_buildlist()
966 } else if (moi->top_index != 0) { in dlg_buildlist()
968 if ((temp -= all.use_height) < 0) in dlg_buildlist()
974 if ((at_end - at_bot) < all.use_height) { in dlg_buildlist()
1015 int oops = item_no; in dlg_buildlist() local
1018 DLG_TRACE(("# <--CHOICE %d\n", i)); in dlg_buildlist()
1019 DLG_TRACE(("# <--topITM %d\n", moi->top_index)); in dlg_buildlist()
1020 DLG_TRACE(("# <--now_at %d\n", now_at)); in dlg_buildlist()
1021 DLG_TRACE(("# <--at_top %d\n", at_top)); in dlg_buildlist()
1022 DLG_TRACE(("# <--at_bot %d\n", at_bot)); in dlg_buildlist()
1026 if ((at_bot - at_top) >= all.use_height) { in dlg_buildlist()
1028 next_item(&all, moi->top_index, which), in dlg_buildlist()
1031 at_top = index2row(&all, moi->top_index, which); in dlg_buildlist()
1036 DLG_TRACE(("# ...topITM %d\n", moi->top_index)); in dlg_buildlist()
1038 at_bot - at_top)); in dlg_buildlist()
1042 * If we bumped into the end, move the top-item in dlg_buildlist()
1046 if ((at_bot - at_top) > all.use_height) { in dlg_buildlist()
1048 next_item(&all, moi->top_index, which), in dlg_buildlist()
1051 (at_bot - at_top) >= all.use_height) { in dlg_buildlist()
1053 next_item(&all, moi->top_index, which), in dlg_buildlist()
1058 if (--oops < 0) { in dlg_buildlist()
1059 DLG_TRACE(("# OOPS-forward\n")); in dlg_buildlist()
1065 old_item = moi->top_index; in dlg_buildlist()
1067 prev_item(&all, moi->top_index, which), in dlg_buildlist()
1069 at_top = index2row(&all, moi->top_index, which); in dlg_buildlist()
1072 DLG_TRACE(("# ...topITM %d\n", moi->top_index)); in dlg_buildlist()
1074 if (moi->top_index >= old_item) in dlg_buildlist()
1078 if (--oops < 0) { in dlg_buildlist()
1079 DLG_TRACE(("# OOPS-backward\n")); in dlg_buildlist()
1084 DLG_TRACE(("# -->now_at %d\n", now_at)); in dlg_buildlist()
1127 * If told to re-order the list, update it to reflect the current display: in dlg_buildlist()
1128 * a) The left-side will be at the beginning, without gaps. in dlg_buildlist()
1129 * b) The right-side will follow, in display-order. in dlg_buildlist()
1201 /* FIXME dump the items[][] too */ in dialog_buildlist()