003 File Manager
Current Path:
/usr/src/contrib/dialog
usr
/
src
/
contrib
/
dialog
/
📁
..
📄
CHANGES
(108.53 KB)
📄
COPYING
(25.81 KB)
📄
README
(2.78 KB)
📄
VERSION
(20 B)
📄
aclocal.m4
(195.3 KB)
📄
argv.c
(3.54 KB)
📄
arrows.c
(6.8 KB)
📄
buildlist.c
(31.36 KB)
📄
buttons.c
(16.19 KB)
📄
calendar.c
(24.45 KB)
📄
checklist.c
(17.98 KB)
📄
columns.c
(4.17 KB)
📄
config.guess
(43.14 KB)
📄
config.hin
(75 B)
📄
config.sub
(34.92 KB)
📄
configure
(666.11 KB)
📄
configure.in
(7.57 KB)
📄
demo.pl
(11.44 KB)
📄
dialog-config.in
(4.31 KB)
📄
dialog.1
(60.51 KB)
📄
dialog.3
(124.54 KB)
📄
dialog.c
(52.45 KB)
📄
dialog.h
(37.7 KB)
📄
dialog.lsm
(1.1 KB)
📄
dialog.pl
(15.08 KB)
📄
dlg_colors.h
(6.87 KB)
📄
dlg_keys.c
(20.68 KB)
📄
dlg_keys.h
(5.23 KB)
📄
editbox.c
(16.81 KB)
📄
formbox.c
(23.3 KB)
📄
fselect.c
(22.06 KB)
📄
guage.c
(10.26 KB)
📄
headers-sh.in
(5.35 KB)
📄
headers.sh
(3.6 KB)
📄
help.c
(1.4 KB)
📄
inputbox.c
(7.04 KB)
📄
inputstr.c
(17.73 KB)
📄
install-sh
(6.96 KB)
📄
makefile.in
(10.07 KB)
📄
menubox.c
(20.26 KB)
📄
mixedform.c
(3.39 KB)
📄
mixedgauge.c
(9.6 KB)
📄
mouse.c
(3.5 KB)
📄
mousewget.c
(2.19 KB)
📄
msgbox.c
(4.99 KB)
📁
package
📄
pause.c
(6.53 KB)
📁
po
📄
prgbox.c
(2.73 KB)
📄
progressbox.c
(9.88 KB)
📄
rangebox.c
(10.54 KB)
📄
rc.c
(15 KB)
📄
rename.sh
(3.04 KB)
📁
samples
📄
tailbox.c
(9.53 KB)
📄
textbox.c
(24.86 KB)
📄
timebox.c
(10.27 KB)
📄
trace.c
(5.72 KB)
📄
treeview.c
(16.55 KB)
📄
ttysize.c
(2.28 KB)
📄
ui_getc.c
(14.03 KB)
📄
util.c
(64.44 KB)
📄
version.c
(1.01 KB)
📄
yesno.c
(4.28 KB)
Editing: demo.pl
#!/usr/bin/env perl # $Id: demo.pl,v 1.23 2018/06/12 21:39:44 tom Exp $ ################################################################################ # Copyright 2018 Thomas E. Dickey # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License, version 2.1 # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to # Free Software Foundation, Inc. # 51 Franklin St., Fifth Floor # Boston, MA 02110, USA. ################################################################################ # This demonstration is provided solely to exercise the sample Perl wrapper for # dialog which is included in its source-code. See libui-dialog-perl for a # more comprehensive binding. # # TODO: modify dialog.pl to use $DIALOG environment variable, drive from GetOpts here # TODO: eliminate constant $scr_lines in dialog.pl use warnings; use strict; use diagnostics; use FindBin qw($Bin $Script); use lib "$Bin"; require "dialog.pl"; dialog->import('@dialog_result'); our @dialog_result; sub tput($$) { my $name = shift; my $default = shift; my $value = `tput "$name"`; chomp $value; $value = $default unless ( $value =~ /^[0-9]+$/ ); return $value; } sub napms($) { my $msecs = shift; select( undef, undef, undef, $msecs * 0.001 ); } sub show_results($$) { my $title = shift; my $width = shift; &rhs_msgbox( $title, sprintf( "Resulting text:\\n %s", join( '\\n ', @dialog_result ) ), $width ); } sub doit() { my $status = 1; my $RHS_CLEAR = "clear"; my $RHS_TEXTBOX = "textbox"; my $RHS_MSGBOX = "msgbox"; my $RHS_INFOBOX = "infobox"; my $RHS_YESNO = "yesno"; my $RHS_GAUGE = "gauge"; my $RHS_INPUTBOX = "inputbox"; my $RHS_MENU = "menu"; my $RHS_MENUL = "menul"; my $RHS_MENUA = "menua"; my $RHS_CHECKLIST = "checklist"; my $RHS_CHECKLISTL = "checklistl"; my $RHS_CHECKLISTA = "checklista"; my $RHS_RADIOLIST = "radiolist"; my @demo_2col = qw( This that is has a this 2-column quoted menu "tag". ); my @demo_3col; my @demo_tags; my %demo_hash; for ( my $s = 0, my $t = 0 ; $s <= $#demo_2col ; $s += 2, $t += 3 ) { my $d = $s / 2; my $c1 = $demo_2col[$s]; my $c2 = $demo_2col[ $s + 1 ]; $demo_3col[$t] = $c1; $demo_3col[ $t + 1 ] = $c2; $demo_3col[ $t + 2 ] = ( $c1 =~ /2/ ) ? 1 : 0; $demo_tags[$d] = $c1; $demo_tags[$d] =~ s/2/1/; $demo_tags[ $d + ( $#demo_2col + 1 ) / 2 ] = $c2; $demo_hash{ sprintf( "%d %s", $d, $c1 ) } = $c2; } while ( $status > 0 ) { my $lines = &tput( "lines", 24 ); my $cols = &tput( "cols", 80 ); my $maxcols = $cols - 4; my $mincols = ( $cols > 8 ) ? 8 : $cols; my $midcols = int( ( $cols * 3 ) / 4 ); @dialog_result = (); $status = &rhs_menu( "My title", "My message", 0, 14, $RHS_CLEAR, "clear and exit", $RHS_TEXTBOX, "text-box of this script", $RHS_MSGBOX, "informational-message, OK button", $RHS_INFOBOX, "informational-message, no button", $RHS_YESNO, "message with Yes/No buttons", $RHS_GAUGE, "message with progress-gauge", $RHS_INPUTBOX, "input-box", $RHS_MENU, "menu, with tags and description", $RHS_MENUL, "menu, using only tags", $RHS_MENUA, "alphabetically sorted menu", $RHS_CHECKLIST, "check-list with tags and description", $RHS_CHECKLISTL, "check-list using only tags", $RHS_CHECKLISTA, "alphabetically sorted check-list", $RHS_RADIOLIST, "list of radio-buttons" ); if ( $status > 0 and $#dialog_result == 0 ) { my $testcase = $dialog_result[0]; if ( $testcase eq $RHS_CLEAR ) { &rhs_clear; last; } elsif ( $testcase eq $RHS_TEXTBOX ) { &rhs_textbox( "This script", "$Script", 0, 0 ); } elsif ( $testcase eq $RHS_MSGBOX ) { my $msg = "This is a demonstration script.\\n" . "This should be the second line,\\n" . "and this should be the third line,"; &rhs_msgbox( "A message", $msg, int( ( length($msg) + 3 ) / 3 ) + 3 ); } elsif ( $testcase eq $RHS_INFOBOX ) { my $msg = "This is a fairly long line of text, used to" . " show how dialog can be used to wrap lines to fit in" . " screens with different width. The text will start wide," . " then get narrower, showing a new infobox for each width" . " before going back up to the full width of the terminal."; my $wide = $maxcols; while ( $wide > $mincols ) { &rhs_infobox( "Info-box", $msg, $wide-- ); &napms(50); } while ( $wide < $maxcols ) { &rhs_infobox( "Info-box", $msg, ++$wide ); &napms(50); } &rhs_msgbox( "Info-end", $msg, $wide ); } elsif ( $testcase eq $RHS_YESNO ) { if ( &rhs_yesno( "Yes/no", "Should \"dialog --yesno\" return \"1\" on \"yes\"" . " to simplify (some) shell scripts?", $cols / 2 ) ) { &rhs_msgbox( "Explanation", "No, a successful program exits with " . "\"0\" (EXIT_SUCCESS)", $cols / 2 ); } else { &rhs_msgbox( "Explanation", "Shell scripts assume that \"exit\ 0\" is successful;" . " Perl is different.", $cols / 2 ); } } elsif ( $testcase eq $RHS_GAUGE ) { my $pct = 0; my $sec = 10; &rhs_gauge( "My gauge", "Show progress (or lack of it)", $midcols * 3, $pct ); while ( $pct < 100 ) { $pct++; &napms($sec); $sec *= 1.04; &rhs_update_gauge($pct); } $pct = 99; &rhs_update_gauge_and_message( "This will go faster", $pct ); while ( $pct > 0 ) { $pct--; &napms($sec); $sec /= 1.05; &rhs_update_gauge($pct); } &napms(1000); &rhs_stop_gauge; } elsif ( $testcase eq $RHS_INPUTBOX ) { if ( &rhs_inputbox( "My inputbox", "This demonstrates the inputbox", $maxcols, "" ) ) { &show_results( "My inputbox", $midcols ); } } elsif ( $testcase eq $RHS_MENU ) { if ( &rhs_menu( ( "A menu", "This menu uses \"tag\" values and descriptions:", $midcols, ( $#demo_2col + 1 ) / 2 ), @demo_2col ) ) { &show_results( "My menu", $midcols ); } } elsif ( $testcase eq $RHS_MENUL ) { if ( &rhs_menul( ( "A menu", "This menu uses only the \"tag\" values:", $midcols, $#demo_tags + 1 ), @demo_tags ) ) { &show_results( "My long-menu", $midcols ); } } elsif ( $testcase eq $RHS_MENUA ) { if ( &rhs_menua( "A menu", "This menu uses the sorted keys from a hash:", $midcols, %demo_hash ) ) { &show_results( "My alpha-menu", $midcols ); } } elsif ( $testcase eq $RHS_CHECKLIST ) { if ( &rhs_checklist( ( "A checklist", "This checklist uses \"tag\" values" . " and descriptions:", $midcols, ( $#demo_3col + 1 ) / 3 ), @demo_3col ) ) { &show_results( "My checklist", $midcols ); } } elsif ( $testcase eq $RHS_CHECKLISTL ) { if ( &rhs_checklistl( ( "A checklist", "This checklist uses only the \"tag\" values:", $midcols, $#demo_tags + 1 ), @demo_tags ) ) { &show_results( "My long-checklist", $midcols ); } } elsif ( $testcase eq $RHS_CHECKLISTA ) { if ( &rhs_checklista( "A checklist", "This checklist uses the sorted keys from a hash:", $midcols, %demo_hash ) ) { &show_results( "My alpha-checklist", $midcols ); } } elsif ( $testcase eq $RHS_RADIOLIST ) { if ( &rhs_radiolist( ( "A radiolist", "This radiolist uses \"tag\" values" . " and descriptions:", $midcols, ( $#demo_3col + 1 ) / 3 ), @demo_3col ) ) { &show_results( "My radiolist", $midcols ); } } } } } &doit; 1;
Upload File
Create Folder