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

Bug#2489: dialog auto-sizing doesn't take title into account.



Package: dialog

David,

Would you please add this patch to "dialog" and upload a new version? It
make it take the title into account when auto-sizing boxes. Otherwise, a
wide title will end up on the bottom line of the box, partially visible.

The boot floppies require this patch.

	Thanks

	Bruce

diff -uNr dialog-0.9a.orig/checklist.c dialog-0.9a/checklist.c
--- dialog-0.9a.orig/checklist.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/checklist.c	Sat Mar  9 10:28:42 1996
@@ -73,10 +73,10 @@
     if (list_height == 0) {
       min_width=calc_listw(item_no, items, 3)+14;
       /* calculate height without items (4) */
-      prompt=auto_size(prompt, &height, &width, 4, MAX(26, min_width));
+      prompt=auto_size(title, prompt, &height, &width, 4, MAX(26, min_width));
       calc_listh(&height, &list_height, item_no);
     } else
-      prompt=auto_size(prompt, &height, &width, 4+list_height, 26);
+      prompt=auto_size(title, prompt, &height, &width, 4+list_height, 26);

     print_size(height, width);
     ctl_size(height, width);
diff -uNr dialog-0.9a.orig/debian.rules dialog-0.9a/debian.rules
--- dialog-0.9a.orig/debian.rules	Thu Feb 22 08:12:57 1996
+++ dialog-0.9a/debian.rules	Sat Mar  9 11:06:21 1996
@@ -10,7 +10,7 @@

 p = dialog
 v = 0.9a
-d = 1
+d = 2

 build:
 # Builds the binary package.
diff -uNr dialog-0.9a.orig/dialog.c dialog-0.9a/dialog.c
--- dialog-0.9a.orig/dialog.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/dialog.c	Sat Mar  9 10:33:38 1996
@@ -19,6 +19,7 @@
  */

 #include "dialog.h"
+#include <string.h>

 static void Usage (const char *name);
 static int howmany_tags(int argc, const char * const * argv, int offset, int group);
diff -uNr dialog-0.9a.orig/dialog.h dialog-0.9a/dialog.h
--- dialog-0.9a.orig/dialog.h	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/dialog.h	Sat Mar  9 10:48:52 1996
@@ -162,8 +162,8 @@
 void attr_clear (WINDOW * win, int height, int width, chtype attr);
 void put_backtitle(void);

-char *auto_size(char *prompt, int *height, int *width, int boxlines, int mincols);
-void auto_sizefile(const char *file, int *height, int *width, int boxlines, int mincols);
+char *auto_size(const char * title, char *prompt, int *height, int *width, int boxlines, int mincols);
+void auto_sizefile(const char * title, const char *file, int *height, int *width, int boxlines, int mincols);

 char *make_lock_filename(char *filename);
 void wrefresh_lock(WINDOW *win);
@@ -220,28 +220,17 @@
  */
 #ifndef HAVE_LIBGPM

-extern __inline__ void
-mouse_open (void)
-{
-};
-extern __inline__ void
-mouse_close (void)
-{
-};
-extern __inline__ void
-mouse_mkregion (int y, int x, int height, int width,
-		int code)
-{
-};
-extern __inline__ void
-mouse_mkbigregion (int y, int x, int height, int width,
-		   int nitems, int th, int mode)
-{
-};
-extern __inline__ void
-mouse_setbase (int x, int y)
-{
-};
+/*
+ * This used to be defined as "extern __inline__", which caused problems
+ * when building with -g . That might be a gcc bug, but what does a compiler
+ * do with an "extern" inline? Inline it and then generate an
+ * externaly-callable version? Ugh!
+ */
+#define	mouse_open() {}
+#define	mouse_close() {}
+#define	mouse_mkregion(y, x, height, width, code) {}
+#define	mouse_mkbigregion(y, x, height, width, nitems, th, mode) {}
+#define	mouse_setbase(x, y) {}

 #else

diff -uNr dialog-0.9a.orig/guage.c dialog-0.9a/guage.c
--- dialog-0.9a.orig/guage.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/guage.c	Sat Mar  9 10:28:53 1996
@@ -41,7 +41,7 @@
   char *prompt=strclone(cprompt);

   tab_correct_str(prompt);
-  prompt=auto_size(prompt, &height, &width, 3, 0);
+  prompt=auto_size(title, prompt, &height, &width, 3, 0);
   print_size(height, width);
   ctl_size(height, width);

diff -uNr dialog-0.9a.orig/inputbox.c dialog-0.9a/inputbox.c
--- dialog-0.9a.orig/inputbox.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/inputbox.c	Sat Mar  9 10:29:04 1996
@@ -37,9 +37,9 @@

     tab_correct_str(prompt);
     if (init != NULL) {
-      prompt=auto_size(prompt, &height, &width, 5, MIN(MAX(strlen(init)+7,26),SCOLS-(begin_set ? begin_x : 0)));
+      prompt=auto_size(title, prompt, &height, &width, 5, MIN(MAX(strlen(init)+7,26),SCOLS-(begin_set ? begin_x : 0)));
     } else
-      prompt=auto_size(prompt, &height, &width, 5, 26);
+      prompt=auto_size(title, prompt, &height, &width, 5, 26);
     print_size(height, width);
     ctl_size(height, width);

