]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
improve handling of long strings in whiptail menu (#1353792)
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 3 Aug 2016 14:29:44 +0000 (16:29 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 3 Aug 2016 14:33:36 +0000 (16:33 +0200)
dialogboxes.c

index d7902100913a2da79ede6b5c6a6493322416b469..502b6edb37ae69d19321a0d2eeeb569c06a22e36 100644 (file)
@@ -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)) {