From b2698a7b151418d8adfbcdd8b0e021864dd059a1 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 4 Jan 2025 10:55:53 +0100 Subject: [PATCH] Repeat cell size query for logging if verbose is enabled. --- src/term-query.cc | 9 +++++++-- src/timg.cc | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/term-query.cc b/src/term-query.cc index 2505441..d7bdb5e 100644 --- a/src/term-query.cc +++ b/src/term-query.cc @@ -353,7 +353,12 @@ TermSizeResult DetermineTermSize() { TermSizeResult result; for (const int fd : {STDOUT_FILENO, STDERR_FILENO, STDIN_FILENO}) { struct winsize w = {}; - if (ioctl(fd, TIOCGWINSZ, &w) != 0) continue; + if (ioctl(fd, TIOCGWINSZ, &w) != 0) { + if (s_log_terminal_queries) { + fprintf(stderr, "ioctl(%d, TIOCGWINSZ) failing.\n", fd); + } + continue; + } // If we get the size of the terminals in pixels, we can determine // what aspect ratio the pixels. This is also needed to // jump up the exact number of character cells needed for animations @@ -370,7 +375,7 @@ TermSizeResult DetermineTermSize() { } else { if (s_log_terminal_queries) { - fprintf(stderr, "no usable TIOCGWINSZ, trying cell query.\n"); + fprintf(stderr, "No usable TIOCGWINSZ, trying cell query.\n"); } // Alright, TIOCGWINSZ did not return the terminal size, let's // see if it reports character cell size otherwise diff --git a/src/timg.cc b/src/timg.cc index 6c16262..30b4ce2 100644 --- a/src/timg.cc +++ b/src/timg.cc @@ -802,6 +802,10 @@ int main(int argc, char *argv[]) { } timg::EnableTerminalQueryLogging(verbose); + if (verbose) { + // Called this earlier, but now that verbose enabled, again for logging + timg::DetermineTermSize(); + } // -- A sieve of sanity checks and configuration refinement.