Curses
view release on metacpan or search on metacpan
sub AUTOLOAD {
my $N = $AUTOLOAD;
$N =~ s/^.*:://;
croak
"No '$N' in Curses module. This could be because the Curses " .
"library for which it was built does not provide the associated " .
"functions. ";
}
sub printw($@) {
my ($format, @substitutions) = @_;
addstring(sprintf($format, @substitutions));
}
tie $LINES, Curses::Vars, 1;
tie $COLS, Curses::Vars, 2;
tie $stdscr, Curses::Vars, 3;
tie $curscr, Curses::Vars, 4;
Makefile.PL view on Meta::CPAN
'' => undef
};
###
## You shouldn't need to change anything below
#
my $TRUE = 1; my $FALSE = 0;
sub nCursesIsInstalled() {
if (-f('/usr/include/ncurses/ncurses.h')) {
return $TRUE;
} elsif (-f('/usr/include/ncurses.h')) {
return $TRUE;
} else {
return $FALSE;
}
}
sub bsdIsInstalled() {
if (-f('/usr/include/curses/curses.h')) {
return $TRUE;
} elsif (-f('/usr/include/curses.h')) {
return $TRUE;
} else {
return $FALSE;
}
}
sub chooseLibraryType($$) {
my ($typeList, $libtypR) = @_;
#-----------------------------------------------------------------------------
# Assuming this is a platform on which there may be multiple versions of
# Curses, choose one.
#
# Return the choice as $$libtypR.
#
# We prefer Ncurses, so choose that if it appears to be installed.
# If it doesn't, but BSD appears to be installed, we choose that. If
# we don't see either, we choose $libtypDefault.
Makefile.PL view on Meta::CPAN
$$libtypR = 'ncurses';
} elsif ($typeList->{'bsd'} && bsdIsInstalled()) {
$$libtypR = 'bsd';
} else {
$$libtypR = $typeList->{'default'};
}
}
sub guessAtCursesLocation($$$) {
my ($libtypR, $incR, $libsR) = @_;
#-----------------------------------------------------------------------------
# Return as $$libtypR the type of Curses library we should use, e.g.
# 'ncurses', 'ncursesw' or 'bsd'. May be undefined if we don't think
# we have to choose between those on this system.
#
# Return as $$incR the -I option we think is appropriate to get the
# Curses interface header files.
#
# Return as $$libsR the -L and -l options we think are needed to link
Makefile.PL view on Meta::CPAN
if (defined($$libtypR)) {
print(" Curses type: $$libtypR");
} else {
print(" Curses type: irrelevant");
}
print("\n");
}
sub defaultLibTypeForOs($) {
my ($osname) = @_;
#-----------------------------------------------------------------------------
# Return the default library type for OS named '$osname'; if we don't think
# there is a choice of library type on this OS, return undef.
#-----------------------------------------------------------------------------
my $libType;
my $guess = $guess_cfg->{$OSNAME};
if (ref $guess eq 'HASH') {
Makefile.PL view on Meta::CPAN
'bsd' => 'bsd',
'ncurses' => 'ncurses',
'ncursesw' => 'ncurses',
'sysv' => 'sysv',
'visualc' => 'visualc',
'borland' => 'borland',
);
sub makeCConfigH($) {
my ($libType) = @_;
#-----------------------------------------------------------------------------
# $libType is the kind of Curses library we are using - e.g. 'bsd',
# 'ncurses', or 'ncursesw'. It may be undefined if there is no
# choice on this system.
#-----------------------------------------------------------------------------
print qq{Making a guess for "c-config.h"...\n};
my $libClass;
Makefile.PL view on Meta::CPAN
exit 1;
} else {
system($sys);
}
}
}
sub guessPanelMenuFormLibs($$$$$) {
my ($ncursesLibSearch, $libType, $panelLibsR, $menuLibsR, $formLibsR) = @_;
my ($panelLibGuess, $menuLibGuess, $formLibGuess);
if (defined($libType) && $libType eq "ncursesw") {
$panelLibGuess = -lpanelw;
$menuLibGuess = -lmenuw;
$formLibGuess = -lformw;
} else {
sub fatal {
clrtobot(0, 0);
addstr(0, 0, "@_\n");
refresh();
sleep 2;
die("Fatal error");
}
sub driveForm($$) {
my ($fwinR, $formR) = @_;
while (1) {
my $ch = getch($fwinR);
if ($ch eq KEY_UP) {
form_driver($formR, REQ_PREV_FIELD);
} elsif ($ch eq KEY_DOWN or $ch eq "\t" or
$ch eq "\r" or $ch eq "\n") {
form_driver($formR, REQ_NEXT_FIELD);
} elsif ($ch eq KEY_LEFT) {
} elsif ($ch =~ /^\S$/) {
form_driver($formR, ord($ch));
} else {
beep();
}
}
}
sub makeFields() {
my $fieldListR = [
[ 'L', 0, 0, 0, 8, "Form" ],
[ 'L', 0, 0, 2, 0, "First Name" ],
[ 'F', 1, 15, 2, 12, "F Name" ],
[ 'L', 0, 0, 3, 0, "Last Name" ],
[ 'F', 1, 15, 3, 12, "L Name" ],
[ 'L', 0, 0, 5, 8, "Form (pt 2)" ],
[ 'L', 0, 0, 7, 0, "# Tuits" ],
[ 'F', 1, 5, 7, 12, "Tuits" ],
set_field_back($fieldR, A_UNDERLINE);
}
push(@fieldRList, $fieldR);
}
return @fieldRList;
}
sub interpretForm($$$) {
my ($cFieldRListR, $firstNameR, $lastNameR) = @_;
$$firstNameR = field_buffer($cFieldRListR->[2], 0);
$$lastNameR = field_buffer($cFieldRListR->[4], 0);
}
sub demo($$) {
my ($firstNameR, $lastNameR) = @_;
noecho();
eval { new_form() };
if ($@ =~ m{not defined in your Curses library}) {
print STDERR "Curses was not compiled with form function.\n";
exit 1;
}
use Data::Dumper;
use I18N::Langinfo;
use Encode;
use Curses;
sub test($$) {
my ($win, $argsR) = @_;
my $charset = I18N::Langinfo::langinfo(I18N::Langinfo::CODESET());
my ($function, $arg) = @{$argsR};
if (!defined($function)) {
die("You must give a function name as the first argument");
}
## Thanks to Raphael Manfredi and the other contributors of dist-3.0.
##
## VMS patches thanks to Peter Prymmer <pvhp@forte.com>
use strict;
use warnings;
use English;
my $verbose;
sub makeCompileCommand($) {
my ($compileR) = @_;
#-----------------------------------------------------------------------------
# A template for a compile command that can test for existence of some
# symbol in this system's Curses library.
#
# The template is a shell command containing some variables
# to be substituted to make a real executable command.
#
# Those variables are:
#
if ($compile =~ m{#.+#}) {
die "OOPS: internal error constructing a compile command. " .
"We failed to substitute for a #xxx# substitution variable " .
"and thus ended up with this: '$compile'\n";
}
$$compileR = $compile;
}
sub completeCompileCmd($$$$) {
my ($template, $sym, $args, $file) = @_;
#-----------------------------------------------------------------------------
# The complete ready-to-execute compile command.
#
# $template is a template for the compile command, with some variables in it
# that need to be replaced based on the values of $sym, $args, and $file.
# -----------------------------------------------------------------------------
my $retval;
$retval = $template; # initial value
my $symargs = $sym . (defined($args) ? $args : '');
$retval =~ s{_C_SYM_}{$symargs}ge;
$retval =~ s{_C_FILE_}{$file}g;
return $retval;
}
sub writeHeader($) {
my ($cursesDefFh) = @_;
print $cursesDefFh <<'EOHDR';
/*============================================================================
CursesDef.h
==============================================================================
This file defines C macros that tell which Curses functions are available
(in the C Curses library) on the target platform and some information about
what variant is implemented.
}
my %tstfile = qw( E testsym
I testint
V testsym
T testtyp);
sub testCompile($$$$$$) {
my ($action, $sym, $args, $compileCmdTemplate, $logFh, $compFailedR) = @_;
#-----------------------------------------------------------------------------
# Do a test compile to determine if symbol $sym exists in this system's
# Curses library.
#
# Use the compile command template $compileCmdTemplate to do this,
# filling in variables _C_SYM and _C_FILE in this template appropriately.
#
# The source file we compile is that given my %tstfile for the action
# $action.
( run in 0.757 second using v1.01-cache-2.11-cpan-65fba6d93b7 )