3
UI::Dialog::Backend::CDialog
7
use UI::Dialog::Backend::CDialog;
8
my $d = new UI::Dialog::Backend::CDialog ( backtitle => 'Demo',
11
$d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' );
15
UI::Dialog::Backend::CDialog is the UI::Dialog backend for the console
16
dialog variant. While this module is used through UI::Dialog or any other loader
17
module only the compatible methods are ever accessible. However, when using
18
this module directly in your application (as in the SYNOPSIS example) you are
19
given access to all the options and features of the real dialog(1) application.
23
There are essentially two versions of the console dialog program. One has
24
support for colours as well as extra widgets, while the other does not have
25
either. You can read about the colour support in the TEXT MARKUP section.
45
=head2 new( @options )
53
my $d = new( title => 'Default Title', backtitle => 'Backtitle',
54
width => 65, height => 20, listheight => 5 );
62
This is the Class Constructor method. It accepts a list of key => value pairs
63
and uses them as the defaults when interacting with the various widgets.
71
A blessed object reference of the UI::Dialog::Backend::CDialog class.
77
The (...)'s after each option indicate the default for the option. An * denotes
78
support by all the widget methods on a per-use policy defaulting to the values
79
decided during object creation.
83
=item B<debug = 0,1,2> (0)
85
=item B<literal = 0,1> (0)
87
=item B<backtitle = "backtitle"> ('') *
89
=item B<title = "title"> ('') *
91
=item B<height = \d+> (0) *
93
=item B<width = \d+> (0) *
95
=item B<beepbefore = 0,1> (0) *
97
=item B<beepafter = 0,1> (0) *
103
=head1 WIDGET METHODS
113
if ($d->yesno( text => 'A binary type question?') ) {
116
# user pressed no or cancel
125
Present the end user with a message box that has two buttons, yes and no.
133
TRUE (1) for a response of YES or FALSE (0) for anything else.
147
$d->msgbox( text => 'A simple message' );
155
Pesent the end user with a message box that has an OK button.
163
TRUE (1) for a response of OK or FALSE (0) for anything else.
177
$d->infobox( text => 'A simple 6 second message.', timeout => 6000 );
185
Pesent the end user with a message box for a limited duration of time. The
186
timeout is specified in thousandths of a second, ie: 1000 = 1 second.
194
TRUE (1) for a response of OK or FALSE (0) for anything else.
208
my $string = $d->password( text => 'Enter some (hidden) text.' );
216
Present the end user with a text input field that doesn't reveal the input
217
(except to the script) and a message.
225
a SCALAR if the response is OK and FALSE (0) for anything else.
239
my $string = $d->inputbox( text => 'Please enter some text.',
240
entry => 'this is the input field' );
248
Present the end user with a text input field and a message.
256
a SCALAR if the response is OK and FALSE (0) for anything else.
270
$d->textbox( path => '/path/to/a/text/file' );
278
Present the end user with a simple scrolling box containing the contents
279
of the given text file.
287
TRUE (1) if the response is OK and FALSE (0) for anything else.
301
my $selection1 = $d->menu( text => 'Select one:',
302
list => [ 'tag1', 'item1',
313
Present the user with a selectable list.
321
a SCALAR of the chosen tag if the response is OK and FALSE (0) for
336
my @selection = $d->checklist( text => 'Select one:',
337
list => [ 'tag1', [ 'item1', 0 ],
338
'tag2', [ 'item2', 1 ],
339
'tag3', [ 'item3', 1 ] ]
348
Present the user with a selectable checklist.
356
an ARRAY of the chosen tags if the response is OK and FALSE (0) for
371
my @data = $d->form( text => 'Select one:',
372
list => [ [ 'tag1', 1, 1 ], [ 'item1', 1, 10, 10, 10 ],
373
[ 'tag2', 2, 1 ], [ 'item2', 2, 10, 10, 10 ],
374
[ 'tag3', 3, 1 ], [ 'item3', 3, 10, 10, 10 ] ]
383
Present the user with a selectable and potentially editable form.
391
an ARRAY of the form data if the response is OK and FALSE (0) for
406
my $selection = $d->radiolist( text => 'Select one:',
407
list => [ 'tag1', [ 'item1', 0 ],
408
'tag2', [ 'item2', 1 ],
409
'tag3', [ 'item3', 0 ] ]
418
Present the user with a selectable radiolist.
426
a SCALAR of the chosen tag if the response is OK and FALSE (0) for
441
my $text = $d->fselect( path => '/path/to/a/file/or/directory' );
449
Present the user with a file selection widget preset with the given path.
457
a SCALAR if the response is OK and FALSE (0) for anything else.
471
my $text = $d->dselect( path => '/path/to/a/directory' );
479
Present the user with a file selection widget preset with the given path.
480
Unlike fselect() this widget will only return a directory selection.
488
a SCALAR if the response is OK and FALSE (0) for anything else.
502
my $date = $d->calendar( text => 'Pick a date...',
503
day => 1, month => 1, year => 1970 );
504
my ($m,$d,$y) = split(/\//,$date);
506
# or alternatively...
508
$d->calendar( text => 'Pick a date...',
509
day => 1, month => 1, year => 1970 );
510
($m,$d,$y) = $d->ra();
518
Present the user with a calendar widget preset with the given date or if
519
none is specified, use the current date.
527
a SCALAR if the response is OK and FALSE (0) for anything else.
541
my $time = $d->timebox( text => 'What time?' );
542
my ($h,$m,$s) = split(/\:/,$time);
544
# or alternatively...
546
$d->timebox( text => 'What time?',
547
hour => 10, minute => 01, second => 01 );
548
my ($h,$m,$s) = $d->ra();
556
Present the user with a time widget preset with the current time.
564
a SCALAR if the response is OK and FALSE (0) for anything else.
578
$d->tailbox( path => '/path/to/a/text/file' );
586
Present the end user with a scrolling box containing the contents
587
of the given text file. The contents of the window is constantly updated
588
in a similar manner to that of the unix tail(1) command.
596
TRUE (1) if the response is OK and FALSE (0) for anything else.
602
=head2 gauge_start( )
610
$d->gauge_start( text => 'gauge...', percentage => 1 );
618
Display a meter bar to the user. This get's the widget realized but requires
619
the use of the other gauge_*() methods for functionality.
627
TRUE (1) if the widget loaded fine and FALSE (0) for anything else.
649
Increment the meter by the given amount.
657
TRUE (1) if the widget incremented fine and FALSE (0) for anything else.
679
Decrement the meter by the given amount.
687
TRUE (1) if the widget incremented fine and FALSE (0) for anything else.
709
Set the meter bar to the given amount.
717
TRUE (1) if the widget set fine and FALSE (0) for anything else.
731
$d->gauge_text( 'string' );
739
Set the meter bar message to the given string.
747
TRUE (1) if the widget set fine and FALSE (0) for anything else.
769
End the meter bar widget process. One of the flaws with gdialog is that the
770
gauge widget does not close properly and requies the end user to close the
771
gauge window when 100% has been reached. This is the second reason why I'm
772
glad gdialog is going the way of the dodo.
780
TRUE (1) if the widget closed fine and FALSE (0) for anything else.
808
Please email the author with any bug reports. Include the name of the
809
module in the subject line.
813
Kevin C. Krinke, E<lt>kevin@krinke.caE<gt>
815
=head1 COPYRIGHT AND LICENSE
817
Copyright (C) 2013 Kevin C. Krinke <kevin@krinke.ca>
819
This library is free software; you can redistribute it and/or
820
modify it under the terms of the GNU Lesser General Public
821
License as published by the Free Software Foundation; either
822
version 2.1 of the License, or (at your option) any later version.
824
This library is distributed in the hope that it will be useful,
825
but WITHOUT ANY WARRANTY; without even the implied warranty of
826
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
827
Lesser General Public License for more details.
829
You should have received a copy of the GNU Lesser General Public
830
License along with this library; if not, write to the Free Software
831
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA