[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

whiptail / modconf fix



The attached patch fixes bugs 36587, 43270, 47855, and 51019 in whiptail. In
particular, #51019 is the (RC) bug where modconf messes up its width
handling when displaying module information.

randolph
-- 
   @..@                                         http://www.TauSq.org/
  (----)
 ( >__< )
 ^^ ~~ ^^

diff -uNr newt-0.50/dialogboxes.c newt-0.50.new/dialogboxes.c
--- newt-0.50/dialogboxes.c	Tue Dec 14 17:48:29 1999
+++ newt-0.50.new/dialogboxes.c	Tue Dec 14 17:47:07 1999
@@ -162,7 +162,7 @@
     int listHeight;
     int numItems = 0;
     int allocedItems = 5;
-    int i, top;
+    int i, top, left;
     int rc = DLG_OKAY;
     char buf[80], format[20];
     int maxTagWidth = 0;
@@ -212,14 +212,14 @@
 	i = 2;
     }
 
-    listBox = newtListbox(3 + ((width - 10 - maxTagWidth - maxTextWidth - i) 
-					/ 2),
-			  top + 1, listHeight, 
+    left = (width - 10 - maxTagWidth - maxTextWidth - i) / 2;
+    if (left < 0) left = 0;
+    listBox = newtListbox(3 + left, top + 1, listHeight, 
 			    NEWT_FLAG_RETURNEXIT | scrollFlag);
 
     sprintf(format, "%%-%ds  %%s", maxTagWidth);
     for (i = 0; i < numItems; i++) {
-	sprintf(buf, format, itemInfo[i].tag, itemInfo[i].text);
+	snprintf(buf, width - 6, format, itemInfo[i].tag, itemInfo[i].text);
 	newtListboxAddEntry(listBox, buf, (void *) i);
     }
 
@@ -364,6 +364,18 @@
     newtComponent form, yes, tb, answer;
     newtComponent no = NULL;
     int tFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
+    char * buf, * src, * dst;
+   
+    dst = buf = alloca(strlen(text) + 1);
+    src = text; 
+    while (*src) {
+	if (*src == '\\' && *(src + 1) == 'n') {
+	    src += 2;
+	    *dst++ = '\n';
+	} else
+	    *dst++ = *src++;
+    }
+    *dst++ = '\0';
 
     form = newtForm(NULL, NULL, 0);
 
@@ -375,7 +387,7 @@
       tb = newtTextbox(1, 1, width - 2, height - 2, NEWT_FLAG_WRAP | tFlag);
     }
 
-    newtTextboxSetText(tb, text);
+    newtTextboxSetText(tb, buf);
 
     newtFormAddComponent(form, tb);
 
diff -uNr newt-0.50/entry.c newt-0.50.new/entry.c
--- newt-0.50/entry.c	Sun Aug  1 21:25:14 1999
+++ newt-0.50.new/entry.c	Tue Dec 14 16:18:05 1999
@@ -285,6 +285,12 @@
 	}
 	break;
 
+      case '\025':				/* ^U */
+        en->cursorPosition = 0;
+        *(en->buf) = 0;
+        en->bufUsed = 0;
+        break;
+       
       case NEWT_KEY_BKSPC:
 	if (en->cursorPosition) {
 	    /* if this isn't true, there's nothing to erase */
diff -uNr newt-0.50/form.c newt-0.50.new/form.c
--- newt-0.50/form.c	Tue Dec 14 17:48:29 1999
+++ newt-0.50.new/form.c	Tue Dec 14 16:18:05 1999
@@ -67,7 +67,7 @@
   unsigned char buttons, modifiers;  /* try to be a multiple of 4 */
   unsigned short vc;
   short dx, dy, x, y;
-  short wdx, wdy;               // For wheels..
+  short wdx, wdy;               /* For wheels.. */
   enum Gpm_Etype type;
   int clicks;
   enum Gpm_Margin margin;
diff -uNr newt-0.50/whiptail.c newt-0.50.new/whiptail.c
--- newt-0.50/whiptail.c	Tue Dec 14 17:48:29 1999
+++ newt-0.50.new/whiptail.c	Tue Dec 14 16:55:42 1999
@@ -96,7 +96,8 @@
 
     *height += h;
     *width += w;
-    
+   
+    *width = min(*width, SLtt_Screen_Cols); 
     return text;
 }
 
@@ -154,6 +155,7 @@
     }
 
     *width = max(*width, tagWidth + descriptionWidth + overhead);
+    *width = min(*width, SLtt_Screen_Cols);
 
     h = min(h, SLtt_Screen_Rows - *height - 4);
     *height = *height + h + 1;
@@ -219,7 +221,7 @@
        w += 2; /* Add width of slider - is this right? */
     }
 
-    *width = min(max(*width, w), SLtt_Screen_Cols);
+    *width = min(max(*width, w), SLtt_Screen_Cols); 
     *height = max(*height, h);
 }
 


Reply to: