Lines Matching refs:list

90 init_list(LIST * list, WINDOW *par, WINDOW *win, int mousex)
92 list->par = par;
93 list->win = win;
94 list->length = 0;
95 list->offset = 0;
96 list->choice = 0;
97 list->mousex = mousex;
98 list->allocd = 0;
99 list->data = 0;
117 data_of(LIST * list)
119 if (list != 0
120 && list->data != 0)
121 return list->data[list->choice];
126 free_list(LIST * list, int reinit)
130 if (list->data != 0) {
131 for (n = 0; list->data[n] != 0; n++)
132 free(list->data[n]);
133 free(list->data);
134 list->data = 0;
137 init_list(list, list->par, list->win, list->mousex);
141 add_to_list(LIST * list, char *text)
145 need = (unsigned) (list->length + 1);
146 if (need + 1 > list->allocd) {
147 list->allocd = 2 * (need + 1);
148 if (list->data == 0) {
149 list->data = dlg_malloc(char *, list->allocd);
151 list->data = dlg_realloc(char *, list->allocd, list->data);
153 assert_ptr(list->data, "add_to_list");
155 list->data[list->length++] = dlg_strclone(text);
156 list->data[list->length] = 0;
160 keep_visible(LIST * list)
162 int high = getmaxy(list->win);
164 if (list->choice < list->offset) {
165 list->offset = list->choice;
167 if (list->choice - list->offset >= high)
168 list->offset = list->choice - high + 1;
174 find_choice(char *target, LIST * list)
177 int choice = list->choice;
181 list->choice = 0;
189 for (n = 0; n < list->length; n++) {
191 char *b = list->data[n];
206 list->choice = n;
210 if (choice != list->choice) {
211 keep_visible(list);
213 return (choice != list->choice);
217 display_list(LIST * list)
225 if (list->win != 0) {
226 dlg_attr_clear(list->win, getmaxy(list->win), getmaxx(list->win), item_attr);
227 for (n = list->offset; n < list->length && list->data[n]; n++) {
228 y = n - list->offset;
229 if (y >= getmaxy(list->win))
231 (void) wmove(list->win, y, 0);
232 if (n == list->choice)
233 (void) wattrset(list->win, item_selected_attr);
234 (void) waddstr(list->win, list->data[n]);
235 (void) wattrset(list->win, item_attr);
237 (void) wattrset(list->win, item_attr);
239 getparyx(list->win, y, x);
242 bottom = y + getmaxy(list->win);
243 dlg_draw_scrollbar(list->par,
244 (long) list->offset,
245 (long) list->offset,
246 (long) (list->offset + getmaxy(list->win)),
247 (long) (list->length),
249 x + getmaxx(list->win),
255 (void) wmove(list->win, list->choice - list->offset, 0);
256 (void) wnoutrefresh(list->win);
268 fix_arrows(LIST * list)
276 if (list->win != 0) {
277 getparyx(list->win, y, x);
279 right = getmaxx(list->win);
280 bottom = y + getmaxy(list->win);
283 ((list->mousex == MOUSE_D)
287 ((list->mousex == MOUSE_D)
294 show_list(char *target, LIST * list, int keep)
296 int changed = keep || find_choice(target, list);
297 display_list(list);
302 * Highlight the closest match to 'target' in the given list, setting offset
314 * Move up/down in the given list
317 change_list(int choice, LIST * list)
319 if (data_of(list) != 0) {
320 int last = list->length - 1;
322 choice += list->choice;
327 list->choice = choice;
328 keep_visible(list);
329 display_list(list);
336 scroll_list(int direction, LIST * list)
338 if (data_of(list) != 0) {
339 int length = getmaxy(list->win);
340 if (change_list(direction * length, list))