From 10bbfd2837eb5ad87416ed2a648231a2a9b7c6fc Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 3 Aug 2016 16:29:44 +0200 Subject: [PATCH] improve handling of long strings in whiptail menu (#1353792) --- dialogboxes.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dialogboxes.c b/dialogboxes.c index d790210..502b6ed 100644 --- a/dialogboxes.c +++ b/dialogboxes.c @@ -326,7 +326,7 @@ int listBox(const char * text, int height, int width, poptContext optCon, i = 2; } - lineWidth = min(maxTagWidth + maxTextWidth + i, SLtt_Screen_Cols - 10); + lineWidth = min(maxTagWidth + maxTextWidth + i + 1, SLtt_Screen_Cols - 6); listBox = newtListbox( (width - lineWidth) / 2 , top + 1, listHeight, NEWT_FLAG_RETURNEXIT | scrollFlag); @@ -335,12 +335,16 @@ int listBox(const char * text, int height, int width, poptContext optCon, if (maxTextWidth == 0) { tagWidth = lineWidth; } else { - if (maxTextWidth + maxTagWidth + i > lineWidth) - tagWidth = textWidth = (lineWidth / 2) - 2; - else { - tagWidth++; - textWidth++; - } + tagWidth++; + textWidth++; + while (textWidth + tagWidth + i > lineWidth) { + if (textWidth >= tagWidth && textWidth > 0) + textWidth--; + else if (tagWidth > 0) + tagWidth--; + else + break; + } } if (!(flags & FLAG_NOTAGS)) { -- 2.47.2