aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2025-06-24 22:01:17 +0200
committerThorsten Töpper <atsutane@freethoughts.de>2025-06-24 22:08:12 +0200
commit111f1bb981d6d6ed6f9116dc297d74ad20010401 (patch)
treefbc5ce385cdef509db30e39eced10c88b40c64cf
parent0937d5cb650544a8a3e729ffc783c74df1abea3e (diff)
downloaddir_monitor-111f1bb981d6d6ed6f9116dc297d74ad20010401.tar.gz
dir_monitor-111f1bb981d6d6ed6f9116dc297d74ad20010401.tar.bz2
output: limit fputc_all_cols to 72-144
-rw-r--r--src/output.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/output.c b/src/output.c
index 254d73f..396f3ef 100644
--- a/src/output.c
+++ b/src/output.c
@@ -34,7 +34,13 @@ void out_print_time_by_option(struct list_node *ptr);
inline int fputc_all_cols(char c, FILE *fdout) {
struct winsize terminal;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &terminal);
- return fputc_width_x(c, ((terminal.ws_col == 0) ? 72 : terminal.ws_col), fdout);
+ /* Somehow not always ws_col == 0, instead > 300 characters */
+ if (terminal.ws_col == 0) {
+ terminal.ws_col = 72;
+ } else if (terminal.ws_col > 144) {
+ terminal.ws_col = 144;
+ }
+ return fputc_width_x(c, terminal.ws_col, fdout);
}