summaryrefslogtreecommitdiff
path: root/misc/dialog/patches/patch-aj
blob: a2285abc21a412c5a58f87c1b601f9f096c2eb35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- yesno.c.orig	Fri Jan 23 17:37:13 1998
+++ yesno.c	Fri Jan 23 18:17:16 1998
@@ -26,8 +26,18 @@
 int
 dialog_yesno (const char *title, const char *prompt, int height, int width)
 {
-    int i, x, y, key = 0, button = 0;
+    int i, j, x, y, key = 0, button = 0;
     WINDOW *dialog;
+
+    /* Choose useful default height and width if they are negative */
+    if (height < 0)
+        height = strheight(prompt) + 4;
+    if (width < 0) {
+        i = strwidth(prompt);
+        j = ((title != NULL) ? strwidth(title) : 0);
+        width = MAX (i, j) + 4;
+    }
+    width = MAX (width, MIN_DIALOG_WIDTH);
 
     /* center dialog box on screen */
     x = (COLS - width) / 2;