diff -uNr dialog-0.9a.orig/menubox.c dialog-0.9a/menubox.c
--- dialog-0.9a.orig/menubox.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/menubox.c	Sat Mar  9 10:29:11 1996
@@ -62,10 +62,10 @@
     if (menu_height == 0) {
       min_width=calc_listw(item_no, items, 2)+10;
       /* calculate height without items (4) */
-      prompt=auto_size(prompt, &height, &width, 4, MAX(26, min_width));
+      prompt=auto_size(title, prompt, &height, &width, 4, MAX(26, min_width));
       calc_listh(&height, &menu_height, item_no);
     } else
-      prompt=auto_size(prompt, &height, &width, 4+menu_height, 26);
+      prompt=auto_size(title, prompt, &height, &width, 4+menu_height, 26);
     print_size(height, width);
     ctl_size(height, width);

diff -uNr dialog-0.9a.orig/msgbox.c dialog-0.9a/msgbox.c
--- dialog-0.9a.orig/msgbox.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/msgbox.c	Sat Mar  9 10:29:18 1996
@@ -33,7 +33,7 @@
     char *prompt=strclone(cprompt);

     tab_correct_str(prompt);
-    prompt=auto_size(prompt, &height, &width, (pause == 1 ? 2 : 0), (pause == 1 ? 12 : 0));
+    prompt=auto_size(title, prompt, &height, &width, (pause == 1 ? 2 : 0), (pause == 1 ? 12 : 0));
     print_size(height, width);
     ctl_size(height, width);

diff -uNr dialog-0.9a.orig/tailbox.c dialog-0.9a/tailbox.c
--- dialog-0.9a.orig/tailbox.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/tailbox.c	Sat Mar  9 10:32:58 1996
@@ -45,7 +45,7 @@
   WINDOW *dialog, *text;
   char ch;

-  auto_sizefile(file, &height, &width, 2, 12);
+  auto_sizefile(title, file, &height, &width, 2, 12);
   print_size(height, width);
   ctl_size(height, width);

@@ -168,7 +168,7 @@
   WINDOW *dialog, *text;
   char ch;

-  auto_sizefile(file, &height, &width, 1, 0);
+  auto_sizefile(title, file, &height, &width, 1, 0);
   print_size(height, width);
   ctl_size(height, width);

diff -uNr dialog-0.9a.orig/textbox.c dialog-0.9a/textbox.c
--- dialog-0.9a.orig/textbox.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/textbox.c	Sat Mar  9 10:29:35 1996
@@ -49,7 +49,7 @@
   char search_term[MAX_LEN+1], *tempptr, *found;
   WINDOW *dialog, *text;

-  auto_sizefile(file, &height, &width, 2, 12);
+  auto_sizefile(title, file, &height, &width, 2, 12);
   print_size(height, width);
   ctl_size(height, width);

diff -uNr dialog-0.9a.orig/util.c dialog-0.9a/util.c
--- dialog-0.9a.orig/util.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/util.c	Sat Mar  9 11:00:17 1996
@@ -293,8 +293,8 @@
  *    else
  *       calculate with aspect_ratio
  */
-char *auto_size(char *prompt, int *height, int *width, int boxlines, int mincols) {
-  int count = 0, len = 0, street, i, first, nc = 4, nl = 3,
+char *auto_size(const char * title, char *prompt, int *height, int *width, int boxlines, int mincols) {
+  int count = 0, len = title ? strlen(title) : 0, street, i, first, nc = 4, nl = 3,
       cur_x, text_width;
   char *cr1, *cr2, *ptr = prompt, *str, *word;

@@ -346,7 +346,8 @@
     return prompt;
   } else {          /* all chars in only a line */
     str = (char *)malloc(strlen(prompt)*2);
-    text_width = MAX( ((int) sqrt((double)(aspect_ratio*strlen(prompt)))), (mincols-nc));
+    text_width = MAX(((int) sqrt((double)(aspect_ratio*strlen(prompt)))), (mincols-nc));
+	text_width = MAX(text_width, len);
     ptr = (char *)malloc(strlen(prompt)+1);

     while (1) {
@@ -398,8 +399,8 @@
  *    height=MIN(SLINES, num.lines in fd+n);
  *    width=MIN(SCOLS, MAX(longer line+n, mincols));
  */
-void auto_sizefile(const char *file, int *height, int *width, int boxlines, int mincols) {
-  int count = 0, len = 0, nc = 4, nl = 2;
+void auto_sizefile(const char * title, const char *file, int *height, int *width, int boxlines, int mincols) {
+  int count = 0, len = title ? strlen(title) : 0, nc = 4, nl = 2;
   long offset;
   char ch;
   FILE *fd;
diff -uNr dialog-0.9a.orig/yesno.c dialog-0.9a/yesno.c
--- dialog-0.9a.orig/yesno.c	Mon Jan 15 14:53:00 1996
+++ dialog-0.9a/yesno.c	Sat Mar  9 10:29:55 1996
@@ -31,7 +31,7 @@
     char *prompt=strclone(cprompt);

     tab_correct_str(prompt);
-    prompt=auto_size(prompt, &height, &width, 2, 25);
+    prompt=auto_size(title, prompt, &height, &width, 2, 25);
     print_size(height, width);
     ctl_size(height, width);


Reply to: