mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-06-26 12:52:08 +02:00
Add noimages option
This commit is contained in:
parent
456a0eb4da
commit
5b6e333366
@ -268,6 +268,10 @@ Always use
|
|||||||
.I Kitty
|
.I Kitty
|
||||||
terminal's built-in method of previewing images.
|
terminal's built-in method of previewing images.
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
.B noimages
|
||||||
|
Print only text and do not use any image previewing method.
|
||||||
|
.
|
||||||
.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
|
||||||
|
@ -15,6 +15,10 @@ use_kitty() {
|
|||||||
is_kitty
|
is_kitty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noimages() {
|
||||||
|
[ -n "$noimages" ]
|
||||||
|
}
|
||||||
|
|
||||||
fifo_open() {
|
fifo_open() {
|
||||||
# https://unix.stackexchange.com/a/522940/183147
|
# https://unix.stackexchange.com/a/522940/183147
|
||||||
dd oflag=nonblock conv=notrunc,nocreat count=0 of="$1" \
|
dd oflag=nonblock conv=notrunc,nocreat count=0 of="$1" \
|
||||||
@ -39,6 +43,8 @@ check_exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_image() {
|
send_image() {
|
||||||
|
noimages && return 127
|
||||||
|
|
||||||
if use_kitty; then
|
if use_kitty; then
|
||||||
kitty +kitten icat --transfer-mode file --align left \
|
kitty +kitten icat --transfer-mode file --align left \
|
||||||
--place "${w}x${h}@${x}x${y}" "$1"
|
--place "${w}x${h}@${x}x${y}" "$1"
|
||||||
@ -53,6 +59,7 @@ send_image() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
convert_and_show_image() {
|
convert_and_show_image() {
|
||||||
|
noimages && exit 127
|
||||||
setup_fifo
|
setup_fifo
|
||||||
[ -n "$cache_valid" ] || "$@" || exit "$?"
|
[ -n "$cache_valid" ] || "$@" || exit "$?"
|
||||||
send_image "$cache_f"
|
send_image "$cache_f"
|
||||||
|
@ -42,6 +42,7 @@ static VectorPreview *previews;
|
|||||||
|
|
||||||
static struct Option options[] = {
|
static struct Option options[] = {
|
||||||
{ "forcekitty", OPTION_BOOL, { .i = &ctpv.opts.forcekitty } },
|
{ "forcekitty", OPTION_BOOL, { .i = &ctpv.opts.forcekitty } },
|
||||||
|
{ "noimages", OPTION_BOOL, { .i = &ctpv.opts.noimages } },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void any_type_null(char **s)
|
static void any_type_null(char **s)
|
||||||
|
@ -14,7 +14,7 @@ struct CTPV {
|
|||||||
} mode;
|
} mode;
|
||||||
char *server_id_s;
|
char *server_id_s;
|
||||||
struct {
|
struct {
|
||||||
int forcekitty;
|
int forcekitty, noimages;
|
||||||
} opts;
|
} opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ 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);
|
ERRCHK_RET_ERN(setenv("forcekitty", ctpv.opts.forcekitty ? "1" : "", 1) == -1);
|
||||||
|
ERRCHK_RET_ERN(setenv("noimages", ctpv.opts.noimages ? "1" : "", 1) == -1);
|
||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user