mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-24 13:53:07 +01:00
Decrease width by 2
lf doesn't show last 2 characters in a line
This commit is contained in:
parent
899870af44
commit
462f75761a
30
src/ctpv.c
30
src/ctpv.c
@ -205,7 +205,8 @@ static RESULT check_cache(int *resp, char *file, char *cache_file)
|
|||||||
static RESULT preview(int argc, char *argv[])
|
static RESULT preview(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *f, *w, *h, *x, *y, *id;
|
char *f, *w, *h, *x, *y, *id;
|
||||||
char y_buf[4], h_buf[4];
|
char w_buf[24], h_buf[24], y_buf[24];
|
||||||
|
long w_l, h_l, y_l;
|
||||||
|
|
||||||
GET_PARG(f, 0);
|
GET_PARG(f, 0);
|
||||||
GET_PARG(w, 1);
|
GET_PARG(w, 1);
|
||||||
@ -223,6 +224,10 @@ static RESULT preview(int argc, char *argv[])
|
|||||||
if (!y)
|
if (!y)
|
||||||
y = "0";
|
y = "0";
|
||||||
|
|
||||||
|
ERRCHK_RET_OK(strtol_w(&w_l, w, NULL, 10));
|
||||||
|
ERRCHK_RET_OK(strtol_w(&h_l, h, NULL, 10));
|
||||||
|
ERRCHK_RET_OK(strtol_w(&y_l, y, NULL, 10));
|
||||||
|
|
||||||
ERRCHK_RET_OK(init_previews());
|
ERRCHK_RET_OK(init_previews());
|
||||||
|
|
||||||
struct InputFile input_f;
|
struct InputFile input_f;
|
||||||
@ -232,18 +237,21 @@ static RESULT preview(int argc, char *argv[])
|
|||||||
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);
|
||||||
|
|
||||||
if (y && h) {
|
y_l += 3;
|
||||||
unsigned char y_i = atoi(y);
|
h_l -= 3;
|
||||||
unsigned char h_i = atoi(h);
|
|
||||||
y_i += 3;
|
|
||||||
h_i -= 3;
|
|
||||||
snprintf(y_buf, LEN(y_buf), "%d", y_i);
|
|
||||||
snprintf(h_buf, LEN(h_buf), "%d", h_i);
|
|
||||||
y = y_buf;
|
|
||||||
h = h_buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To some reason lf chops off last 2 characters of a line */
|
||||||
|
w_l -= 2;
|
||||||
|
|
||||||
|
snprintf(w_buf, LEN(w_buf), "%ld", w_l);
|
||||||
|
snprintf(h_buf, LEN(h_buf), "%ld", h_l);
|
||||||
|
snprintf(y_buf, LEN(y_buf), "%ld", y_l);
|
||||||
|
|
||||||
|
w = w_buf;
|
||||||
|
h = h_buf;
|
||||||
|
y = y_buf;
|
||||||
|
|
||||||
ERRCHK_RET_OK(init_magic());
|
ERRCHK_RET_OK(init_magic());
|
||||||
|
|
||||||
const char *mimetype;
|
const char *mimetype;
|
||||||
|
23
src/utils.c
23
src/utils.c
@ -165,3 +165,26 @@ RESULT register_signal(int sig, SigHandler handler)
|
|||||||
ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
|
ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RESULT strtol_w(long *res, char *s, char **endptr, int base)
|
||||||
|
{
|
||||||
|
char *endptr_int;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
*res = strtol(s, &endptr_int, base);
|
||||||
|
|
||||||
|
if (errno != 0) {
|
||||||
|
FUNCFAILED("strtol", strerror(errno));
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endptr_int[0] != '\0') {
|
||||||
|
PRINTINTERR("strtol: invalid number %s", s);
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endptr)
|
||||||
|
*endptr = endptr_int;
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
@ -44,5 +44,6 @@ int mkpath(char* file_path, int mode);
|
|||||||
const char *get_ext(const char *path);
|
const char *get_ext(const char *path);
|
||||||
|
|
||||||
RESULT register_signal(int sig, SigHandler handler);
|
RESULT register_signal(int sig, SigHandler handler);
|
||||||
|
RESULT strtol_w(long *res, char *s, char **endptr, int base);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user