Пример #1
0
/* Clones one view into another.  Path specifies location of active pane and can
 * be NULL.  The destination view is assumed to not own any resources. */
static void
clone_view(view_t *dst, view_t *src, const char path[])
{
	strcpy(dst->curr_dir, path == NULL ? flist_get_dir(src) : path);
	dst->timestamps_mutex = src->timestamps_mutex;
	dst->win = src->win;
	dst->title = src->title;

	flist_init_view(dst);
	dst->dir_entry[0].origin = src->curr_dir;

	clone_local_options(src, dst, 1);
	matcher_free(dst->manual_filter);
	dst->manual_filter = matcher_clone(src->manual_filter);
	filter_assign(&dst->auto_filter, &src->auto_filter);
	dst->prev_invert = src->prev_invert;
	dst->invert = src->invert;

	/* Clone current entry even though we populate file list later to give
	 * reloading reference point for cursor. */
	replace_dir_entries(dst, &dst->dir_entry, &dst->list_rows,
			get_current_entry(src), 1);
	dst->list_pos = 0;
	/* Clone viewport configuration. */
	dst->curr_line = src->curr_line;
	dst->top_line = src->top_line;
	dst->window_rows = src->window_rows;
	dst->window_cols = src->window_cols;
	dst->window_cells = src->window_cells;

	flist_hist_resize(dst, cfg.history_len);
	flist_hist_clone(dst, src);
	if(path != NULL && !flist_custom_active(src))
	{
		/* Record location we're leaving. */
		flist_hist_save(dst, src->curr_dir, get_current_file_name(src),
				src->list_pos - src->top_line);
	}

	(void)populate_dir_list(dst, path == NULL);
	/* XXX: do we need to update origins or is this a leftover from before list
	 *      population was introduced? */
	flist_update_origins(dst, &dst->curr_dir[0], &src->curr_dir[0]);

	/* Record new location. */
	flist_hist_save(dst, NULL, NULL, -1);
}
Пример #2
0
/* Loads full list of files into unfiltered list of the view.  Returns position
 * of file under cursor in the unfiltered list. */
static int
load_unfiltered_list(view_t *view)
{
	int current_file_pos = view->list_pos;

	view->local_filter.in_progress = 1;

	view->local_filter.saved = strdup(view->local_filter.filter.raw);

	if(list_is_incomplete(view))
	{
		char full_path[PATH_MAX + 1];
		dir_entry_t *entry;

		get_current_full_path(view, sizeof(full_path), full_path);

		filter_clear(&view->local_filter.filter);
		(void)populate_dir_list(view, 1);

		/* Resolve current file position in updated list. */
		entry = entry_from_path(view, view->dir_entry, view->list_rows, full_path);
		if(entry != NULL)
		{
			current_file_pos = entry_to_pos(view, entry);
		}

		if(current_file_pos >= view->list_rows)
		{
			current_file_pos = view->list_rows - 1;
		}
	}
	else
	{
		/* Save unfiltered (by local filter) list for further use. */
		replace_dir_entries(view, &view->local_filter.entries,
				&view->local_filter.entry_count, view->dir_entry, view->list_rows);
	}

	view->local_filter.unfiltered = view->dir_entry;
	view->local_filter.unfiltered_count = view->list_rows;
	view->local_filter.prefiltered_count = view->filtered;
	view->dir_entry = NULL;

	return current_file_pos;
}
Пример #3
0
void
local_filter_apply(view_t *view, const char filter[])
{
	if(view->local_filter.in_progress)
	{
		assert(!view->local_filter.in_progress && "Wrong local filter applying.");
		return;
	}

	(void)filter_set(&view->local_filter.filter, filter);
	hists_filter_save(view->local_filter.filter.raw);

	if(flist_custom_active(view) && view->custom.type != CV_TREE &&
			view->local_filter.entry_count == 0)
	{
		/* Save unfiltered (by local filter) list for further use so it can be
		 * restored on changing local filter. */
		replace_dir_entries(view, &view->local_filter.entries,
				&view->local_filter.entry_count, view->dir_entry, view->list_rows);
	}

	ui_view_schedule_reload(view);
}
Пример #4
0
/* Clones one view into another.  The destination view is assumed to not own any
 * resources. */
static void
clone_view(view_t *dst, view_t *src)
{
	strcpy(dst->curr_dir, flist_get_dir(src));
	dst->timestamps_mutex = src->timestamps_mutex;
	dst->win = src->win;
	dst->title = src->title;

	flist_init_view(dst);
	dst->dir_entry[0].origin = src->curr_dir;

	clone_local_options(src, dst, 1);
	matcher_free(dst->manual_filter);
	dst->manual_filter = matcher_clone(src->manual_filter);
	filter_assign(&dst->auto_filter, &src->auto_filter);
	dst->prev_invert = src->prev_invert;
	dst->invert = src->invert;

	/* Clone current entry even though we populate file list later to give
	 * reloading reference point for cursor. */
	replace_dir_entries(dst, &dst->dir_entry, &dst->list_rows,
			get_current_entry(src), 1);
	dst->list_pos = 0;
	/* Clone viewport configuration. */
	dst->curr_line = src->curr_line;
	dst->top_line = src->top_line;
	dst->window_rows = src->window_rows;
	dst->window_cols = src->window_cols;
	dst->window_cells = src->window_cells;

	flist_hist_resize(dst, cfg.history_len);
	flist_hist_clone(dst, src);

	(void)populate_dir_list(dst, 1);
	flist_update_origins(dst, &dst->curr_dir[0], &src->curr_dir[0]);
}