mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-28 07:23:07 +01:00
Add noimages option
This commit is contained in:
parent
456a0eb4da
commit
5b6e333366
@ -268,6 +268,10 @@ Always use
|
||||
.I Kitty
|
||||
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
|
||||
.
|
||||
A snippet below defines a new preview with name
|
||||
|
@ -15,6 +15,10 @@ use_kitty() {
|
||||
is_kitty
|
||||
}
|
||||
|
||||
noimages() {
|
||||
[ -n "$noimages" ]
|
||||
}
|
||||
|
||||
fifo_open() {
|
||||
# https://unix.stackexchange.com/a/522940/183147
|
||||
dd oflag=nonblock conv=notrunc,nocreat count=0 of="$1" \
|
||||
@ -39,6 +43,8 @@ check_exists() {
|
||||
}
|
||||
|
||||
send_image() {
|
||||
noimages && return 127
|
||||
|
||||
if use_kitty; then
|
||||
kitty +kitten icat --transfer-mode file --align left \
|
||||
--place "${w}x${h}@${x}x${y}" "$1"
|
||||
@ -53,6 +59,7 @@ send_image() {
|
||||
}
|
||||
|
||||
convert_and_show_image() {
|
||||
noimages && exit 127
|
||||
setup_fifo
|
||||
[ -n "$cache_valid" ] || "$@" || exit "$?"
|
||||
send_image "$cache_f"
|
||||
|
@ -42,6 +42,7 @@ static VectorPreview *previews;
|
||||
|
||||
static struct Option options[] = {
|
||||
{ "forcekitty", OPTION_BOOL, { .i = &ctpv.opts.forcekitty } },
|
||||
{ "noimages", OPTION_BOOL, { .i = &ctpv.opts.noimages } },
|
||||
};
|
||||
|
||||
static void any_type_null(char **s)
|
||||
|
@ -14,7 +14,7 @@ struct CTPV {
|
||||
} mode;
|
||||
char *server_id_s;
|
||||
struct {
|
||||
int forcekitty;
|
||||
int forcekitty, noimages;
|
||||
} opts;
|
||||
};
|
||||
|
||||
|
@ -35,6 +35,7 @@ int run_script(char *script, size_t script_len, int *exitcode, int *signal,
|
||||
SpawnProg sp, void *sp_arg)
|
||||
{
|
||||
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 *args[] = SHELL_ARGS(scr);
|
||||
|
Loading…
Reference in New Issue
Block a user