Beispiel #1
0
WERROR multilist_set_window(struct multilist *list, WINDOW *window)
{
	int maxy, maxx;
	bool rerender = false;

	getmaxyx(window, maxy, maxx);

	/* rerender pad if window width is different. */
	if (list->data && maxx != list->window_width) {
		rerender = true;
	}

	list->window = window;
	list->window_width = maxx;
	list->window_height = maxy;
	list->start_row = 0;
	if (rerender) {
		const void *row = multilist_get_current_row(list);
		WERROR rv = multilist_set_data(list, list->data);
		if (W_ERROR_IS_OK(rv) && row) {
			multilist_set_current_row(list, row);
		}
		return rv;
	} else {
		put_header(list);
		fix_start_row(list);
	}

	return WERR_OK;
}
void value_list_set_current_item_by_name(struct value_list *vl,
					 const char *name)
{
	size_t i;

	for (i = 0; i < vl->nvalues; ++i) {
		if (strequal(vl->values[i].value_name, name)) {
			multilist_set_current_row(vl->list, &vl->values[i]);
			return;
		}
	}
}
void value_list_set_current_item(struct value_list *vl,
				 const struct value_item *item)
{
	multilist_set_current_row(vl->list, item);
}