Esempio n. 1
0
static void free_matches(struct search_context *context)
{
	struct list_entry *a;
	struct list_entry *b;
	
	a = context->found->next;

	/* empty the list before clearing and deleting the
	 * selections because the the clearing updates the
	 * screen immediately, causing nested accesses to the list */

	context->found->prev = NULL;
	context->found->next = NULL;

	for (; a; a = b) {
		b = a->next;
		if (a->sel) {
			selection_clear(a->sel, true);
			selection_destroy(a->sel);
		}
		free(a);
	}
}
Esempio n. 2
0
/* Exported function documented in search.h */
void search_show_all(bool all, struct search_context *context)
{
	struct list_entry *a;

	for (a = context->found->next; a; a = a->next) {
		bool add = true;
		if (!all && a != context->current) {
			add = false;
			if (a->sel) {
				selection_clear(a->sel, true);
				selection_destroy(a->sel);
				a->sel = NULL;
			}
		}
		if (add && !a->sel) {

			if (context->is_html == true) {
				html_content *html = (html_content *)context->c;
				a->sel = selection_create(context->c, true);
				if (!a->sel)
					continue;

				selection_init(a->sel, html->layout,
						&html->len_ctx);
			} else {
				a->sel = selection_create(context->c, false);
				if (!a->sel)
					continue;

				selection_init(a->sel, NULL, NULL);
			}

			selection_set_start(a->sel, a->start_idx);
			selection_set_end(a->sel, a->end_idx);
		}
	}
}