summaryrefslogtreecommitdiff
path: root/misc/dialog/patches/patch-ag
blob: a90855e085a1fc53e148d9bcbd9c3ba3d48be2b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$NetBSD: patch-ag,v 1.2 1998/08/07 11:10:15 agc Exp $

--- msgbox.c.orig	Fri Jan 23 17:37:13 1998
+++ msgbox.c	Fri Jan 23 18:16:53 1998
@@ -28,8 +28,19 @@
 dialog_msgbox (const char *title, const char *prompt, int height, int width,
 		int pause)
 {
-    int i, x, y, key = 0;
+    int i, j, x, y, key = 0;
     WINDOW *dialog;
+
+    /* Choose useful default height and width if they are negative */
+    if (height < 0)
+        height = strheight(prompt) + 2 + 2 * (!!pause);
+    if (width < 0) {
+        i = strwidth(prompt);
+        j = ((title != NULL) ? strwidth(title) : 0);
+        width = MAX (i, j) + 4;
+    }
+    if (pause)
+        width = MAX (width, 10);
 
     /* center dialog box on screen */
     x = (COLS - width) / 2;