From 2c4ac215829fcabe57bc873b77d18c66902b3051 Mon Sep 17 00:00:00 2001 From: jkh Date: Mon, 28 Sep 1998 16:11:22 +0000 Subject: Teach this code about the new tree functionality of libdialog. Submitted by: "Anatoly A. Orehovsky" --- gnu/usr.bin/dialog/TESTS/ftreebox | 27 ++++++++++++++++++++ gnu/usr.bin/dialog/TESTS/treebox | 25 ++++++++++++++++++ gnu/usr.bin/dialog/dialog.c | 54 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100755 gnu/usr.bin/dialog/TESTS/ftreebox create mode 100755 gnu/usr.bin/dialog/TESTS/treebox (limited to 'gnu') 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 @@ -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 \ \n --menu ...\ \n --checklist ...\ -\n --radiolist ...\n", VERSION, name, name, name); +\n --radiolist ...\ +\n --ftree \ +\n --tree ...\n", VERSION, name, name, name); } /* End of Usage() */ -- cgit v1.1