]> git.ipfire.org Git - thirdparty/newt.git/blobdiff - whiptcl.c
install python modules to purelib and platlib
[thirdparty/newt.git] / whiptcl.c
index 82c12ab55c5b68d165b2cdbde35f0ecf13065f31..c5762d9d22e988878d4e8274dc5400af7fa6cf1b 100644 (file)
--- a/whiptcl.c
+++ b/whiptcl.c
@@ -65,14 +65,15 @@ static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
     char * end;
     int height;
     int width;
+    int listHeight;
     int noCancel = 0;
     int noItem = 0;
     int scrollText = 0;
     int rc = 0;
     int flags = 0;
     int defaultNo = 0;
-    const char * result;
-    const char ** selections, ** next;
+    char * result;
+    char ** selections, ** next;
     char * title = NULL;
     char *default_item = NULL;
     struct poptOption optionsTable[] = {
@@ -179,6 +180,22 @@ static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
        return TCL_ERROR;
     }
 
+    switch (mode) {
+      case MODE_MENU:
+      case MODE_RADIOLIST:
+      case MODE_CHECKLIST:
+       if (!(nextArg = poptGetArg(optCon))) {
+           interp->result = "list-height missing";
+           return TCL_ERROR;
+       }
+       listHeight = strtoul(nextArg, &end, 10);
+       if (*end) {
+           interp->result = "list-height is not a number";
+           return TCL_ERROR;
+       }
+       break;
+    }
+
     width -= 2;
     height -= 2;
     newtOpenWindow((80 - width) / 2, (24 - height) / 2, width, height, title);
@@ -205,29 +222,34 @@ static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
       case MODE_INPUTBOX:
        rc = inputBox(text, height, width, optCon, flags, &result);
        if (rc ==DLG_OKAY) {
-           interp->result = strdup(result);
+           interp->result = result;
            interp->freeProc = TCL_DYNAMIC;
        }
        break;
 
       case MODE_MENU:
-       rc = listBox(text, height, width, optCon, flags, default_item, &result);
+       rc = listBox(text, height, width, listHeight, optCon, flags, default_item,
+                    &result);
        if (rc==DLG_OKAY) {
-           interp->result = strdup(result);
+           interp->result = result;
            interp->freeProc = TCL_DYNAMIC;
        }
        break;
 
       case MODE_RADIOLIST:
-       rc = checkList(text, height, width, optCon, 1, flags, &selections);
+       rc = checkList(text, height, width, listHeight, optCon, 1, flags,
+                      &selections);
        if (rc==DLG_OKAY) {
-           interp->result = strdup(selections[0]);
+           interp->result = selections[0];
            interp->freeProc = TCL_DYNAMIC;
+
+           free(selections);
        }
        break;
 
       case MODE_CHECKLIST:
-       rc = checkList(text, height, width, optCon, 0, flags, &selections);
+       rc = checkList(text, height, width, listHeight, optCon, 0, flags,
+                      &selections);
 
        if (rc==DLG_OKAY) {
            for (next = selections; *next; next++)