示例#1
0
文件: running.c 项目: cfillion/vifm
/* Executes current file of the view by program specification that does not
 * include any macros (hence file name is appended implicitly. */
static void
run_implicit_prog(FileView *view, const char prog_spec[], int pause,
		int force_bg)
{
	int bg;
	char cmd[NAME_MAX + 1 + NAME_MAX + 1];
	const char *name_macro;
	char *file_name;
	char spec[strlen(prog_spec) + 1];

	strcpy(spec, prog_spec);
	bg = cut_suffix(spec, " &") || force_bg;

	if(curr_stats.shell_type == ST_CMD)
	{
		name_macro = (view == curr_view) ? "%\"c" : "%\"C";
	}
	else
	{
		name_macro = (view == curr_view) ? "%c" : "%C";
	}

	file_name = expand_macros(name_macro, NULL, NULL, 1);
	snprintf(cmd, sizeof(cmd), "%s %s", spec, file_name);
	free(file_name);

	if(bg)
	{
		(void)start_background_job(cmd, 0);
	}
	else
	{
		(void)shellout(cmd, pause ? PAUSE_ALWAYS : PAUSE_ON_ERROR, 1);
	}
}
示例#2
0
文件: running.c 项目: cfillion/vifm
/* Executes current file of the current view by program specification that
 * includes at least one macro. */
static void
run_explicit_prog(const char prog_spec[], int pause, int force_bg)
{
	int bg;
	MacroFlags flags;
	int save_msg;
	char *const cmd = expand_macros(prog_spec, NULL, &flags, 1);

	bg = cut_suffix(cmd, " &");
	bg = !pause && (bg || force_bg);

	save_msg = 0;
	if(run_ext_command(cmd, flags, bg, &save_msg) != 0)
	{
		if(save_msg)
		{
			curr_stats.save_msg = 1;
		}
	}
	else if(bg)
	{
		assert(flags != MF_IGNORE && "This case is for run_ext_command()");
		(void)start_background_job(cmd, flags == MF_IGNORE);
	}
	else
	{
		(void)shellout(cmd, pause ? PAUSE_ALWAYS : PAUSE_ON_ERROR,
				flags != MF_NO_TERM_MUX);
	}

	free(cmd);
}
示例#3
0
/* Fill the buffer of specified size with path to color scheme, which might not
 * exist. */
static void
get_cs_path(const char name[], char buf[], size_t buf_size)
{
	snprintf(buf, buf_size, "%s/%s.vifm", cfg.colors_dir, name);
	if(is_regular_file(buf))
	{
		return;
	}

	(void)cut_suffix(buf, ".vifm");
	if(is_regular_file(buf))
	{
		return;
	}

	snprintf(buf, buf_size, GLOBAL_COLORS_DIR "/%s.vifm", name);
	if(is_regular_file(buf))
	{
		return;
	}

	(void)cut_suffix(buf, ".vifm");
}
示例#4
0
static void
draw_1_browse(int x, int y, struct name_list *el)
{
    char rname[16];

    cblock(vf.p,x-2-4,y,71+8,49,sblack);
    bro_frame(x,y,swhite);
    if (el != NULL)
    {
        strcpy(rname, el->name);
        if (rname[0] != '\\' && rname[0] != 0)
        {
            postage_stamp(x+1,y+1,el->name);
            cut_suffix(rname, ".FLI");
        }
        gtext(rname, x + (65 - CH_WIDTH*strlen(rname))/2, y+42, swhite);
    }
}