diff --git a/completion/_catimg b/completion/_catimg index 6e41580..b6e72bf 100644 --- a/completion/_catimg +++ b/completion/_catimg @@ -40,6 +40,7 @@ _arguments \ '-c[convert colors to a restricted palette]' \ '-h[display a help message]' \ '-H[specify the height of the displayed image]' \ + '-o[specify the height offset of the displayed image]' \ '-l[specify the amount of loops that catimg should repeat a GIF]' \ '-r[force the resolution of the image]: :->resolution' \ '-t[disable true color and use 256 color instead]' \ diff --git a/man/catimg.1 b/man/catimg.1 index 073c0e3..5db21fc 100644 --- a/man/catimg.1 +++ b/man/catimg.1 @@ -5,7 +5,7 @@ catimg \- fast image printing in to your terminal .SH SYNOPSIS .B catimg -[\fB-hct\fP] [\fB-w width\fP | \fB-H height\fP] [\fB-l loops\fP] [\fB-r resolution\fP] image +[\fB-hct\fP] [\fB-w width\fP | \fB-H height\fP] [\fB-o height offset\fP] [\fB-l loops\fP] [\fB-r resolution\fP] image .SH DESCRIPTION .B catimg @@ -22,6 +22,9 @@ Prints a help message \fB\-H\fR HEIGHT Specify the height of the displayed image, passing '0' will use terminal height. .TP +\fB\-o\fR HEIGHT_OFFSET +Specify the height offset of the displayed image, passing '0' will use no terminal height offset. +.TP \fB\-l\fR LOOPS Specify the amount of loops that catimg should repeat a GIF. A value of 1 means that the GIF will be displayed twice. A negative value implies infinity. .TP diff --git a/src/catimg.c b/src/catimg.c index 962ce5c..fe4f7a8 100644 --- a/src/catimg.c +++ b/src/catimg.c @@ -11,6 +11,7 @@ " -h: Displays this message\n" \ " -w: Terminal width/columns by default\n" \ " -H: Terminal height/row by default\n" \ + " -o: Terminal height offset by default 1\n" \ " -l: Loops are only useful with GIF files. A value of 1 means that the GIF will " \ "be displayed twice because it loops once. A negative value means infinite " \ "looping\n" \ @@ -72,13 +73,14 @@ int main(int argc, char *argv[]) opterr = 0; uint32_t cols = 0, rows = 0, precision = 0; + uint32_t height_offset = 1; // To account for the prompt in vertical scaling uint32_t max_cols = 0, max_rows = 0; uint8_t convert = 0; uint8_t true_color = 1; uint8_t adjust_to_height = 0, adjust_to_width = 0; float scale_cols = 0, scale_rows = 0; - while ((c = getopt (argc, argv, "H:w:l:r:hct")) != -1) + while ((c = getopt (argc, argv, "H:o:w:l:r:hct")) != -1) switch (c) { case 'H': rows = strtol(optarg, &num, 0); @@ -90,6 +92,9 @@ int main(int argc, char *argv[]) } adjust_to_height = 1; break; + case 'o': + height_offset = strtol(optarg, &num, 0); + break; case 'w': cols = strtol(optarg, &num, 0) >> 1; if (adjust_to_height) { @@ -138,7 +143,7 @@ int main(int argc, char *argv[]) // if precision is 2 we can use the terminal full width/height. Otherwise we can only use half max_cols = terminal_columns() / (2 / precision); - max_rows = terminal_rows() * precision; + max_rows = (terminal_rows() - height_offset) * precision; if (strcmp(file, "-") == 0) { img_load_from_stdin(&img);