CursesWidgets
view release on metacpan or search on metacpan
--POD fixes
--Compatibility fix for curses without attr_get/attr_set functions
--Introduction of the multi-column list box
ListBox:
--Fixed VALUE initialisation bug when when in multi-select mode
--Fixed cursor position bug for large jumps down the last (past the
viewable window)
--Changed arrow placement to go by window bounds to make inherited
behaviour more predictable
--Added printable character navigation (thanks to Eric Lenio)
Menu:
--Checking for defined code reference before attempting to execute
TextMemo:
--Changed arrow placement to go by window bounds to make inherited
behaviour more predictable
----------------------------
revision 1.996 locked by: corliss;
date: 2002/11/03 23:25:01; author: corliss; state: Exp; lines: +450 -75
--Added test_colour function
--Added DEFAULTFG and DEFAULTBG scalars
--Removed hard coded black:white colour pair, now detecting
--Entire widget is now underlined correctly in non-borderd mode
--VALUE now holds selected items instead of SELECTED
TextField & TextMemo:
--Fixed underline mode to correctly underline entire field, instead
of just text
--Added regex to accept only printable characters as part of the value
--Fixed bugs in cursor placement and scrolling
----------------------------
revision 1.995 locked by: corliss;
date: 2002/10/22 18:00:23; author: corliss;
--Added Menu and Label widgets
--Auto-applying the list length based on list entries was getting lost
at times in the ComboBox. Fixed.
--Popup wouldn't show up in the right location on combos on newwins that
didn't start at 0,0. Fixed.
--VALUE in ListBox wasn't getting updated. Fixed.
----------------------------
revision 1.994
date: 2002/10/22 17:56:08; author: corliss;
--Added shift+tab support for execute method
--Pod updates
Widgets.pm
Widgets/ButtonSet.pm
Widgets/Calendar.pm
Widgets/ComboBox.pm
Widgets/Label.pm
Widgets/ListBox.pm
Widgets/ListBox/MultiColumn.pm
Widgets/Menu.pm
Widgets/ProgressBar.pm
Widgets/TextField.pm
Widgets/TextMemo.pm
Widgets/Tutorial.pod
Widgets/Tutorial/Creation.pod
Makefile.PL
test.pl
CHANGELOG
README
LICENSE
=item Calendar (Curses::Widgets::Calendar)
=item Combo-Box (Curses::Widgets::ComboBox)
=item Label (Curses::Widgets::Label)
=item List Box (Curses::Widgets::ListBox)
=item Multicolumn List Box (Curses::Widgets::ListBox::MultiColumn)
=item Menu (Curses::Widgets::Menu)
=item Progress Bar (Curses::Widgets::ProgressBar)
=item Text Field (Curses::Widgets::TextField)
=item Text Memo (Curses::Widgets::TextMemo)
=back
The following tutorials are available:
Widgets/Menu.pm view on Meta::CPAN
# Curses::Widgets::Menu.pm -- Menu Widgets
#
# (c) 2001, Arthur Corliss <corliss@digitalmages.com>
#
# $Id: Menu.pm,v 1.103 2002/11/14 01:26:34 corliss Exp corliss $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#####################################################################
=head1 NAME
Curses::Widgets::Menu - Menu Widgets
=head1 MODULE VERSION
$Id: Menu.pm,v 1.103 2002/11/14 01:26:34 corliss Exp corliss $
=head1 SYNOPSIS
use Curses::Widgets::Menu;
$menu = Curses::Widgets::Menu->new({
COLUMNS => 10,
INPUTFUNC => \&scankey,
FOREGROUND => undef,
BACKGROUND => 'black',
FOCUSSWITCH => "\t",
X => 1,
Y => 1,
MENUS => {
MENUORDER => [qw(File)],
File => {
Widgets/Menu.pm view on Meta::CPAN
=item Curses
=item Curses::Widgets
=item Curses::Widgets::ListBox
=back
=head1 DESCRIPTION
Curses::Widgets::Menu provides simplified OO access to menus. Each item in a
menu can be tied to a subroutine reference which is called when selected.
=cut
#####################################################################
#
# Environment definitions
#
#####################################################################
package Curses::Widgets::Menu;
use strict;
use vars qw($VERSION @ISA);
use Carp;
use Curses;
use Curses::Widgets;
use Curses::Widgets::ListBox;
($VERSION) = (q$Revision: 1.103 $ =~ /(\d+(?:\.(\d+))+)/);
@ISA = qw(Curses::Widgets);
Widgets/Menu.pm view on Meta::CPAN
#####################################################################
#
# Module code follows
#
#####################################################################
=head1 METHODS
=head2 new (inherited from Curses::Widgets)
$menu = Curses::Widgets::Menu->new({
INPUTFUNC => \&scankey,
FOREGROUND => undef,
BACKGROUND => 'black',
FOCUSSWITCH => "\t",
MENUS => {
MENUORDER => [qw(File)],
File => {
ITEMORDER => [qw(Save Quit)],
Save => \&Save,
Quit => \&Quit,
},
CURSORPOS => 'File',
BORDER => 1,
});
The new method instantiates a new Menu object. The only mandatory
key/value pairs in the configuration hash are B<X> and B<Y>. All others
have the following defaults:
Key Default Description
============================================================
INPUTFUNC \&scankey Function to use to scan for keystrokes
FOREGROUND undef Default foreground colour
BACKGROUND 'black' Default background colour
FOCUSSWITCH "\t" Characters which signify end of input
MENUS {} Menu structure
CURSORPOS '' Current position of the cursor
BORDER 0 Avoid window borders
The B<MENUS> option is a hash of hashes, with each hash a separate menu, and
the constituent hashes being a Entry/Function pairs. Each hash requires a
special key/value pair that determines the order of the items when displayed.
Each item is separated by two spaces.
=cut
sub _conf {
# Validates and initialises the new Menu object.
#
# Internal use only.
my $self = shift;
my %conf = (
INPUTFUNC => \&scankey,
FOREGROUND => undef,
BACKGROUND => 'black',
FOCUSSWITCH => "\t",
MENUS => {MENUORDER => []},
Widgets/Menu.pm view on Meta::CPAN
$item = $$menus{MENUORDER}[$i];
# Process special keys
if ($in eq KEY_LEFT) {
--$i;
$i = $#{$$menus{MENUORDER}} if $i < 0;
} elsif ($in eq KEY_RIGHT) {
++$i;
$i = 0 if $i > $#{$$menus{MENUORDER}};
# Display the Menu
} elsif ($in eq KEY_DOWN || $in eq "\n") {
# Calculate and set popup geometry
$x = 0;
for (0..$i) {
$x += (length($$menus{MENUORDER}[$i]) + 2) if $_ != $i;
}
$x += 1 if $$conf{BORDER};
$x += $self->{BEGYX}->[1];
$y = $$conf{BORDER} ? 2 : 1;
use strict;
use Curses;
use Curses::Widgets; # Included to import select_colour & scankey
use Curses::Widgets::TextField;
use Curses::Widgets::ButtonSet;
use Curses::Widgets::ProgressBar;
use Curses::Widgets::TextMemo;
use Curses::Widgets::ListBox;
use Curses::Widgets::Calendar;
use Curses::Widgets::ComboBox;
use Curses::Widgets::Menu;
use Curses::Widgets::Label;
#####################################################################
#
# Set up the environment
#
#####################################################################
my ($mwh, $key, $i, $p);
my (@widgets, @descriptions);
main_win();
comment_box(<< '__EOF__');
Welcome to the Curses::Widgets Test Script!
Press any key to begin.
__EOF__
$key = scankey($mwh);
# Create each of the widgets beforehand
$widgets[0] = Curses::Widgets::Menu->new({
FOREGROUND => 'white',
BACKGROUND => 'green',
BORDER => 1,
CURSORPOS => [qw(File)],
MENUS => {
MENUORDER => [qw(File Help)],
File => {
ITEMORDER => [qw(Open Save Exit)],
Open => sub { 1 },
Save => sub { 1 },
},
Help => {
ITEMORDER => [qw(Help About)],
Help => sub { 1 },
About => sub { 1 },
},
},
});
$descriptions[0] = << '__EOF__';
Curses::Widgets::Menu -- Menus
Use the arrow keys to navigate, and <ESC> to exit a menu without selecting anything. Use <TAB> to move to the next widget.
__EOF__
$widgets[1] = Curses::Widgets::ButtonSet->new({
Y => 2,
X => 2,
FOREGROUND => 'white',
BACKGROUND => 'black',
BORDER => 0,
( run in 0.546 second using v1.01-cache-2.11-cpan-49f99fa48dc )