mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-12-01 00:43:08 +01:00
Add nosymlinkinfo option
This commit is contained in:
parent
61b6edb83b
commit
8e3dbc40d7
@ -282,6 +282,10 @@ for image previews.
|
|||||||
.B noimages
|
.B noimages
|
||||||
Print only text and do not use any image previewing method.
|
Print only text and do not use any image previewing method.
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
.B nosymlinkinfo
|
||||||
|
Do not print resolved path of symbolic links.
|
||||||
|
.
|
||||||
.SS Defining custom previews
|
.SS Defining custom previews
|
||||||
.
|
.
|
||||||
A snippet below defines a new preview with name
|
A snippet below defines a new preview with name
|
||||||
|
12
src/config.c
12
src/config.c
@ -17,6 +17,11 @@
|
|||||||
#define ACCEPT(x) CHECK_OK(accept(x))
|
#define ACCEPT(x) CHECK_OK(accept(x))
|
||||||
#define NOT_ACCEPT(x) CHECK_NULL(accept(x))
|
#define NOT_ACCEPT(x) CHECK_NULL(accept(x))
|
||||||
|
|
||||||
|
#define DEF_OPTION(name, type, val) { (#name), (type), { .val = &ctpv.opts.name } }
|
||||||
|
#define DEF_OPTION_BOOL(name) DEF_OPTION(name, OPTION_BOOL, i)
|
||||||
|
#define DEF_OPTION_INT(name) DEF_OPTION(name, OPTION_INT, i)
|
||||||
|
#define DEF_OPTION_STR(name) DEF_OPTION(name, OPTION_STR, s)
|
||||||
|
|
||||||
struct Option {
|
struct Option {
|
||||||
char *name;
|
char *name;
|
||||||
enum {
|
enum {
|
||||||
@ -41,9 +46,10 @@ static Token token;
|
|||||||
static VectorPreview *previews;
|
static VectorPreview *previews;
|
||||||
|
|
||||||
static struct Option options[] = {
|
static struct Option options[] = {
|
||||||
{ "forcekitty", OPTION_BOOL, { .i = &ctpv.opts.forcekitty } },
|
DEF_OPTION_BOOL(forcekitty),
|
||||||
{ "forcechafa", OPTION_BOOL, { .i = &ctpv.opts.forcechafa } },
|
DEF_OPTION_BOOL(forcechafa),
|
||||||
{ "noimages", OPTION_BOOL, { .i = &ctpv.opts.noimages } },
|
DEF_OPTION_BOOL(noimages),
|
||||||
|
DEF_OPTION_BOOL(nosymlinkinfo),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void any_type_null(char **s)
|
static void any_type_null(char **s)
|
||||||
|
@ -210,10 +210,12 @@ static int preview(int argc, char *argv[])
|
|||||||
GET_PARG(y, 4);
|
GET_PARG(y, 4);
|
||||||
GET_PARG(id, 5);
|
GET_PARG(id, 5);
|
||||||
|
|
||||||
|
ERRCHK_RET_OK(init_previews());
|
||||||
|
|
||||||
struct InputFile input_f;
|
struct InputFile input_f;
|
||||||
ERRCHK_RET_OK(get_input_file(f, &input_f));
|
ERRCHK_RET_OK(get_input_file(f, &input_f));
|
||||||
|
|
||||||
if (*input_f.link) {
|
if (!ctpv.opts.nosymlinkinfo && *input_f.link) {
|
||||||
printf("\033[1;36mSymlink points to:\033[m\n\t%s\n\n", input_f.link);
|
printf("\033[1;36mSymlink points to:\033[m\n\t%s\n\n", input_f.link);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -231,8 +233,6 @@ static int preview(int argc, char *argv[])
|
|||||||
|
|
||||||
ERRCHK_RET_OK(init_magic());
|
ERRCHK_RET_OK(init_magic());
|
||||||
|
|
||||||
ERRCHK_RET_OK(init_previews());
|
|
||||||
|
|
||||||
const char *mimetype;
|
const char *mimetype;
|
||||||
ERRCHK_RET(!(mimetype = get_mimetype(input_f.path)));
|
ERRCHK_RET(!(mimetype = get_mimetype(input_f.path)));
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ struct CTPV {
|
|||||||
} mode;
|
} mode;
|
||||||
char *server_id_s;
|
char *server_id_s;
|
||||||
struct {
|
struct {
|
||||||
int forcekitty, forcechafa, noimages;
|
int forcekitty, forcechafa, noimages, nosymlinkinfo;
|
||||||
} opts;
|
} opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
10
src/shell.c
10
src/shell.c
@ -31,12 +31,16 @@ static char *prepend_helpers(char *str, size_t len)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OPT_SETENV(name) \
|
||||||
|
ERRCHK_RET_ERN(setenv((#name), ctpv.opts.name ? "1" : "", 1) == -1)
|
||||||
|
|
||||||
int run_script(char *script, size_t script_len, int *exitcode, int *signal,
|
int run_script(char *script, size_t script_len, int *exitcode, int *signal,
|
||||||
SpawnProg sp, void *sp_arg)
|
SpawnProg sp, void *sp_arg)
|
||||||
{
|
{
|
||||||
ERRCHK_RET_ERN(setenv("forcekitty", ctpv.opts.forcekitty ? "1" : "", 1) == -1);
|
OPT_SETENV(forcechafa);
|
||||||
ERRCHK_RET_ERN(setenv("forcechafa", ctpv.opts.forcechafa ? "1" : "", 1) == -1);
|
OPT_SETENV(forcekitty);
|
||||||
ERRCHK_RET_ERN(setenv("noimages", ctpv.opts.noimages ? "1" : "", 1) == -1);
|
OPT_SETENV(noimages);
|
||||||
|
OPT_SETENV(nosymlinkinfo);
|
||||||
|
|
||||||
char *scr = prepend_helpers(script, script_len);
|
char *scr = prepend_helpers(script, script_len);
|
||||||
char *args[] = SHELL_ARGS(scr);
|
char *args[] = SHELL_ARGS(scr);
|
||||||
|
Loading…
Reference in New Issue
Block a user