* setup.c: when running in Newt mode, make the size of the dialogs dynamic
authorArt Cancro <ajc@citadel.org>
Mon, 30 Aug 2004 02:45:34 +0000 (02:45 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Aug 2004 02:45:34 +0000 (02:45 +0000)
  to the size of the text in them.

citadel/ChangeLog
citadel/setup.c

index 4c6232b741912b5b79b6a77d64d1e6eec2ea3b85..df57ea0daf43c6ef35bcbbfc62fef2bac3cada73 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 625.6  2004/08/30 02:45:33  ajc
+ * setup.c: when running in Newt mode, make the size of the dialogs dynamic
+   to the size of the text in them.
+
  Revision 625.5  2004/08/29 15:18:41  error
  * newinstall.sh: fix detection of gmake/make
 
@@ -6018,4 +6022,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index fd14d1db0812d00d5c6f4505accc3573c90b2b0c..6f5ecbb6ccf33e8650e54254a7522b6a6e8aed99 100644 (file)
@@ -244,6 +244,7 @@ int yesno(char *question)
        newtComponent yesbutton = NULL;
        newtComponent nobutton = NULL;
        int i = 0;
+       int prompt_window_height = 0;
 #endif
        int answer = 0;
        char buf[SIZ];
@@ -264,14 +265,15 @@ int yesno(char *question)
 
 #ifdef HAVE_NEWT
        case UI_NEWT:
-               newtCenteredWindow(76, 10, "Question");
+               prompt_window_height = num_tokens(question, '\n') + 5;
+               newtCenteredWindow(76, prompt_window_height, "Question");
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(question, '\n'); ++i) {
                        extract_token(buf, question, i, '\n');
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
-               yesbutton = newtButton(10, 5, "Yes");
-               nobutton = newtButton(60, 5, "No");
+               yesbutton = newtButton(10, (prompt_window_height - 4), "Yes");
+               nobutton = newtButton(60, (prompt_window_height - 4), "No");
                newtFormAddComponent(form, yesbutton);
                newtFormAddComponent(form, nobutton);
                if (newtRunForm(form) == yesbutton) {
@@ -635,6 +637,7 @@ void strprompt(char *prompt_title, char *prompt_text, char *str)
        newtComponent form;
        char *result;
        int i;
+       int prompt_window_height = 0;
 #endif
        char buf[SIZ];
        char setupmsg[SIZ];
@@ -655,14 +658,22 @@ void strprompt(char *prompt_title, char *prompt_text, char *str)
 #ifdef HAVE_NEWT
        case UI_NEWT:
 
-               newtCenteredWindow(76, 10, prompt_title);
+               prompt_window_height = num_tokens(prompt_text, '\n') + 5 ;
+               newtCenteredWindow(76,
+                               prompt_window_height,
+                               prompt_title);
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(prompt_text, '\n'); ++i) {
                        extract_token(buf, prompt_text, i, '\n');
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form,
-                       newtEntry(1, 8, str, 74, &result, NEWT_FLAG_RETURNEXIT)
+                       newtEntry(1,
+                               (prompt_window_height - 2),
+                               str,
+                               74,
+                               &result,
+                               NEWT_FLAG_RETURNEXIT)
                );
                newtRunForm(form);
                strcpy(str, result);