Skip to content

Commit

Permalink
Repeat cell size query for logging if verbose is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Jan 4, 2025
1 parent 0f64f01 commit b2698a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/term-query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/timg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit b2698a7

Please sign in to comment.