2 ###APPNAME: ui-select-list
4 ###APPDATE: 2009-02-08 19:31:24
6 ###APPDESC: ui-select-list
7 ###APPUSAGE: (title) (items ...)
8 ###APPEXAMPLE: ui-select-list
9 ###APPOPTION: ui-select-list "Where to go?" "goto hell" "goto heaven"
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
15 use lib
$ENV{XR_PERL_MODULE_DIR
};
17 use MyPlace
::Script
::Usage qw
/help_required help_even_empty/;
18 exit 0 if(help_required
($0,@ARGV));
19 #exit 0 if(help_even_empty($0,@ARGV));
26 print STDERR
("Usage: $0 <title> <items...>\n");exit 0;
29 my $width=length($title) + 8;
30 my $list_height = 1 * @items;
31 my $height= $list_height + 8;
38 my $len = length($_) + 8;$width = $len if($len>$width);
39 push @cmdline,$idx,"- $_";
42 unshift @cmdline,$app,"--menu",$title,$height,$width,$list_height,"--";
43 use File
::Temp qw
/tempfile/;
44 my (undef,$filename) = tempfile
();
47 open $olderr,">&",\
*STDERR
;
48 open $fh,">",$filename;
50 my $r = system(@cmdline);
52 open STDERR
,">&",$olderr;
55 exit 0 unless($r == 0);
57 open $fh,"<",$filename;
60 $r =~ s/^\s*(\d+).*$/$1/;