From 540c5674722c1f569e9089db14ef07554ef48c16 Mon Sep 17 00:00:00 2001 From: "Pierre-Loup A. Griffais" Date: Sat, 6 Jun 2020 14:45:25 -0700 Subject: Don't display icons if they would line-wrap. Assuming we can query the terminal width. --- xprop.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'xprop.c') diff --git a/xprop.c b/xprop.c index 4d38c30..dc7fa0b 100644 --- a/xprop.c +++ b/xprop.c @@ -33,6 +33,7 @@ from The Open Group. #include #include #include +#include #include #include #include @@ -65,6 +66,8 @@ from The Open Group. /* isprint() in "C" locale */ #define c_isprint(c) ((c) >= 0x20 && (c) < 0x7f) +static int term_width = 80; + /* * * The Thunk Manager - routines to create, add to, and free thunk lists @@ -785,7 +788,7 @@ Format_Icons (const unsigned long *icon, int len) tail += sprintf (tail, "\tIcon (%lu x %lu):\n", width, height); - if (width > 144 || height > 144) + if ((width + 8) > term_width || height > 144) { tail += sprintf (tail, "\t(not shown)"); icon += width * height; @@ -1900,6 +1903,15 @@ main (int argc, char **argv) int n; char **nargv; +#ifdef TIOCGWINSZ + struct winsize ws; + ws.ws_col = 0; + ioctl(STDIN_FILENO, TIOCGWINSZ, &ws); + + if (ws.ws_col != 0) + term_width = ws.ws_col; +#endif + INIT_NAME; /* Set locale for XmbTextProptertyToTextList and iswprint(). */ -- cgit v1.2.3