예제 #1
0
파일: running.c 프로젝트: cfillion/vifm
int
shellout(const char command[], ShellPause pause, int use_term_multiplexer)
{
	char *cmd;
	int result;
	int ec;

	if(pause == PAUSE_ALWAYS && command != NULL && ends_with(command, "&"))
	{
		pause = PAUSE_ON_ERROR;
	}

	setup_shellout_env();

	cmd = gen_shell_cmd(command, pause == PAUSE_ALWAYS, use_term_multiplexer);

	if(curr_stats.load_stage != 0)
	{
		endwin();
	}
	ec = vifm_system(cmd);
	/* No WIFEXITED(ec) check here, since vifm_system(...) shouldn't return until
	 * subprocess exited. */
	result = WEXITSTATUS(ec);

	cleanup_shellout_env();

	if(result != 0 && pause == PAUSE_ON_ERROR)
	{
		LOG_ERROR_MSG("Subprocess (%s) exit code: %d (0x%x); status = 0x%x", cmd,
				result, result, ec);
		pause_shell();
	}

	free(cmd);

	/* Force views update. */
	ui_view_schedule_reload(&lwin);
	ui_view_schedule_reload(&rwin);

	recover_after_shellout();

	if(!curr_stats.skip_shellout_redraw)
	{
		/* Redraw to handle resizing of terminal that we could have missed. */
		curr_stats.need_update = UT_FULL;
	}

	if(curr_stats.load_stage != 0)
	{
		curs_set(FALSE);
	}

	return result;
}
예제 #2
0
파일: filtering.c 프로젝트: vifm/vifm
void
local_filter_remove(view_t *view)
{
	(void)replace_string(&view->local_filter.prev, view->local_filter.filter.raw);
	filter_clear(&view->local_filter.filter);
	ui_view_schedule_reload(view);
}
예제 #3
0
/* leaves properties change dialog */
static void
leave_attr_mode(void)
{
	vle_mode_set(NORMAL_MODE, VMT_PRIMARY);
	curr_stats.use_input_bar = 1;

	flist_sel_stash(view);
	ui_view_schedule_reload(view);
}
예제 #4
0
파일: filtering.c 프로젝트: vifm/vifm
void
dot_filter_set(view_t *view, int visible)
{
	view->hide_dot_g = view->hide_dot = !visible;
	ui_view_schedule_reload(view);
	if(view == curr_view)
	{
		load_dot_filter_option(view);
	}
	if(curr_stats.global_local_settings)
	{
		view_t *other = (view == curr_view) ? other_view : curr_view;
		other->hide_dot_g = other->hide_dot = !visible;
		ui_view_schedule_reload(other);
		if(other == curr_view)
		{
			load_dot_filter_option(other);
		}
	}
}
예제 #5
0
파일: filtering.c 프로젝트: vifm/vifm
void
name_filters_restore(view_t *view)
{
	if(view->prev_manual_filter[0] == '\0' && view->prev_auto_filter[0] == '\0')
	{
		return;
	}

	replace_matcher(&view->manual_filter, view->prev_manual_filter);

	(void)filter_set(&view->auto_filter, view->prev_auto_filter);
	view->invert = view->prev_invert;
	ui_view_schedule_reload(view);
}
예제 #6
0
파일: filtering.c 프로젝트: vifm/vifm
void
name_filters_remove(view_t *view)
{
	if(name_filters_empty(view))
	{
		return;
	}

	(void)replace_string(&view->prev_manual_filter,
			matcher_get_expr(view->manual_filter));
	(void)replace_string(&view->prev_auto_filter, view->auto_filter.raw);
	view->prev_invert = view->invert;

	name_filters_drop(view);
	view->invert = cfg.filter_inverted_by_default ? 1 : 0;

	ui_view_schedule_reload(view);
}
예제 #7
0
파일: filtering.c 프로젝트: vifm/vifm
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);
}
예제 #8
0
int
compare_move(FileView *from, FileView *to)
{
	char from_path[PATH_MAX], to_path[PATH_MAX];
	char *from_fingerprint, *to_fingerprint;

	const CompareType ct = from->custom.diff_cmp_type;

	dir_entry_t *const curr = &from->dir_entry[from->list_pos];
	dir_entry_t *const other = &to->dir_entry[from->list_pos];

	if(from->custom.type != CV_DIFF || !from->custom.diff_path_group)
	{
		status_bar_error("Not in diff mode with path grouping");
		return 1;
	}

	if(curr->id == other->id && !fentry_is_fake(curr) && !fentry_is_fake(other))
	{
		/* Nothing to do if files are already equal. */
		return 0;
	}

	/* We're going at least to try to update one of views (which might refer to
	 * the same directory), so schedule a reload. */
	ui_view_schedule_reload(from);
	ui_view_schedule_reload(to);

	if(fentry_is_fake(curr))
	{
		/* Just remove the other file (it can't be fake entry too). */
		return fops_delete_current(to, 1, 0);
	}

	get_full_path_of(curr, sizeof(from_path), from_path);
	get_full_path_of(other, sizeof(to_path), to_path);

	if(fentry_is_fake(other))
	{
		char to_path[PATH_MAX];
		char canonical[PATH_MAX];
		snprintf(to_path, sizeof(to_path), "%s/%s/%s", flist_get_dir(to),
				curr->origin + strlen(flist_get_dir(from)), curr->name);
		canonicalize_path(to_path, canonical, sizeof(canonical));

		/* Copy current file to position of the other one using relative path with
		 * different base. */
		fops_replace(from, canonical, 0);

		/* Update the other entry to not be fake. */
		remove_last_path_component(canonical);
		replace_string(&other->name, curr->name);
		replace_string(&other->origin, canonical);
	}
	else
	{
		/* Overwrite file in the other pane with corresponding file from current
		 * pane. */
		fops_replace(from, to_path, 1);
	}

	/* Obtaining file fingerprint relies on size field of entries, so try to load
	 * it and ignore if it fails. */
	other->size = get_file_size(to_path);

	/* Try to update id of the other entry by computing fingerprint of both files
	 * and checking if they match. */

	from_fingerprint = get_file_fingerprint(from_path, curr, ct);
	to_fingerprint = get_file_fingerprint(to_path, other, ct);

	if(!is_null_or_empty(from_fingerprint) && !is_null_or_empty(to_fingerprint))
	{
		int match = (strcmp(from_fingerprint, to_fingerprint) == 0);
		if(match && ct == CT_CONTENTS)
		{
			match = files_are_identical(from_path, to_path);
		}
		if(match)
		{
			other->id = curr->id;
		}
	}

	free(from_fingerprint);
	free(to_fingerprint);

	return 0;
}