Teach this code about the new tree functionality of libdialog.
Submitted by: "Anatoly A. Orehovsky" <tolik@mpeks.tomsk.su>
This commit is contained in:
parent
8bd4c21699
commit
364c8e85fb
27
gnu/usr.bin/dialog/TESTS/ftreebox
Executable file
27
gnu/usr.bin/dialog/TESTS/ftreebox
Executable file
@ -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.$$
|
25
gnu/usr.bin/dialog/TESTS/treebox
Executable file
25
gnu/usr.bin/dialog/TESTS/treebox
Executable file
@ -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.$$
|
@ -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() */
|
||||
|
Loading…
x
Reference in New Issue
Block a user