diff options
author | jkh <jkh@FreeBSD.org> | 1998-09-28 16:11:22 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1998-09-28 16:11:22 +0000 |
commit | 2c4ac215829fcabe57bc873b77d18c66902b3051 (patch) | |
tree | e891cf82e5a663e58b7e1f3461731335dc9a3105 /gnu | |
parent | d1204d260f029316bea4c00223c0d320f5de4e38 (diff) | |
download | FreeBSD-src-2c4ac215829fcabe57bc873b77d18c66902b3051.zip FreeBSD-src-2c4ac215829fcabe57bc873b77d18c66902b3051.tar.gz |
Teach this code about the new tree functionality of libdialog.
Submitted by: "Anatoly A. Orehovsky" <tolik@mpeks.tomsk.su>
Diffstat (limited to 'gnu')
-rwxr-xr-x | gnu/usr.bin/dialog/TESTS/ftreebox | 27 | ||||
-rwxr-xr-x | gnu/usr.bin/dialog/TESTS/treebox | 25 | ||||
-rw-r--r-- | gnu/usr.bin/dialog/dialog.c | 54 |
3 files changed, 105 insertions, 1 deletions
diff --git a/gnu/usr.bin/dialog/TESTS/ftreebox b/gnu/usr.bin/dialog/TESTS/ftreebox new file mode 100755 index 0000000..621dc1e --- /dev/null +++ b/gnu/usr.bin/dialog/TESTS/ftreebox @@ -0,0 +1,27 @@ +#!/bin/sh +DIALOG=${DIALOG=/usr/bin/dialog} + +find -xd / -type d > /tmp/ftreebox.tmp.$$ + +$DIALOG --clear --title "FTREE BOX" \ + --hline "Press arrows, TAB or Enter" \ + --hfile "../COPYING" \ + --ftree "/tmp/ftreebox.tmp.$$" "/" \ + "This is ftree box" \ + -1 -1 10 2>/tmp/ftree.tmp.$$ + +retval=$? + +choice=`cat /tmp/ftree.tmp.$$` + +case $retval in + 0) + echo "'$choice' chosen.";; + 1) + echo "Cancel pressed.";; + 255) + [ -z "$choice" ] || echo $choice ; + echo "ESC pressed.";; +esac + +rm -f /tmp/ftreebox.tmp.$$ /tmp/ftree.tmp.$$ diff --git a/gnu/usr.bin/dialog/TESTS/treebox b/gnu/usr.bin/dialog/TESTS/treebox new file mode 100755 index 0000000..c5a546f --- /dev/null +++ b/gnu/usr.bin/dialog/TESTS/treebox @@ -0,0 +1,25 @@ +#!/bin/sh +DIALOG=${DIALOG=/usr/bin/dialog} + +$DIALOG --clear --title "TREE BOX" \ + --hline "Press arrows, TAB or Enter" \ + --hfile "../COPYING" \ + --tree "/" \ + "This is tree box" -1 -1 10 \ + `find -x / -type d` 2>/tmp/tree.tmp.$$ + +retval=$? + +choice=`cat /tmp/tree.tmp.$$` + +case $retval in + 0) + echo "'$choice' chosen.";; + 1) + echo "Cancel pressed.";; + 255) + [ -z "$choice" ] || echo $choice ; + echo "ESC pressed.";; +esac + +rm -f /tmp/tree.tmp.$$ diff --git a/gnu/usr.bin/dialog/dialog.c b/gnu/usr.bin/dialog/dialog.c index aafd777..b3690da 100644 --- a/gnu/usr.bin/dialog/dialog.c +++ b/gnu/usr.bin/dialog/dialog.c @@ -75,6 +75,10 @@ * prove 'interesting' to say the least :-) * Added radiolist option * - Version 0.4 released. + * + * 09/28/98 - Patches by Anatoly A. Orehovsky - tolik@mpeks.tomsk.su + * Added ftree and tree options + * */ #include <stdio.h> @@ -333,6 +337,51 @@ int main(int argc, unsigned char *argv[]) end_dialog(); return retval; } +/* ftree and tree options */ + else if (!strcmp(argv[offset+1], "--ftree")) { + unsigned char *tresult; + if (argc-offset != 8) { + Usage(argv[0]); + exit(-1); + } + init_dialog(); + retval = dialog_ftree(argv[offset+2], *argv[offset+3], + title, argv[offset+4], atoi(argv[offset+5]), atoi(argv[offset+6]), + atoi(argv[offset+7]), &tresult); + + dialog_update(); + if (!retval) + { + fputs(tresult, stderr); + free(tresult); + } + if (clear_screen) /* clear screen before exit */ + dialog_clear(); + end_dialog(); + return retval; + } + else if (!strcmp(argv[offset+1], "--tree")) { + unsigned char *tresult; + if (argc-offset < 8) { + Usage(argv[0]); + exit(-1); + } + init_dialog(); + retval = dialog_tree(argv+offset+7, argc-offset-7, *argv[offset+2], + title, argv[offset+3], atoi(argv[offset+4]), atoi(argv[offset+5]), + atoi(argv[offset+6]), &tresult); + + dialog_update(); + if (!retval) + { + fputs(tresult, stderr); + free(tresult); + } + if (clear_screen) /* clear screen before exit */ + dialog_clear(); + end_dialog(); + return retval; + } Usage(argv[0]); exit(-1); @@ -349,6 +398,7 @@ void Usage(unsigned char *name) \ndialog version 0.3, by Savio Lam (lam836@cs.cuhk.hk).\ \n patched to version %s by Stuart Herbert (S.Herbert@shef.ac.uk)\ \n Changes Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia\ +\n patched by Anatoly A. Orehovsky (tolik@mpeks.tomsk.su)\ \n\ \n* Display dialog boxes from shell scripts *\ \n\ @@ -367,6 +417,8 @@ void Usage(unsigned char *name) \n --textbox <file> <height> <width>\ \n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ \n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ -\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\n", VERSION, name, name, name); +\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ +\n --ftree <file> <FS> <text> <height> <width> <menu height>\ +\n --tree <FS> <text> <height> <width> <menu height> <item1>...\n", VERSION, name, name, name); } /* End of Usage() */ |