Import p5-Term-Screen-1.02

--
Term::Screen is a very simple screen positioning module
that should work wherever "Term::Cap" does. It is set up
for Unix using stty's but these dependences are isolated
by evals in the "new" constructor.

brad@ ok
This commit is contained in:
margarida 2003-01-27 23:34:37 +00:00
parent 795d6c38b2
commit 789b325b54
33 changed files with 3601 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# $OpenBSD: Makefile,v 1.1.1.1 2003/01/27 23:34:37 margarida Exp $
COMMENT= "positioning screen based module"
DISTNAME= Term-Screen-1.02
PKGNAME= p5-${DISTNAME}
CATEGORIES= devel perl5
MAINTAINER= Margarida Sequeira <margarida@openbsd.org>
# Artistic
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=Term/}
CONFIGURE_STYLE= perl
.include <bsd.port.mk>

View File

@ -0,0 +1,3 @@
MD5 (Term-Screen-1.02.tar.gz) = 16495a66cf592840716c47898e6a6882
RMD160 (Term-Screen-1.02.tar.gz) = 8a9bdacdc57bfc04ed3420a6cb2f9d769e962bac
SHA1 (Term-Screen-1.02.tar.gz) = 17d0cbe3336f0c9ec8928857d4d93ea474145062

View File

@ -0,0 +1,6 @@
Term::Screen is a very simple screen positioning module
that should work wherever "Term::Cap" does. It is set up
for Unix using stty's but these dependences are isolated
by evals in the "new" constructor. Thus you may create a
child module implementing Screen with MS-DOS, ioctl, or
other means to get raw and unblocked input.

View File

@ -0,0 +1,3 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2003/01/27 23:34:37 margarida Exp $
${P5SITE}/Term/Screen.pm
man/man3p/Term::Screen.3p

View File

@ -0,0 +1,5 @@
MANIFEST
README
Screen.pm
Makefile.PL
test.pl

View File

@ -0,0 +1,687 @@
# This Makefile is for the Term::Screen extension to perl.
#
# It was generated automatically by MakeMaker version
# 6.03 (Revision: 1.6) from the contents of
# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
#
# ANY CHANGES MADE HERE WILL BE LOST!
#
# MakeMaker ARGV: (q[PREFIX=${DESTDIR}/usr/local], q[INSTALLSITELIB=${DESTDIR}/usr/local/libdata/perl5/site_perl], q[INSTALLSITEARCH=${INSTALLSITELIB}/sparc64-openbsd], q[INSTALLPRIVLIB=${DESTDIR}/usr/./libdata/perl5], q[INSTALLARCHLIB=${INSTALLPRIVLIB}/sparc64-openbsd], q[INSTALLMAN1DIR=${DESTDIR}/usr/local/man/man1], q[INSTALLMAN3DIR=${DESTDIR}/usr/local/man/man3p], q[INSTALLBIN=${PREFIX}/bin], q[INSTALLSCRIPT=${INSTALLBIN}])
#
# MakeMaker Parameters:
# NAME => q[Term::Screen]
# PREREQ_PM => { Term::Cap=>q[0] }
# VERSION_FROM => q[Screen.pm]
# --- MakeMaker post_initialize section:
# --- MakeMaker const_config section:
# These definitions are from config.sh (via /usr/libdata/perl5/sparc64-openbsd/5.8.0/Config.pm)
# They may have been overridden via Makefile.PL or on the command line
AR = ar
CC = cc
CCCDLFLAGS = -DPIC -fPIC
CCDLFLAGS = -Wl,-R/usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE
DLEXT = so
DLSRC = dl_dlopen.xs
LD = cc
LDDLFLAGS = -shared -fPIC
LDFLAGS = -Wl,-E
LIBC = /usr/lib/libc.so.29.0
LIB_EXT = .a
OBJ_EXT = .o
OSNAME = openbsd
OSVERS = 3.2
RANLIB = ranlib
SO = so
EXE_EXT =
FULL_AR = /usr/bin/ar
# --- MakeMaker constants section:
AR_STATIC_ARGS = cr
NAME = Term::Screen
DISTNAME = Term-Screen
NAME_SYM = Term_Screen
VERSION = 1.02
VERSION_SYM = 1_02
XS_VERSION = 1.02
INST_ARCHLIB = blib/arch
INST_SCRIPT = blib/script
INST_BIN = blib/bin
INST_LIB = blib/lib
INSTALLDIRS = site
PREFIX = ${DESTDIR}/usr/local
SITEPREFIX = ${DESTDIR}/usr/local
VENDORPREFIX = ${DESTDIR}/usr/local
INSTALLPRIVLIB = ${DESTDIR}/usr/./libdata/perl5
INSTALLSITELIB = ${DESTDIR}/usr/local/libdata/perl5/site_perl
INSTALLVENDORLIB = ${DESTDIR}/usr/local/lib/perl5
INSTALLARCHLIB = ${INSTALLPRIVLIB}/sparc64-openbsd
INSTALLSITEARCH = ${INSTALLSITELIB}/sparc64-openbsd
INSTALLVENDORARCH = ${DESTDIR}/usr/local/lib/perl5/5.8.0/sparc64-openbsd
INSTALLBIN = ${PREFIX}/bin
INSTALLSITEBIN = ${DESTDIR}/usr/local/bin
INSTALLVENDORBIN = ${DESTDIR}/usr/local/bin
INSTALLSCRIPT = ${INSTALLBIN}
PERL_LIB = /usr/libdata/perl5
PERL_ARCHLIB = /usr/libdata/perl5/sparc64-openbsd/5.8.0
SITELIBEXP = /usr/local/libdata/perl5/site_perl
SITEARCHEXP = /usr/local/libdata/perl5/site_perl/sparc64-openbsd
LIBPERL_A = libperl.a
FIRST_MAKEFILE = Makefile
MAKE_APERL_FILE = Makefile.aperl
PERLMAINCC = $(CC)
PERL_INC = /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE
PERL = /usr/bin/perl
FULLPERL = /usr/bin/perl
PERLRUN = $(PERL)
FULLPERLRUN = $(FULLPERL)
PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
ABSPERL = $(PERL)
ABSPERLRUN = $(ABSPERL)
ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
FULL_AR = /usr/bin/ar
PERL_CORE = 0
NOOP = $(SHELL) -c true
NOECHO = @
VERSION_MACRO = VERSION
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
MAKEMAKER = /usr/libdata/perl5/ExtUtils/MakeMaker.pm
MM_VERSION = 6.03
# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
FULLEXT = Term/Screen
BASEEXT = Screen
PARENT_NAME = Term
DLBASE = $(BASEEXT)
VERSION_FROM = Screen.pm
OBJECT =
LDFROM = $(OBJECT)
LINKTYPE = dynamic
# Handy lists of source code files:
XS_FILES=
C_FILES =
O_FILES =
H_FILES =
MAN1PODS =
MAN3PODS = Screen.pm
INST_MAN1DIR = blib/man1
MAN1EXT = 1
INSTALLMAN1DIR = ${DESTDIR}/usr/local/man/man1
INSTALLSITEMAN1DIR = ${DESTDIR}/usr/local/man/man$(MAN1EXT)
INSTALLVENDORMAN1DIR = ${DESTDIR}/usr/local/man/man$(MAN1EXT)
INST_MAN3DIR = blib/man3
MAN3EXT = 3p
INSTALLMAN3DIR = ${DESTDIR}/usr/local/man/man3p
INSTALLSITEMAN3DIR = ${DESTDIR}/usr/local/man/man$(MAN3EXT)
INSTALLVENDORMAN3DIR = ${DESTDIR}/usr/local/man/man$(MAN3EXT)
PERM_RW = 644
PERM_RWX = 755
# work around a famous dec-osf make(1) feature(?):
makemakerdflt: all
.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
# some make implementations will delete the Makefile when we rebuild it. Because
# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
# does so. Our milage may vary.
# .PRECIOUS: Makefile # seems to be not necessary anymore
.PHONY: all config static dynamic test linkext manifest
# Where is the Config information that we are using/depend on
CONFIGDEP = $(PERL_ARCHLIB)/Config.pm $(PERL_INC)/config.h
# Where to put things:
INST_LIBDIR = $(INST_LIB)/Term
INST_ARCHLIBDIR = $(INST_ARCHLIB)/Term
INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
INST_STATIC =
INST_DYNAMIC =
INST_BOOT =
EXPORT_LIST =
PERL_ARCHIVE =
PERL_ARCHIVE_AFTER =
TO_INST_PM = Screen.pm
PM_TO_BLIB = Screen.pm \
blib/lib/Term/Screen.pm
# --- MakeMaker tool_autosplit section:
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
# --- MakeMaker tool_xsubpp section:
# --- MakeMaker tools_other section:
SHELL = /bin/sh
CHMOD = chmod
CP = cp
LD = cc
MV = mv
NOOP = $(SHELL) -c true
RM_F = rm -f
RM_RF = rm -rf
TEST_F = test -f
TOUCH = touch
UMASK_NULL = umask 0
DEV_NULL = > /dev/null 2>&1
# The following is a portable way to say mkdir -p
# To see which directories are created, change the if 0 to if 1
MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath
# This helps us to minimize the effect of the .exists files A yet
# better solution would be to have a stable file in the perl
# distribution with a timestamp of zero. But this solution doesn't
# need any changes to the core distribution and works with older perls
EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime
# Here we warn users that an old packlist file was found somewhere,
# and that they should call some uninstall routine
WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \
-e 'print "WARNING: I have found an old package in\n";' \
-e 'print "\t$$ARGV[0].\n";' \
-e 'print "Please make sure the two installations are not conflicting\n";'
UNINST=0
VERBINST=0
MOD_INSTALL = $(PERL) "-I$(INST_LIB)" "-I$(PERL_LIB)" "-MExtUtils::Install" \
-e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \
-e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \
-e 'print "=over 4";' \
-e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \
-e 'print "=back";'
UNINSTALL = $(PERLRUN) "-MExtUtils::Install" \
-e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \
-e 'print " packlist above carefully.\n There may be errors. Remove the";' \
-e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"'
# --- MakeMaker dist section:
ZIPFLAGS = -r
TO_UNIX = @$(NOOP)
TAR = tar
POSTOP = @$(NOOP)
ZIP = zip
DIST_DEFAULT = tardist
CI = ci -u
SHAR = shar
COMPRESS = gzip --best
DIST_CP = best
PREOP = @$(NOOP)
TARFLAGS = cvf
DISTVNAME = $(DISTNAME)-$(VERSION)
SUFFIX = .gz
RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
# --- MakeMaker macro section:
# --- MakeMaker depend section:
# --- MakeMaker cflags section:
# --- MakeMaker const_loadlibs section:
# --- MakeMaker const_cccmd section:
# --- MakeMaker post_constants section:
# --- MakeMaker pasthru section:
PASTHRU = LIB="$(LIB)"\
LIBPERL_A="$(LIBPERL_A)"\
LINKTYPE="$(LINKTYPE)"\
PREFIX="$(PREFIX)"\
OPTIMIZE="$(OPTIMIZE)"\
PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\
PASTHRU_INC="$(PASTHRU_INC)"
# --- MakeMaker c_o section:
# --- MakeMaker xs_c section:
# --- MakeMaker xs_o section:
# --- MakeMaker top_targets section:
all :: pure_all manifypods
@$(NOOP)
pure_all :: config pm_to_blib subdirs linkext
@$(NOOP)
subdirs :: $(MYEXTLIB)
@$(NOOP)
config :: Makefile $(INST_LIBDIR)/.exists
@$(NOOP)
config :: $(INST_ARCHAUTODIR)/.exists
@$(NOOP)
config :: $(INST_AUTODIR)/.exists
@$(NOOP)
$(INST_AUTODIR)/.exists :: /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h
@$(MKPATH) $(INST_AUTODIR)
@$(EQUALIZE_TIMESTAMP) /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h $(INST_AUTODIR)/.exists
-@$(CHMOD) $(PERM_RWX) $(INST_AUTODIR)
$(INST_LIBDIR)/.exists :: /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h
@$(MKPATH) $(INST_LIBDIR)
@$(EQUALIZE_TIMESTAMP) /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h $(INST_LIBDIR)/.exists
-@$(CHMOD) $(PERM_RWX) $(INST_LIBDIR)
$(INST_ARCHAUTODIR)/.exists :: /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h
@$(MKPATH) $(INST_ARCHAUTODIR)
@$(EQUALIZE_TIMESTAMP) /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h $(INST_ARCHAUTODIR)/.exists
-@$(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR)
config :: $(INST_MAN3DIR)/.exists
@$(NOOP)
$(INST_MAN3DIR)/.exists :: /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h
@$(MKPATH) $(INST_MAN3DIR)
@$(EQUALIZE_TIMESTAMP) /usr/libdata/perl5/sparc64-openbsd/5.8.0/CORE/perl.h $(INST_MAN3DIR)/.exists
-@$(CHMOD) $(PERM_RWX) $(INST_MAN3DIR)
help:
perldoc ExtUtils::MakeMaker
# --- MakeMaker linkext section:
linkext :: $(LINKTYPE)
@$(NOOP)
# --- MakeMaker dlsyms section:
# --- MakeMaker dynamic section:
## $(INST_PM) has been moved to the all: target.
## It remains here for awhile to allow for old usage: "make dynamic"
#dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT)
@$(NOOP)
# --- MakeMaker dynamic_bs section:
BOOTSTRAP =
# --- MakeMaker dynamic_lib section:
# --- MakeMaker static section:
## $(INST_PM) has been moved to the all: target.
## It remains here for awhile to allow for old usage: "make static"
#static :: Makefile $(INST_STATIC) $(INST_PM)
static :: Makefile $(INST_STATIC)
@$(NOOP)
# --- MakeMaker static_lib section:
# --- MakeMaker manifypods section:
POD2MAN_EXE = /usr/bin/pod2man
POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \
-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "Makefile";' \
-e 'print "Manifying $$m{$$_}\n";' \
-e 'system(q[$(PERLRUN) $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\047t install $$m{$$_}\n";' \
-e 'chmod(oct($(PERM_RW)), $$m{$$_}) or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
manifypods : pure_all Screen.pm
@$(POD2MAN) \
Screen.pm \
$(INST_MAN3DIR)/Term::Screen.$(MAN3EXT)
# --- MakeMaker processPL section:
# --- MakeMaker installbin section:
# --- MakeMaker subdirs section:
# none
# --- MakeMaker clean section:
# Delete temporary files but do not touch installed files. We don't delete
# the Makefile here so a later make realclean still has a makefile to use.
clean ::
-rm -rf ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core
-mv Makefile Makefile.old $(DEV_NULL)
# --- MakeMaker realclean section:
# Delete temporary files (via clean) and also delete installed files
realclean purge :: clean
rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR)
rm -rf $(DISTVNAME)
rm -f blib/lib/Term/Screen.pm
rm -rf Makefile Makefile.old
# --- MakeMaker dist_basics section:
distclean :: realclean distcheck
$(NOECHO) $(NOOP)
distcheck :
$(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
skipcheck :
$(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
manifest :
$(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
veryclean : realclean
$(RM_F) *~ *.orig */*~ */*.orig
# --- MakeMaker dist_core section:
dist : $(DIST_DEFAULT)
@$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \
-e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "Makefile";'
tardist : $(DISTVNAME).tar$(SUFFIX)
zipdist : $(DISTVNAME).zip
$(DISTVNAME).tar$(SUFFIX) : distdir
$(PREOP)
$(TO_UNIX)
$(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(COMPRESS) $(DISTVNAME).tar
$(POSTOP)
$(DISTVNAME).zip : distdir
$(PREOP)
$(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(POSTOP)
uutardist : $(DISTVNAME).tar$(SUFFIX)
uuencode $(DISTVNAME).tar$(SUFFIX) \
$(DISTVNAME).tar$(SUFFIX) > \
$(DISTVNAME).tar$(SUFFIX)_uu
shdist : distdir
$(PREOP)
$(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
$(RM_RF) $(DISTVNAME)
$(POSTOP)
# --- MakeMaker dist_dir section:
distdir :
$(RM_RF) $(DISTVNAME)
$(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
# --- MakeMaker dist_test section:
disttest : distdir
cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
# --- MakeMaker dist_ci section:
ci :
$(PERLRUN) "-MExtUtils::Manifest=maniread" \
-e "@all = keys %{ maniread() };" \
-e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \
-e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
# --- MakeMaker install section:
install :: all pure_install doc_install
install_perl :: all pure_perl_install doc_perl_install
install_site :: all pure_site_install doc_site_install
install_vendor :: all pure_vendor_install doc_vendor_install
pure_install :: pure_$(INSTALLDIRS)_install
doc_install :: doc_$(INSTALLDIRS)_install
@echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
pure__install : pure_site_install
@echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
doc__install : doc_site_install
@echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
pure_perl_install ::
@$(MOD_INSTALL) \
read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \
write $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(INSTALLPRIVLIB) \
$(INST_ARCHLIB) $(INSTALLARCHLIB) \
$(INST_BIN) $(INSTALLBIN) \
$(INST_SCRIPT) $(INSTALLSCRIPT) \
$(INST_MAN1DIR) $(INSTALLMAN1DIR) \
$(INST_MAN3DIR) $(INSTALLMAN3DIR)
@$(WARN_IF_OLD_PACKLIST) \
$(SITEARCHEXP)/auto/$(FULLEXT)
pure_site_install ::
@$(MOD_INSTALL) \
read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \
write $(INSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(INSTALLSITELIB) \
$(INST_ARCHLIB) $(INSTALLSITEARCH) \
$(INST_BIN) $(INSTALLSITEBIN) \
$(INST_SCRIPT) $(INSTALLSCRIPT) \
$(INST_MAN1DIR) $(INSTALLSITEMAN1DIR) \
$(INST_MAN3DIR) $(INSTALLSITEMAN3DIR)
@$(WARN_IF_OLD_PACKLIST) \
$(PERL_ARCHLIB)/auto/$(FULLEXT)
pure_vendor_install ::
@$(MOD_INSTALL) \
$(INST_LIB) $(INSTALLVENDORLIB) \
$(INST_ARCHLIB) $(INSTALLVENDORARCH) \
$(INST_BIN) $(INSTALLVENDORBIN) \
$(INST_SCRIPT) $(INSTALLSCRIPT) \
$(INST_MAN1DIR) $(INSTALLVENDORMAN1DIR) \
$(INST_MAN3DIR) $(INSTALLVENDORMAN3DIR)
doc_perl_install ::
-@$(MKPATH) $(INSTALLARCHLIB)
-@$(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLPRIVLIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(INSTALLARCHLIB)/perllocal.pod
doc_site_install ::
-@$(MKPATH) $(INSTALLARCHLIB)
-@$(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLSITELIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(INSTALLSITEARCH)/perllocal.pod
doc_vendor_install ::
uninstall :: uninstall_from_$(INSTALLDIRS)dirs
uninstall_from_perldirs ::
@$(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist
uninstall_from_sitedirs ::
@$(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist
# --- MakeMaker force section:
# Phony target to force checking subdirectories.
FORCE:
@$(NOOP)
# --- MakeMaker perldepend section:
# --- MakeMaker makefile section:
# We take a very conservative approach here, but it\'s worth it.
# We move Makefile to Makefile.old here to avoid gnu make looping.
Makefile : Makefile.PL $(CONFIGDEP)
@echo "Makefile out-of-date with respect to $?"
@echo "Cleaning current config before rebuilding Makefile..."
-@$(RM_F) Makefile.old
-@$(MV) Makefile Makefile.old
-$(MAKE) -f Makefile.old clean $(DEV_NULL) || $(NOOP)
$(PERLRUN) Makefile.PL "PREFIX=${DESTDIR}/usr/local" "INSTALLSITELIB=${DESTDIR}/usr/local/libdata/perl5/site_perl" "INSTALLSITEARCH=${INSTALLSITELIB}/sparc64-openbsd" "INSTALLPRIVLIB=${DESTDIR}/usr/./libdata/perl5" "INSTALLARCHLIB=${INSTALLPRIVLIB}/sparc64-openbsd" "INSTALLMAN1DIR=${DESTDIR}/usr/local/man/man1" "INSTALLMAN3DIR=${DESTDIR}/usr/local/man/man3p" "INSTALLBIN=${PREFIX}/bin" "INSTALLSCRIPT=${INSTALLBIN}"
@echo "==> Your Makefile has been rebuilt. <=="
@echo "==> Please rerun the make command. <=="
false
# --- MakeMaker staticmake section:
# --- MakeMaker makeaperl section ---
MAP_TARGET = perl
FULLPERL = /usr/bin/perl
$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
$(MAKE) -f $(MAKE_APERL_FILE) $@
$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
@echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
@$(PERLRUNINST) \
Makefile.PL DIR= \
MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= \
PREFIX=${DESTDIR}/usr/local \
INSTALLSITELIB=${DESTDIR}/usr/local/libdata/perl5/site_perl \
INSTALLSITEARCH=${INSTALLSITELIB}/sparc64-openbsd \
INSTALLPRIVLIB=${DESTDIR}/usr/./libdata/perl5 \
INSTALLARCHLIB=${INSTALLPRIVLIB}/sparc64-openbsd \
INSTALLMAN1DIR=${DESTDIR}/usr/local/man/man1 \
INSTALLMAN3DIR=${DESTDIR}/usr/local/man/man3p \
INSTALLBIN=${PREFIX}/bin \
INSTALLSCRIPT=${INSTALLBIN}
# --- MakeMaker test section:
TEST_VERBOSE=0
TEST_TYPE=test_$(LINKTYPE)
TEST_FILE = test.pl
TEST_FILES =
TESTDB_SW = -d
testdb :: testdb_$(LINKTYPE)
test :: $(TEST_TYPE)
test_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
testdb_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
test_ : test_dynamic
test_static :: test_dynamic
testdb_static :: testdb_dynamic
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd:
@$(PERL) -e "print qq{<SOFTPKG NAME=\"$(DISTNAME)\" VERSION=\"1,02,0,0\">\n\t<TITLE>$(DISTNAME)</TITLE>\n\t<ABSTRACT></ABSTRACT>\n\t<AUTHOR></AUTHOR>\n}" > $(DISTNAME).ppd
@$(PERL) -e "print qq{\t<IMPLEMENTATION>\n\t\t<DEPENDENCY NAME=\"Term-Cap\" VERSION=\"0,0,0,0\" />\n}" >> $(DISTNAME).ppd
@$(PERL) -e "print qq{\t\t<OS NAME=\"$(OSNAME)\" />\n\t\t<ARCHITECTURE NAME=\"sparc64-openbsd\" />\n\t\t<CODEBASE HREF=\"\" />\n\t</IMPLEMENTATION>\n</SOFTPKG>\n}" >> $(DISTNAME).ppd
# --- MakeMaker pm_to_blib section:
pm_to_blib: $(TO_INST_PM)
@$(PERLRUNINST) "-MExtUtils::Install" \
-e "pm_to_blib({qw{Screen.pm blib/lib/Term/Screen.pm}},'$(INST_LIB)/auto','$(PM_FILTER)')"
@$(TOUCH) $@
# --- MakeMaker selfdocument section:
# --- MakeMaker postamble section:
# End.

View File

@ -0,0 +1,7 @@
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Term::Screen',
'VERSION_FROM' => 'Screen.pm',
'PREREQ_PM' => { Term::Cap => 0 },
);

View File

@ -0,0 +1,61 @@
Term::Screen version 1.01
=========================
This module provides a simple interface to the terminal control features
for character mode terminals.
INSTALLATION
This module will build in the usual way :
perl Makefile.PL
make
make test
make install
This last step may need to be done as a user with permission to write into
the Perl library directories - if you are not able to do this you may run
the first step with:
perl Makefile.PL PREFIX=/some/directory/you/can/write/to
And then run the rest of the procedure as usual - you will need to add
that path to @INC as described in the FAQ or in the manpage for the 'lib'
pragma.
DEPENDENCIES
This module depends on version 1.01 or greater of Term::Cap - whilst this
module has been in the core Perl distribution for some years it had
previously required a patch - 1.01 is available as part of the 5.7.2
development release (not intended for general release) and will be in
5.8.0 - it is hoped that 1.02 will be released to CPAN for those who
dont want to upgrade their version of Perl just now.
TO DO
Make a terminfo version of this so better function key support would be
built in.
Make an MS-DOS version and a MAC version and an OS/2 version and a VMS
version, and ... so we can stop seeing "how can I read one char questions"
SUPPORT
Please contact the current maintainer of this module to report any bugs
or suggest changes to this module.
Jonathan Stowe <jns@gellyfish.com>
COPYRIGHT AND LICENSE
Copyright (c) Mark Kaehny 1996
Jonathan Stowe 2001
This is free software it can be modified and distributed under the same
terms as Perl itself - see the README file in the Perl Distribution for
more information.
Mark Kaehny
kaehny@execpc.com

View File

@ -0,0 +1,628 @@
# $Id: Screen.pm,v 1.1.1.1 2003/01/27 23:34:37 margarida Exp $
package Term::Screen;
use strict;
use vars qw($VERSION);
$VERSION = '1.02';
=head1 NAME
Term::Screen - A Simple all perl Term::Cap based screen positioning module
=head1 SYNOPSIS
require Term::Screen;
$scr = new Term::Screen;
unless ($scr) { die " Something's wrong \n"; }
$scr->clrscr();
$scr->at(5,3);
$scr->puts("this is some stuff");
$scr->at(10,10)->bold()->puts("hi!")->normal();
# you can concatenate many calls (not getch)
$c = $scr->getch(); # doesn't need Enter key
...
if ($scr->key_pressed()) { print "ha you hit a key!"; }
=head1 DESCRIPTION
Term::Screen is a very simple screen positioning module that should
work wherever C<Term::Cap> does. It is set up for Unix using stty's but
these dependences are isolated by evals in the C<new> constructor. Thus
you may create a child module implementing Screen with MS-DOS, ioctl,
or other means to get raw and unblocked input. This is not a replacement
for Curses -- it has no memory. This was written so that it could be
easily changed to fit nasty systems, and to be available first thing.
The input functions getch, key_pressed, echo, and noecho are implemented
so as to work under a fairly standard Unix system. They use 'stty'
to set raw and no echo modes and turn on auto flush. All of these are
'eval'ed so that this class can be inherited for new definitions easily.
Term::Screen was designed to be "required", then used with object syntax
as shown above. One quirk (which the author was used to so he didn't
care) is that for function key translation, no delay is set. So for many
terminals to get an esc character, you have to hit another char after it,
generally another esc.
=head1 PUBLIC INTERFACE
Term::Screen has a very minimal set of of fixed character terminal position
and character reading commands:
=over 4
=cut
require Term::Cap;
=item new()
Initialize the screen. Does not clear the screen, but does home the cursor.
=cut
sub new
{
my ($prototype, @args) = @_;
my $classname = ref($prototype) || $prototype;
my ($ospeed);
# adjust OSPEED below to your system.
eval { $ospeed = `stty speed`; }; # Unixish way to get OSpeed - works
$ospeed = 9600 if ($@); # on Linux, Gnuish, Suns ...
my $term = Tgetent Term::Cap { 'TERM' => '', 'OSPEED' => $ospeed };
my $this = {}; # create object
bless $this, $classname;
$this->term($term); # keep termcap entry reference
$this->{IN} = ''; # clear input buffer
$this->{ROWS} = 0;
$this->{COLS} = 0;
$this->resize(); # sets $this->{ROWS} & {COLS}
$this->{KEYS} = {}; # set up fn key hash of hashes
$this->get_fn_keys() ; # define function key table from defaults
$this->at(0,0); # home cursor
$this->{ECHO} = 1; # start off echoing
$| = 1; # for output flush on writes
# wrapped so inherited versions can call with different input codes
eval { system('stty raw -echo'); }; # turn on raw input
# ignore errors
return $this;
}
sub DESTROY { eval { system('stty -raw echo'); } }
=item term(term)
Sets or Gets the Term::Cap object used by this object.
=cut
sub term
{
my ( $self, $term ) = @_;
if ( defined $term && ref $term and UNIVERSAL::isa($term,'Term::Cap'))
{
$self->{TERM} = $term;
}
return $self->{TERM};
}
=item rows(rows)
Returns and/or sets the number of rows on the terminal.
=cut
sub rows
{
my ( $self, $rows ) = @_;
if ( defined $rows and $rows =~ /\d+/ )
{
$self->{ROWS} = $rows;
}
return $self->{ROWS};
}
=item cols(cols)
Returns and/or sets the number of cols on the terminal.
=cut
sub cols
{
my ( $self, $cols ) = @_;
if ( defined $cols and $cols =~ /\d+/ )
{
$self->{COLS} = $cols;
}
return $self->{COLS};
}
=item at(row,col)
Moves cursor to (row,col) where (0,0) is upper left corner, - if the spot is
illegal does whatever 'cm' in termcap does, since that is what it uses.
=cut
sub at
{
my ($this, $r, $c) = @_;
if ($r < 0) {$r = 0;}
if ($c < 0) {$c = 0;}
if ($r >= $this->{ROWS}) {$r = $this->{ROWS}-1;}
if ($c >= $this->{COLS}) {$c = $this->{COLS}-1;}
$this->term()->Tgoto('cm', $c, $r, *STDOUT);
return $this;
}
=item resize(r,c)
Tell screen the new number of rows & cols physically you can skip the r & c
and get new checked vals from stty or termcap. Term::Screen does not
handle resize signals internally, but you can do it by checking and updating
screen size using this function.
=cut
sub resize
{
my ($this, $r, $c) = @_;
my $size = '';
# find screen size -- trying different methods
if ($#_ != 2 || $r <= 0 || $c <= 0)
{
$r = 0; $c = 0;
eval { $size = `stty size`; }; # not portable but most accurate
if ( $size =~ /^\s*(\d+)\s+(\d+)\s*/ )
{
($r, $c) = ($1, $2);
}
}
if ($r == 0 || $c == 0) # try getting rows and cols some other way
{
if (exists $ENV{'LINES'}) { $r = $ENV{'LINES'}; }
else { $r = $this->term()->{'_li'}; } # this is often wrong
if (exists $ENV{'COLUMNS'}) { $c = $ENV{'COLUMNS'}; }
else { $c = $this->term()->{'_co'}; }
}
$this->{ROWS} = $r; $this->{COLS} = $c;
return $this;
}
=item normal()
Turn off any highlightling (bold, reverse)
=cut
sub normal
{
my $this = shift;
$this->term()->Tputs('me',1,*STDOUT);
return $this;
}
=item bold()
The md value from termcap - turn on bold usually
=cut
sub bold
{
my $this = shift;
$this->term()->Tputs('md',1,*STDOUT);
return $this;
}
=item reverse()
The mr value from termcap - turn on reverse text often. these last
two default to whatever is available.
=cut
sub reverse
{
my $this = shift;
$this->term()->Tputs('mr',1,*STDOUT);
return $this;
}
=item clrscr()
Clear the screen and home cursor
=cut
sub clrscr
{
my $this = shift;
$this->term()->Tputs('cl',1, *STDOUT);
$this->{'rc'} = [0,0];
return $this;
}
=item clreol()
Clear to the end of the line - cursor doesn't move
=cut
sub clreol
{
my $this = shift;
if (exists ($this->term()->{'_ce'}))
{
$this->term()->Tputs('ce',1,*STDOUT);
}
return $this
}
=item clreos()
Clear to end of screen - right and down, cursor doesn't move.
=cut
sub clreos
{
my $this = shift;
if (exists ($this->term()->{'_cd'}))
{
$this->term()->Tputs('cd',1,*STDOUT);
}
return $this;
}
=item il()
Insert blank line before line cursor is on, moving lower lines down.
=cut
sub il
{
my $this = shift;
$this->term()->Tputs('al', 1, *STDOUT);
return $this;
}
=item dl()
Delete line cursor is on, moving lower lines up.
=cut
sub dl
{
my $this = shift;
$this->term()->Tputs('dl',1, *STDOUT);
return $this;
}
=item ic_exists()
Insert character option is available.
=cut
sub ic_exists { ( exists ($_[0]->term()->{'ic'}) ? 1 : 0 ); }
*exists_ic = \&ic_exists;
=item ic()
Insert character at current position move rest to the right.
=cut
sub ic
{
my $this = shift;
$this->term()->Tputs('ic',1, *STDOUT);
$this;
}
=item dc_exists()
Delete char option exists and is available.
=cut
sub dc_exists { ( exists ($_[0]->term()->{'dc'}) ? 1 : 0 ); }
*exists_dc = \&dc_exists;
=item dc()
Delete character at current position moving rest to the left.
=cut
sub dc
{
my $this = shift;
$this->term()->Tputs('dc',1, *STDOUT);
return $this;
}
=back
The following are the I/O functions. They provide standard useful
single character reading values. getch returns either a single char or
the name of a function key when a key is pressed. The only exception is
when you hit a character that is the start of a function key sequence.
In this case getch keeps waiting for the next char to see if it is fn key.
Generally this is the escape key, and why you need to hit esc twice.
To get a stright char, just use the regular 'gets' perl function. You
will need to echo it yourself if you want.
=over 4
=item puts(str)
Prints $s and returns the screen object. Used to do things like
C<$scr->at(10,0)->puts("Hi!")->at(0,0);>. You can just use
print if you want.
=cut
sub puts { print $_[1]; return $_[0]; }
=item getch()
Returns just a char in raw mode. Function keys are returned as their
capability names, e.g. the up key would return "ku". See the
C<get_fn_keys> function for what a lot of the names are. This will wait
for next char if in a possible fn key string, so you would need to type
'esc' 'esc' most likely to get out of getch, since 'esc' is usually the
leading char for function keys. You can use perl's getc, to go 'underneath'
getch if you want. See the table in Screen::get_fn_keys() for more
information.
=cut
sub getch
{
my $this = shift;
my ($c, $fn_flag) = ('', 0);
my $partial_fn_str = '';
if ($this->{IN}) { $c = chop($this->{IN}); }
else { $c = getc(STDIN); }
$partial_fn_str = $c;
while (exists ($this->{KEYS}{$partial_fn_str}))
{ # in a possible function key sequence
$fn_flag = 1;
if ($this->{KEYS}{$partial_fn_str}) # key found
{
$c = $this->{KEYS}{$partial_fn_str};
$partial_fn_str = '';
last;
}
else # wait for another key to see if were in FN yet
{
if ($this->{IN}) { $partial_fn_str .= chop($this->{IN}); }
else { $partial_fn_str .= getc(); }
}
}
if ($fn_flag) # seemed like a fn key
{
if ($partial_fn_str) # oops not a fn key
{
if ($partial_fn_str eq "\e\e") # take care of funny ESC case
{
$c = "\e";
$partial_fn_str = "";
}
else # buffer up the received chars
{
$this->{IN} = CORE::reverse($partial_fn_str) . $this->{IN};
$c = chop($this->{IN});
$this->puts($c) if ($this->{ECHO} && ($c ne "\e"));
}
}
# if fn_key then never echo so do nothing here
}
elsif ($this->{ECHO} && ($c ne "\e")) { $this->puts($c); } # regular key
return $c;
}
=item def_key('name','input string')
Lets you define your own function key sequence. 'name' is what will be
returned by getch. 'input string' is what the fn key sends literally. This
will override any prev definitions of the input. A whole bunch of defaults
are defined for xterms rxvt's, etc. in the get_fn_keys function.
=cut
sub def_key
{
my ($this, $fn, $str) = @_;
$this->{KEYS}{$str} = $fn if ($str ne '');
while ($str ne '')
{
chop($str);
$this->{KEYS}{$str} = '' if ($str ne '');
}
return $this;
}
=item key_pressed([sec])
Returns true if there is a character waiting. You can pass an option time in
seconds to wait.
=cut
sub key_pressed
{
my ($this, $seconds) = @_;
my $readfields = '';
my $ready = 0;
$seconds = 0 if (!defined $seconds);
vec($readfields, fileno(STDIN), 1) = 1; # set up to check STDIN
eval { $ready = select($readfields, undef, undef, $seconds); };
return $ready;
}
=item echo()
Tells getch to echo the input to the screen. (the default.)
=cut
sub echo { my $this = shift; $this->{ECHO} = 1; return $this; }
=item noecho()
Tells getch NOT to echo input to the screen.
=cut
sub noecho { my $this = shift; $this->{ECHO} = 0; return $this; }
=item flush_input()
Clears input buffer and removes any incoming chars.
=cut
sub flush_input
{
my $this = shift;
$this->{IN} = '';
while ($this->key_pressed()) { getc(); }
return $this;
}
=item stuff_input(str)
Lets you stuff chars into the input buffer to be read like keystrokes.
This is only the C<getch> method buffer, the underlying getc stuff
is not touched.
=cut
sub stuff_input
{
my ($this, $str) = @_;
$this->{IN} = CORE::reverse($str) . $this->{IN};
return $this;
}
# internal functions
# This function sets up the arrow keys from { ku kd kr kl }
# and the function keys from {k0 .. k9} with labels from { l0 .. l9}
# (if they exist of course.)
# This is all encoded in a funny way -- as a hash with the
# characters as keys - check the code. It makes checking fn keys easy.
sub get_fn_keys
{
my $this = shift;
my $term = $this->term();
my @keys = qw/ku kd kl kr k0 k1 k2 k3 k4 k5 k6 k7 k8 k9/;
my ($fn, $ufn, $lfn);
# throw in some defaults (xterm & rxvt arrows);
$this->def_key("ku","\e[A");
$this->def_key("kd","\e[B");
$this->def_key("kr","\e[C");
$this->def_key("kl","\e[D");
# PC keyboard fn keys for xterm (some of them)
$this->def_key("k1","\e[11~");
$this->def_key("k2","\e[12~");
$this->def_key("k3","\e[13~");
$this->def_key("k4","\e[14~");
$this->def_key("k5","\e[15~");
$this->def_key("k6","\e[17~");
$this->def_key("k7","\e[18~");
$this->def_key("k8","\e[19~");
$this->def_key("k9","\e[20~");
$this->def_key("k10","\e[21~");
$this->def_key("k11","\e[23~");
$this->def_key("k12","\e[24~");
$this->def_key("ins","\e[2~");
$this->def_key("del","\e[3~");
$this->def_key("home","\e[H"); # mult defs are no problem
$this->def_key("home","\eO"); # these are some I have found
$this->def_key("end","\eOw");
$this->def_key("end","\eOe");
$this->def_key("pgup", "\e[5~");
$this->def_key("pgdn", "\e[6~");
# try to get anything useful out of termcap
# (not too accurate in many cases
foreach $fn (@keys)
{
$ufn = '_' . $fn;
$lfn = $ufn;
$lfn =~ s/_k/_l/;
if (exists $term->{$ufn})
{
if ((exists $term->{$lfn}) && ($term->{$lfn}))
{ $fn = substr($lfn,1); }
$this->def_key($fn, $term->{$ufn});
}
}
return $this;
}
1;
__END__
=back
=head1 AUTHOR
Term::Screen.pm by Mark Kaehny (kaehny@execpc.com)
Currently maintained by Jonathan Stowe <jns@gellyfish.com>
=head1 LICENSE AND COPYRIGHT
Please see the README file in the distribution kit for the license details
for this module.
=head1 SEE ALSO
Term::Cap, termcap, curses, stty, select
=cut

View File

@ -0,0 +1,628 @@
# $Id: Screen.pm,v 1.1.1.1 2003/01/27 23:34:38 margarida Exp $
package Term::Screen;
use strict;
use vars qw($VERSION);
$VERSION = '1.02';
=head1 NAME
Term::Screen - A Simple all perl Term::Cap based screen positioning module
=head1 SYNOPSIS
require Term::Screen;
$scr = new Term::Screen;
unless ($scr) { die " Something's wrong \n"; }
$scr->clrscr();
$scr->at(5,3);
$scr->puts("this is some stuff");
$scr->at(10,10)->bold()->puts("hi!")->normal();
# you can concatenate many calls (not getch)
$c = $scr->getch(); # doesn't need Enter key
...
if ($scr->key_pressed()) { print "ha you hit a key!"; }
=head1 DESCRIPTION
Term::Screen is a very simple screen positioning module that should
work wherever C<Term::Cap> does. It is set up for Unix using stty's but
these dependences are isolated by evals in the C<new> constructor. Thus
you may create a child module implementing Screen with MS-DOS, ioctl,
or other means to get raw and unblocked input. This is not a replacement
for Curses -- it has no memory. This was written so that it could be
easily changed to fit nasty systems, and to be available first thing.
The input functions getch, key_pressed, echo, and noecho are implemented
so as to work under a fairly standard Unix system. They use 'stty'
to set raw and no echo modes and turn on auto flush. All of these are
'eval'ed so that this class can be inherited for new definitions easily.
Term::Screen was designed to be "required", then used with object syntax
as shown above. One quirk (which the author was used to so he didn't
care) is that for function key translation, no delay is set. So for many
terminals to get an esc character, you have to hit another char after it,
generally another esc.
=head1 PUBLIC INTERFACE
Term::Screen has a very minimal set of of fixed character terminal position
and character reading commands:
=over 4
=cut
require Term::Cap;
=item new()
Initialize the screen. Does not clear the screen, but does home the cursor.
=cut
sub new
{
my ($prototype, @args) = @_;
my $classname = ref($prototype) || $prototype;
my ($ospeed);
# adjust OSPEED below to your system.
eval { $ospeed = `stty speed`; }; # Unixish way to get OSpeed - works
$ospeed = 9600 if ($@); # on Linux, Gnuish, Suns ...
my $term = Tgetent Term::Cap { 'TERM' => '', 'OSPEED' => $ospeed };
my $this = {}; # create object
bless $this, $classname;
$this->term($term); # keep termcap entry reference
$this->{IN} = ''; # clear input buffer
$this->{ROWS} = 0;
$this->{COLS} = 0;
$this->resize(); # sets $this->{ROWS} & {COLS}
$this->{KEYS} = {}; # set up fn key hash of hashes
$this->get_fn_keys() ; # define function key table from defaults
$this->at(0,0); # home cursor
$this->{ECHO} = 1; # start off echoing
$| = 1; # for output flush on writes
# wrapped so inherited versions can call with different input codes
eval { system('stty raw -echo'); }; # turn on raw input
# ignore errors
return $this;
}
sub DESTROY { eval { system('stty -raw echo'); } }
=item term(term)
Sets or Gets the Term::Cap object used by this object.
=cut
sub term
{
my ( $self, $term ) = @_;
if ( defined $term && ref $term and UNIVERSAL::isa($term,'Term::Cap'))
{
$self->{TERM} = $term;
}
return $self->{TERM};
}
=item rows(rows)
Returns and/or sets the number of rows on the terminal.
=cut
sub rows
{
my ( $self, $rows ) = @_;
if ( defined $rows and $rows =~ /\d+/ )
{
$self->{ROWS} = $rows;
}
return $self->{ROWS};
}
=item cols(cols)
Returns and/or sets the number of cols on the terminal.
=cut
sub cols
{
my ( $self, $cols ) = @_;
if ( defined $cols and $cols =~ /\d+/ )
{
$self->{COLS} = $cols;
}
return $self->{COLS};
}
=item at(row,col)
Moves cursor to (row,col) where (0,0) is upper left corner, - if the spot is
illegal does whatever 'cm' in termcap does, since that is what it uses.
=cut
sub at
{
my ($this, $r, $c) = @_;
if ($r < 0) {$r = 0;}
if ($c < 0) {$c = 0;}
if ($r >= $this->{ROWS}) {$r = $this->{ROWS}-1;}
if ($c >= $this->{COLS}) {$c = $this->{COLS}-1;}
$this->term()->Tgoto('cm', $c, $r, *STDOUT);
return $this;
}
=item resize(r,c)
Tell screen the new number of rows & cols physically you can skip the r & c
and get new checked vals from stty or termcap. Term::Screen does not
handle resize signals internally, but you can do it by checking and updating
screen size using this function.
=cut
sub resize
{
my ($this, $r, $c) = @_;
my $size = '';
# find screen size -- trying different methods
if ($#_ != 2 || $r <= 0 || $c <= 0)
{
$r = 0; $c = 0;
eval { $size = `stty size`; }; # not portable but most accurate
if ( $size =~ /^\s*(\d+)\s+(\d+)\s*/ )
{
($r, $c) = ($1, $2);
}
}
if ($r == 0 || $c == 0) # try getting rows and cols some other way
{
if (exists $ENV{'LINES'}) { $r = $ENV{'LINES'}; }
else { $r = $this->term()->{'_li'}; } # this is often wrong
if (exists $ENV{'COLUMNS'}) { $c = $ENV{'COLUMNS'}; }
else { $c = $this->term()->{'_co'}; }
}
$this->{ROWS} = $r; $this->{COLS} = $c;
return $this;
}
=item normal()
Turn off any highlightling (bold, reverse)
=cut
sub normal
{
my $this = shift;
$this->term()->Tputs('me',1,*STDOUT);
return $this;
}
=item bold()
The md value from termcap - turn on bold usually
=cut
sub bold
{
my $this = shift;
$this->term()->Tputs('md',1,*STDOUT);
return $this;
}
=item reverse()
The mr value from termcap - turn on reverse text often. these last
two default to whatever is available.
=cut
sub reverse
{
my $this = shift;
$this->term()->Tputs('mr',1,*STDOUT);
return $this;
}
=item clrscr()
Clear the screen and home cursor
=cut
sub clrscr
{
my $this = shift;
$this->term()->Tputs('cl',1, *STDOUT);
$this->{'rc'} = [0,0];
return $this;
}
=item clreol()
Clear to the end of the line - cursor doesn't move
=cut
sub clreol
{
my $this = shift;
if (exists ($this->term()->{'_ce'}))
{
$this->term()->Tputs('ce',1,*STDOUT);
}
return $this
}
=item clreos()
Clear to end of screen - right and down, cursor doesn't move.
=cut
sub clreos
{
my $this = shift;
if (exists ($this->term()->{'_cd'}))
{
$this->term()->Tputs('cd',1,*STDOUT);
}
return $this;
}
=item il()
Insert blank line before line cursor is on, moving lower lines down.
=cut
sub il
{
my $this = shift;
$this->term()->Tputs('al', 1, *STDOUT);
return $this;
}
=item dl()
Delete line cursor is on, moving lower lines up.
=cut
sub dl
{
my $this = shift;
$this->term()->Tputs('dl',1, *STDOUT);
return $this;
}
=item ic_exists()
Insert character option is available.
=cut
sub ic_exists { ( exists ($_[0]->term()->{'ic'}) ? 1 : 0 ); }
*exists_ic = \&ic_exists;
=item ic()
Insert character at current position move rest to the right.
=cut
sub ic
{
my $this = shift;
$this->term()->Tputs('ic',1, *STDOUT);
$this;
}
=item dc_exists()
Delete char option exists and is available.
=cut
sub dc_exists { ( exists ($_[0]->term()->{'dc'}) ? 1 : 0 ); }
*exists_dc = \&dc_exists;
=item dc()
Delete character at current position moving rest to the left.
=cut
sub dc
{
my $this = shift;
$this->term()->Tputs('dc',1, *STDOUT);
return $this;
}
=back
The following are the I/O functions. They provide standard useful
single character reading values. getch returns either a single char or
the name of a function key when a key is pressed. The only exception is
when you hit a character that is the start of a function key sequence.
In this case getch keeps waiting for the next char to see if it is fn key.
Generally this is the escape key, and why you need to hit esc twice.
To get a stright char, just use the regular 'gets' perl function. You
will need to echo it yourself if you want.
=over 4
=item puts(str)
Prints $s and returns the screen object. Used to do things like
C<$scr->at(10,0)->puts("Hi!")->at(0,0);>. You can just use
print if you want.
=cut
sub puts { print $_[1]; return $_[0]; }
=item getch()
Returns just a char in raw mode. Function keys are returned as their
capability names, e.g. the up key would return "ku". See the
C<get_fn_keys> function for what a lot of the names are. This will wait
for next char if in a possible fn key string, so you would need to type
'esc' 'esc' most likely to get out of getch, since 'esc' is usually the
leading char for function keys. You can use perl's getc, to go 'underneath'
getch if you want. See the table in Screen::get_fn_keys() for more
information.
=cut
sub getch
{
my $this = shift;
my ($c, $fn_flag) = ('', 0);
my $partial_fn_str = '';
if ($this->{IN}) { $c = chop($this->{IN}); }
else { $c = getc(STDIN); }
$partial_fn_str = $c;
while (exists ($this->{KEYS}{$partial_fn_str}))
{ # in a possible function key sequence
$fn_flag = 1;
if ($this->{KEYS}{$partial_fn_str}) # key found
{
$c = $this->{KEYS}{$partial_fn_str};
$partial_fn_str = '';
last;
}
else # wait for another key to see if were in FN yet
{
if ($this->{IN}) { $partial_fn_str .= chop($this->{IN}); }
else { $partial_fn_str .= getc(); }
}
}
if ($fn_flag) # seemed like a fn key
{
if ($partial_fn_str) # oops not a fn key
{
if ($partial_fn_str eq "\e\e") # take care of funny ESC case
{
$c = "\e";
$partial_fn_str = "";
}
else # buffer up the received chars
{
$this->{IN} = CORE::reverse($partial_fn_str) . $this->{IN};
$c = chop($this->{IN});
$this->puts($c) if ($this->{ECHO} && ($c ne "\e"));
}
}
# if fn_key then never echo so do nothing here
}
elsif ($this->{ECHO} && ($c ne "\e")) { $this->puts($c); } # regular key
return $c;
}
=item def_key('name','input string')
Lets you define your own function key sequence. 'name' is what will be
returned by getch. 'input string' is what the fn key sends literally. This
will override any prev definitions of the input. A whole bunch of defaults
are defined for xterms rxvt's, etc. in the get_fn_keys function.
=cut
sub def_key
{
my ($this, $fn, $str) = @_;
$this->{KEYS}{$str} = $fn if ($str ne '');
while ($str ne '')
{
chop($str);
$this->{KEYS}{$str} = '' if ($str ne '');
}
return $this;
}
=item key_pressed([sec])
Returns true if there is a character waiting. You can pass an option time in
seconds to wait.
=cut
sub key_pressed
{
my ($this, $seconds) = @_;
my $readfields = '';
my $ready = 0;
$seconds = 0 if (!defined $seconds);
vec($readfields, fileno(STDIN), 1) = 1; # set up to check STDIN
eval { $ready = select($readfields, undef, undef, $seconds); };
return $ready;
}
=item echo()
Tells getch to echo the input to the screen. (the default.)
=cut
sub echo { my $this = shift; $this->{ECHO} = 1; return $this; }
=item noecho()
Tells getch NOT to echo input to the screen.
=cut
sub noecho { my $this = shift; $this->{ECHO} = 0; return $this; }
=item flush_input()
Clears input buffer and removes any incoming chars.
=cut
sub flush_input
{
my $this = shift;
$this->{IN} = '';
while ($this->key_pressed()) { getc(); }
return $this;
}
=item stuff_input(str)
Lets you stuff chars into the input buffer to be read like keystrokes.
This is only the C<getch> method buffer, the underlying getc stuff
is not touched.
=cut
sub stuff_input
{
my ($this, $str) = @_;
$this->{IN} = CORE::reverse($str) . $this->{IN};
return $this;
}
# internal functions
# This function sets up the arrow keys from { ku kd kr kl }
# and the function keys from {k0 .. k9} with labels from { l0 .. l9}
# (if they exist of course.)
# This is all encoded in a funny way -- as a hash with the
# characters as keys - check the code. It makes checking fn keys easy.
sub get_fn_keys
{
my $this = shift;
my $term = $this->term();
my @keys = qw/ku kd kl kr k0 k1 k2 k3 k4 k5 k6 k7 k8 k9/;
my ($fn, $ufn, $lfn);
# throw in some defaults (xterm & rxvt arrows);
$this->def_key("ku","\e[A");
$this->def_key("kd","\e[B");
$this->def_key("kr","\e[C");
$this->def_key("kl","\e[D");
# PC keyboard fn keys for xterm (some of them)
$this->def_key("k1","\e[11~");
$this->def_key("k2","\e[12~");
$this->def_key("k3","\e[13~");
$this->def_key("k4","\e[14~");
$this->def_key("k5","\e[15~");
$this->def_key("k6","\e[17~");
$this->def_key("k7","\e[18~");
$this->def_key("k8","\e[19~");
$this->def_key("k9","\e[20~");
$this->def_key("k10","\e[21~");
$this->def_key("k11","\e[23~");
$this->def_key("k12","\e[24~");
$this->def_key("ins","\e[2~");
$this->def_key("del","\e[3~");
$this->def_key("home","\e[H"); # mult defs are no problem
$this->def_key("home","\eO"); # these are some I have found
$this->def_key("end","\eOw");
$this->def_key("end","\eOe");
$this->def_key("pgup", "\e[5~");
$this->def_key("pgdn", "\e[6~");
# try to get anything useful out of termcap
# (not too accurate in many cases
foreach $fn (@keys)
{
$ufn = '_' . $fn;
$lfn = $ufn;
$lfn =~ s/_k/_l/;
if (exists $term->{$ufn})
{
if ((exists $term->{$lfn}) && ($term->{$lfn}))
{ $fn = substr($lfn,1); }
$this->def_key($fn, $term->{$ufn});
}
}
return $this;
}
1;
__END__
=back
=head1 AUTHOR
Term::Screen.pm by Mark Kaehny (kaehny@execpc.com)
Currently maintained by Jonathan Stowe <jns@gellyfish.com>
=head1 LICENSE AND COPYRIGHT
Please see the README file in the distribution kit for the license details
for this module.
=head1 SEE ALSO
Term::Cap, termcap, curses, stty, select
=cut

View File

@ -0,0 +1,294 @@
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Screen 3"
.TH Screen 3 "2002-09-28" "perl v5.8.0" "User Contributed Perl Documentation"
.SH "NAME"
Term::Screen \- A Simple all perl Term::Cap based screen positioning module
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& require Term::Screen;
.Ve
.PP
.Vb 10
\& $scr = new Term::Screen;
\& unless ($scr) { die " Something's wrong \en"; }
\& $scr->clrscr();
\& $scr->at(5,3);
\& $scr->puts("this is some stuff");
\& $scr->at(10,10)->bold()->puts("hi!")->normal();
\& # you can concatenate many calls (not getch)
\& $c = $scr->getch(); # doesn't need Enter key
\& ...
\& if ($scr->key_pressed()) { print "ha you hit a key!"; }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Term::Screen is a very simple screen positioning module that should
work wherever \f(CW\*(C`Term::Cap\*(C'\fR does. It is set up for Unix using stty's but
these dependences are isolated by evals in the \f(CW\*(C`new\*(C'\fR constructor. Thus
you may create a child module implementing Screen with \s-1MS\-DOS\s0, ioctl,
or other means to get raw and unblocked input. This is not a replacement
for Curses \*(-- it has no memory. This was written so that it could be
easily changed to fit nasty systems, and to be available first thing.
.PP
The input functions getch, key_pressed, echo, and noecho are implemented
so as to work under a fairly standard Unix system. They use 'stty'
to set raw and no echo modes and turn on auto flush. All of these are
\&'eval'ed so that this class can be inherited for new definitions easily.
.PP
Term::Screen was designed to be \*(L"required\*(R", then used with object syntax
as shown above. One quirk (which the author was used to so he didn't
care) is that for function key translation, no delay is set. So for many
terminals to get an esc character, you have to hit another char after it,
generally another esc.
.SH "PUBLIC INTERFACE"
.IX Header "PUBLIC INTERFACE"
Term::Screen has a very minimal set of of fixed character terminal position
and character reading commands:
.IP "\fInew()\fR" 4
.IX Item "new()"
Initialize the screen. Does not clear the screen, but does home the cursor.
.IP "term(term)" 4
.IX Item "term(term)"
Sets or Gets the Term::Cap object used by this object.
.IP "rows(rows)" 4
.IX Item "rows(rows)"
Returns and/or sets the number of rows on the terminal.
.IP "cols(cols)" 4
.IX Item "cols(cols)"
Returns and/or sets the number of cols on the terminal.
.IP "at(row,col)" 4
.IX Item "at(row,col)"
Moves cursor to (row,col) where (0,0) is upper left corner, \- if the spot is
illegal does whatever 'cm' in termcap does, since that is what it uses.
.IP "resize(r,c)" 4
.IX Item "resize(r,c)"
Tell screen the new number of rows & cols physically you can skip the r & c
and get new checked vals from stty or termcap. Term::Screen does not
handle resize signals internally, but you can do it by checking and updating
screen size using this function.
.IP "\fInormal()\fR" 4
.IX Item "normal()"
Turn off any highlightling (bold, reverse)
.IP "\fIbold()\fR" 4
.IX Item "bold()"
The md value from termcap \- turn on bold usually
.IP "\fIreverse()\fR" 4
.IX Item "reverse()"
The mr value from termcap \- turn on reverse text often. these last
two default to whatever is available.
.IP "\fIclrscr()\fR" 4
.IX Item "clrscr()"
Clear the screen and home cursor
.IP "\fIclreol()\fR" 4
.IX Item "clreol()"
Clear to the end of the line \- cursor doesn't move
.IP "\fIclreos()\fR" 4
.IX Item "clreos()"
Clear to end of screen \- right and down, cursor doesn't move.
.IP "\fIil()\fR" 4
.IX Item "il()"
Insert blank line before line cursor is on, moving lower lines down.
.IP "\fIdl()\fR" 4
.IX Item "dl()"
Delete line cursor is on, moving lower lines up.
.IP "\fIic_exists()\fR" 4
.IX Item "ic_exists()"
Insert character option is available.
.IP "\fIic()\fR" 4
.IX Item "ic()"
Insert character at current position move rest to the right.
.IP "\fIdc_exists()\fR" 4
.IX Item "dc_exists()"
Delete char option exists and is available.
.IP "\fIdc()\fR" 4
.IX Item "dc()"
Delete character at current position moving rest to the left.
.PP
The following are the I/O functions. They provide standard useful
single character reading values. getch returns either a single char or
the name of a function key when a key is pressed. The only exception is
when you hit a character that is the start of a function key sequence.
In this case getch keeps waiting for the next char to see if it is fn key.
Generally this is the escape key, and why you need to hit esc twice.
To get a stright char, just use the regular 'gets' perl function. You
will need to echo it yourself if you want.
.IP "puts(str)" 4
.IX Item "puts(str)"
Prints \f(CW$s\fR and returns the screen object. Used to do things like
\&\f(CW\*(C`$scr\-\*(C'\fRat(10,0)\->puts(\*(L"Hi!\*(R")\->at(0,0);>. You can just use
print if you want.
.IP "\fIgetch()\fR" 4
.IX Item "getch()"
Returns just a char in raw mode. Function keys are returned as their
capability names, e.g. the up key would return \*(L"ku\*(R". See the
\&\f(CW\*(C`get_fn_keys\*(C'\fR function for what a lot of the names are. This will wait
for next char if in a possible fn key string, so you would need to type
\&'esc' 'esc' most likely to get out of getch, since 'esc' is usually the
leading char for function keys. You can use perl's getc, to go 'underneath'
getch if you want. See the table in \fIScreen::get_fn_keys()\fR for more
information.
.IP "def_key('name','input string')" 4
.IX Item "def_key('name','input string')"
Lets you define your own function key sequence. 'name' is what will be
returned by getch. 'input string' is what the fn key sends literally. This
will override any prev definitions of the input. A whole bunch of defaults
are defined for xterms rxvt's, etc. in the get_fn_keys function.
.IP "key_pressed([sec])" 4
.IX Item "key_pressed([sec])"
Returns true if there is a character waiting. You can pass an option time in
seconds to wait.
.IP "\fIecho()\fR" 4
.IX Item "echo()"
Tells getch to echo the input to the screen. (the default.)
.IP "\fInoecho()\fR" 4
.IX Item "noecho()"
Tells getch \s-1NOT\s0 to echo input to the screen.
.IP "\fIflush_input()\fR" 4
.IX Item "flush_input()"
Clears input buffer and removes any incoming chars.
.IP "stuff_input(str)" 4
.IX Item "stuff_input(str)"
Lets you stuff chars into the input buffer to be read like keystrokes.
This is only the \f(CW\*(C`getch\*(C'\fR method buffer, the underlying getc stuff
is not touched.
.SH "AUTHOR"
.IX Header "AUTHOR"
Term::Screen.pm by Mark Kaehny (kaehny@execpc.com)
Currently maintained by Jonathan Stowe <jns@gellyfish.com>
.SH "LICENSE AND COPYRIGHT"
.IX Header "LICENSE AND COPYRIGHT"
Please see the \s-1README\s0 file in the distribution kit for the license details
for this module.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Term::Cap, termcap, curses, stty, select

View File

@ -0,0 +1,85 @@
#
# TCtest.pl
#
# test program to exercise the screen contol module
#
# by Mark Kaehny 1995
# this file is available under the same terms as the perl language
# distribution. See the Artistic License.
#
require Term::Screen;
$scr = new Term::Screen;
#test clear screen and output
$scr->clrscr();
$scr->puts("Test series for Screen.pm module for perl5");
# test cursor movement, output and linking together
$scr->at(2,3)->puts("1. Should be at row 2 col 3 (upper left is 0,0)");
#test current position update
$r = $scr->{'r'}; $c = $scr->{'c'};
$scr->at(3,0)->puts("2. Last position $r $c -- should be 2 50.");
#test rows and cols ( should be updated for signal )
$scr->at(4,0)->puts("3. Screen size: " . $scr->{'rows'} . " rows and " .
$scr->{'cols'} . " columns.");
# test standout and normal test
$scr->at(6,0);
$scr->puts("4. Testing ")->reverse()->puts("reverse");
$scr->normal()->puts(" mode, ");
$scr->bold()->puts("bold")->normal()->puts(" mode, ");
$scr->bold()->reverse()->puts("and both")->normal()->puts(" together.");
# test clreol
# first put some stuff up
$line = "0---------10--------20--------30--------40--------50--------60--------70-------";
$scr->at(7,0)->puts("5. Testing clreol - " .
" The next 2 lines should end at col 20 and 30.");
for (8 .. 10) {$scr->at($_,0)->puts($line);}
$scr->at(8,20)->clreol()->at(9,30)->clreol();
# test clreos
for (11 .. 20) { $scr->at($_,0)->puts($line); }
$scr->at(11,0)->puts("6. Clreos - Hit a key to clear all right and below:");
$scr->getch();
$scr->clreos();
#test insert line and delete line
$scr->at(12,0)->puts("7. Test insert and delete line - 15 deleted, and ...");
for (13 .. 16) { $scr->at($_,0)->puts($_ . substr($line,2)); }
$scr->at(15,0)->dl();
$scr->at(14,0)->il()->at(14,0)->puts("... this is where line 14 was");
# test key_pressed
$scr->at(18,0)->puts("8. Key_pressed - Don't Hit a key in the next 5 seconds: ");
if ($scr->key_pressed(5)) { $scr->puts("HEY A KEY WAS HIT"); }
else { $scr->puts("GOOD - NO KEY HIT!"); }
$scr->at(19,0)->puts("Hit a key in next 15 seconds: ");
if ($scr->key_pressed(15)) { $scr->puts("KEY HIT!"); }
else { $scr->puts("NO KEY HIT"); }
# test getch
# clear buffer out
$scr->flush_input();
$scr->at(21,0)->puts("Testing getch, Enter Key (q to quit): ")->at(21,40);
$ch = '';
while(($ch = $scr->getch()) ne 'q')
{
if (length($ch) == 1)
{
$scr->at(21,50)->clreol()->puts("ord of char is: ");
$scr->puts(ord($ch))->at(21,40);
}
else
{
$scr->at(21,50)->clreol()->puts("function value: $ch");
$scr->at(21,40);
}
}
$scr->at(22,0);

View File

@ -0,0 +1,628 @@
# $Id: Screen.pm,v 1.1.1.1 2003/01/27 23:34:38 margarida Exp $
package Term::Screen;
use strict;
use vars qw($VERSION);
$VERSION = '1.02';
=head1 NAME
Term::Screen - A Simple all perl Term::Cap based screen positioning module
=head1 SYNOPSIS
require Term::Screen;
$scr = new Term::Screen;
unless ($scr) { die " Something's wrong \n"; }
$scr->clrscr();
$scr->at(5,3);
$scr->puts("this is some stuff");
$scr->at(10,10)->bold()->puts("hi!")->normal();
# you can concatenate many calls (not getch)
$c = $scr->getch(); # doesn't need Enter key
...
if ($scr->key_pressed()) { print "ha you hit a key!"; }
=head1 DESCRIPTION
Term::Screen is a very simple screen positioning module that should
work wherever C<Term::Cap> does. It is set up for Unix using stty's but
these dependences are isolated by evals in the C<new> constructor. Thus
you may create a child module implementing Screen with MS-DOS, ioctl,
or other means to get raw and unblocked input. This is not a replacement
for Curses -- it has no memory. This was written so that it could be
easily changed to fit nasty systems, and to be available first thing.
The input functions getch, key_pressed, echo, and noecho are implemented
so as to work under a fairly standard Unix system. They use 'stty'
to set raw and no echo modes and turn on auto flush. All of these are
'eval'ed so that this class can be inherited for new definitions easily.
Term::Screen was designed to be "required", then used with object syntax
as shown above. One quirk (which the author was used to so he didn't
care) is that for function key translation, no delay is set. So for many
terminals to get an esc character, you have to hit another char after it,
generally another esc.
=head1 PUBLIC INTERFACE
Term::Screen has a very minimal set of of fixed character terminal position
and character reading commands:
=over 4
=cut
require Term::Cap;
=item new()
Initialize the screen. Does not clear the screen, but does home the cursor.
=cut
sub new
{
my ($prototype, @args) = @_;
my $classname = ref($prototype) || $prototype;
my ($ospeed);
# adjust OSPEED below to your system.
eval { $ospeed = `stty speed`; }; # Unixish way to get OSpeed - works
$ospeed = 9600 if ($@); # on Linux, Gnuish, Suns ...
my $term = Tgetent Term::Cap { 'TERM' => '', 'OSPEED' => $ospeed };
my $this = {}; # create object
bless $this, $classname;
$this->term($term); # keep termcap entry reference
$this->{IN} = ''; # clear input buffer
$this->{ROWS} = 0;
$this->{COLS} = 0;
$this->resize(); # sets $this->{ROWS} & {COLS}
$this->{KEYS} = {}; # set up fn key hash of hashes
$this->get_fn_keys() ; # define function key table from defaults
$this->at(0,0); # home cursor
$this->{ECHO} = 1; # start off echoing
$| = 1; # for output flush on writes
# wrapped so inherited versions can call with different input codes
eval { system('stty raw -echo'); }; # turn on raw input
# ignore errors
return $this;
}
sub DESTROY { eval { system('stty -raw echo'); } }
=item term(term)
Sets or Gets the Term::Cap object used by this object.
=cut
sub term
{
my ( $self, $term ) = @_;
if ( defined $term && ref $term and UNIVERSAL::isa($term,'Term::Cap'))
{
$self->{TERM} = $term;
}
return $self->{TERM};
}
=item rows(rows)
Returns and/or sets the number of rows on the terminal.
=cut
sub rows
{
my ( $self, $rows ) = @_;
if ( defined $rows and $rows =~ /\d+/ )
{
$self->{ROWS} = $rows;
}
return $self->{ROWS};
}
=item cols(cols)
Returns and/or sets the number of cols on the terminal.
=cut
sub cols
{
my ( $self, $cols ) = @_;
if ( defined $cols and $cols =~ /\d+/ )
{
$self->{COLS} = $cols;
}
return $self->{COLS};
}
=item at(row,col)
Moves cursor to (row,col) where (0,0) is upper left corner, - if the spot is
illegal does whatever 'cm' in termcap does, since that is what it uses.
=cut
sub at
{
my ($this, $r, $c) = @_;
if ($r < 0) {$r = 0;}
if ($c < 0) {$c = 0;}
if ($r >= $this->{ROWS}) {$r = $this->{ROWS}-1;}
if ($c >= $this->{COLS}) {$c = $this->{COLS}-1;}
$this->term()->Tgoto('cm', $c, $r, *STDOUT);
return $this;
}
=item resize(r,c)
Tell screen the new number of rows & cols physically you can skip the r & c
and get new checked vals from stty or termcap. Term::Screen does not
handle resize signals internally, but you can do it by checking and updating
screen size using this function.
=cut
sub resize
{
my ($this, $r, $c) = @_;
my $size = '';
# find screen size -- trying different methods
if ($#_ != 2 || $r <= 0 || $c <= 0)
{
$r = 0; $c = 0;
eval { $size = `stty size`; }; # not portable but most accurate
if ( $size =~ /^\s*(\d+)\s+(\d+)\s*/ )
{
($r, $c) = ($1, $2);
}
}
if ($r == 0 || $c == 0) # try getting rows and cols some other way
{
if (exists $ENV{'LINES'}) { $r = $ENV{'LINES'}; }
else { $r = $this->term()->{'_li'}; } # this is often wrong
if (exists $ENV{'COLUMNS'}) { $c = $ENV{'COLUMNS'}; }
else { $c = $this->term()->{'_co'}; }
}
$this->{ROWS} = $r; $this->{COLS} = $c;
return $this;
}
=item normal()
Turn off any highlightling (bold, reverse)
=cut
sub normal
{
my $this = shift;
$this->term()->Tputs('me',1,*STDOUT);
return $this;
}
=item bold()
The md value from termcap - turn on bold usually
=cut
sub bold
{
my $this = shift;
$this->term()->Tputs('md',1,*STDOUT);
return $this;
}
=item reverse()
The mr value from termcap - turn on reverse text often. these last
two default to whatever is available.
=cut
sub reverse
{
my $this = shift;
$this->term()->Tputs('mr',1,*STDOUT);
return $this;
}
=item clrscr()
Clear the screen and home cursor
=cut
sub clrscr
{
my $this = shift;
$this->term()->Tputs('cl',1, *STDOUT);
$this->{'rc'} = [0,0];
return $this;
}
=item clreol()
Clear to the end of the line - cursor doesn't move
=cut
sub clreol
{
my $this = shift;
if (exists ($this->term()->{'_ce'}))
{
$this->term()->Tputs('ce',1,*STDOUT);
}
return $this
}
=item clreos()
Clear to end of screen - right and down, cursor doesn't move.
=cut
sub clreos
{
my $this = shift;
if (exists ($this->term()->{'_cd'}))
{
$this->term()->Tputs('cd',1,*STDOUT);
}
return $this;
}
=item il()
Insert blank line before line cursor is on, moving lower lines down.
=cut
sub il
{
my $this = shift;
$this->term()->Tputs('al', 1, *STDOUT);
return $this;
}
=item dl()
Delete line cursor is on, moving lower lines up.
=cut
sub dl
{
my $this = shift;
$this->term()->Tputs('dl',1, *STDOUT);
return $this;
}
=item ic_exists()
Insert character option is available.
=cut
sub ic_exists { ( exists ($_[0]->term()->{'ic'}) ? 1 : 0 ); }
*exists_ic = \&ic_exists;
=item ic()
Insert character at current position move rest to the right.
=cut
sub ic
{
my $this = shift;
$this->term()->Tputs('ic',1, *STDOUT);
$this;
}
=item dc_exists()
Delete char option exists and is available.
=cut
sub dc_exists { ( exists ($_[0]->term()->{'dc'}) ? 1 : 0 ); }
*exists_dc = \&dc_exists;
=item dc()
Delete character at current position moving rest to the left.
=cut
sub dc
{
my $this = shift;
$this->term()->Tputs('dc',1, *STDOUT);
return $this;
}
=back
The following are the I/O functions. They provide standard useful
single character reading values. getch returns either a single char or
the name of a function key when a key is pressed. The only exception is
when you hit a character that is the start of a function key sequence.
In this case getch keeps waiting for the next char to see if it is fn key.
Generally this is the escape key, and why you need to hit esc twice.
To get a stright char, just use the regular 'gets' perl function. You
will need to echo it yourself if you want.
=over 4
=item puts(str)
Prints $s and returns the screen object. Used to do things like
C<$scr->at(10,0)->puts("Hi!")->at(0,0);>. You can just use
print if you want.
=cut
sub puts { print $_[1]; return $_[0]; }
=item getch()
Returns just a char in raw mode. Function keys are returned as their
capability names, e.g. the up key would return "ku". See the
C<get_fn_keys> function for what a lot of the names are. This will wait
for next char if in a possible fn key string, so you would need to type
'esc' 'esc' most likely to get out of getch, since 'esc' is usually the
leading char for function keys. You can use perl's getc, to go 'underneath'
getch if you want. See the table in Screen::get_fn_keys() for more
information.
=cut
sub getch
{
my $this = shift;
my ($c, $fn_flag) = ('', 0);
my $partial_fn_str = '';
if ($this->{IN}) { $c = chop($this->{IN}); }
else { $c = getc(STDIN); }
$partial_fn_str = $c;
while (exists ($this->{KEYS}{$partial_fn_str}))
{ # in a possible function key sequence
$fn_flag = 1;
if ($this->{KEYS}{$partial_fn_str}) # key found
{
$c = $this->{KEYS}{$partial_fn_str};
$partial_fn_str = '';
last;
}
else # wait for another key to see if were in FN yet
{
if ($this->{IN}) { $partial_fn_str .= chop($this->{IN}); }
else { $partial_fn_str .= getc(); }
}
}
if ($fn_flag) # seemed like a fn key
{
if ($partial_fn_str) # oops not a fn key
{
if ($partial_fn_str eq "\e\e") # take care of funny ESC case
{
$c = "\e";
$partial_fn_str = "";
}
else # buffer up the received chars
{
$this->{IN} = CORE::reverse($partial_fn_str) . $this->{IN};
$c = chop($this->{IN});
$this->puts($c) if ($this->{ECHO} && ($c ne "\e"));
}
}
# if fn_key then never echo so do nothing here
}
elsif ($this->{ECHO} && ($c ne "\e")) { $this->puts($c); } # regular key
return $c;
}
=item def_key('name','input string')
Lets you define your own function key sequence. 'name' is what will be
returned by getch. 'input string' is what the fn key sends literally. This
will override any prev definitions of the input. A whole bunch of defaults
are defined for xterms rxvt's, etc. in the get_fn_keys function.
=cut
sub def_key
{
my ($this, $fn, $str) = @_;
$this->{KEYS}{$str} = $fn if ($str ne '');
while ($str ne '')
{
chop($str);
$this->{KEYS}{$str} = '' if ($str ne '');
}
return $this;
}
=item key_pressed([sec])
Returns true if there is a character waiting. You can pass an option time in
seconds to wait.
=cut
sub key_pressed
{
my ($this, $seconds) = @_;
my $readfields = '';
my $ready = 0;
$seconds = 0 if (!defined $seconds);
vec($readfields, fileno(STDIN), 1) = 1; # set up to check STDIN
eval { $ready = select($readfields, undef, undef, $seconds); };
return $ready;
}
=item echo()
Tells getch to echo the input to the screen. (the default.)
=cut
sub echo { my $this = shift; $this->{ECHO} = 1; return $this; }
=item noecho()
Tells getch NOT to echo input to the screen.
=cut
sub noecho { my $this = shift; $this->{ECHO} = 0; return $this; }
=item flush_input()
Clears input buffer and removes any incoming chars.
=cut
sub flush_input
{
my $this = shift;
$this->{IN} = '';
while ($this->key_pressed()) { getc(); }
return $this;
}
=item stuff_input(str)
Lets you stuff chars into the input buffer to be read like keystrokes.
This is only the C<getch> method buffer, the underlying getc stuff
is not touched.
=cut
sub stuff_input
{
my ($this, $str) = @_;
$this->{IN} = CORE::reverse($str) . $this->{IN};
return $this;
}
# internal functions
# This function sets up the arrow keys from { ku kd kr kl }
# and the function keys from {k0 .. k9} with labels from { l0 .. l9}
# (if they exist of course.)
# This is all encoded in a funny way -- as a hash with the
# characters as keys - check the code. It makes checking fn keys easy.
sub get_fn_keys
{
my $this = shift;
my $term = $this->term();
my @keys = qw/ku kd kl kr k0 k1 k2 k3 k4 k5 k6 k7 k8 k9/;
my ($fn, $ufn, $lfn);
# throw in some defaults (xterm & rxvt arrows);
$this->def_key("ku","\e[A");
$this->def_key("kd","\e[B");
$this->def_key("kr","\e[C");
$this->def_key("kl","\e[D");
# PC keyboard fn keys for xterm (some of them)
$this->def_key("k1","\e[11~");
$this->def_key("k2","\e[12~");
$this->def_key("k3","\e[13~");
$this->def_key("k4","\e[14~");
$this->def_key("k5","\e[15~");
$this->def_key("k6","\e[17~");
$this->def_key("k7","\e[18~");
$this->def_key("k8","\e[19~");
$this->def_key("k9","\e[20~");
$this->def_key("k10","\e[21~");
$this->def_key("k11","\e[23~");
$this->def_key("k12","\e[24~");
$this->def_key("ins","\e[2~");
$this->def_key("del","\e[3~");
$this->def_key("home","\e[H"); # mult defs are no problem
$this->def_key("home","\eO"); # these are some I have found
$this->def_key("end","\eOw");
$this->def_key("end","\eOe");
$this->def_key("pgup", "\e[5~");
$this->def_key("pgdn", "\e[6~");
# try to get anything useful out of termcap
# (not too accurate in many cases
foreach $fn (@keys)
{
$ufn = '_' . $fn;
$lfn = $ufn;
$lfn =~ s/_k/_l/;
if (exists $term->{$ufn})
{
if ((exists $term->{$lfn}) && ($term->{$lfn}))
{ $fn = substr($lfn,1); }
$this->def_key($fn, $term->{$ufn});
}
}
return $this;
}
1;
__END__
=back
=head1 AUTHOR
Term::Screen.pm by Mark Kaehny (kaehny@execpc.com)
Currently maintained by Jonathan Stowe <jns@gellyfish.com>
=head1 LICENSE AND COPYRIGHT
Please see the README file in the distribution kit for the license details
for this module.
=head1 SEE ALSO
Term::Cap, termcap, curses, stty, select
=cut

View File

@ -0,0 +1,2 @@
/home/niness/ports/devel/p5-Term-Screen/w-p5-Term-Screen-1.02/fake-sparc64/usr/local/libdata/perl5/site_perl/Term/Screen.pm
/home/niness/ports/devel/p5-Term-Screen/w-p5-Term-Screen-1.02/fake-sparc64/usr/local/man/man3p/Term::Screen.3p

View File

@ -0,0 +1,22 @@
=head2 Sun Jan 26 22:21:54 2003: C<Module> L<Term::Screen|Term::Screen>
=over 4
=item *
C<installed into: /home/niness/ports/devel/p5-Term-Screen/w-p5-Term-Screen-1.02/fake-sparc64/usr/local/libdata/perl5/site_perl>
=item *
C<LINKTYPE: dynamic>
=item *
C<VERSION: 1.02>
=item *
C<EXE_FILES: >
=back

View File

@ -0,0 +1,294 @@
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Screen 3"
.TH Screen 3 "2002-09-28" "perl v5.8.0" "User Contributed Perl Documentation"
.SH "NAME"
Term::Screen \- A Simple all perl Term::Cap based screen positioning module
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& require Term::Screen;
.Ve
.PP
.Vb 10
\& $scr = new Term::Screen;
\& unless ($scr) { die " Something's wrong \en"; }
\& $scr->clrscr();
\& $scr->at(5,3);
\& $scr->puts("this is some stuff");
\& $scr->at(10,10)->bold()->puts("hi!")->normal();
\& # you can concatenate many calls (not getch)
\& $c = $scr->getch(); # doesn't need Enter key
\& ...
\& if ($scr->key_pressed()) { print "ha you hit a key!"; }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Term::Screen is a very simple screen positioning module that should
work wherever \f(CW\*(C`Term::Cap\*(C'\fR does. It is set up for Unix using stty's but
these dependences are isolated by evals in the \f(CW\*(C`new\*(C'\fR constructor. Thus
you may create a child module implementing Screen with \s-1MS\-DOS\s0, ioctl,
or other means to get raw and unblocked input. This is not a replacement
for Curses \*(-- it has no memory. This was written so that it could be
easily changed to fit nasty systems, and to be available first thing.
.PP
The input functions getch, key_pressed, echo, and noecho are implemented
so as to work under a fairly standard Unix system. They use 'stty'
to set raw and no echo modes and turn on auto flush. All of these are
\&'eval'ed so that this class can be inherited for new definitions easily.
.PP
Term::Screen was designed to be \*(L"required\*(R", then used with object syntax
as shown above. One quirk (which the author was used to so he didn't
care) is that for function key translation, no delay is set. So for many
terminals to get an esc character, you have to hit another char after it,
generally another esc.
.SH "PUBLIC INTERFACE"
.IX Header "PUBLIC INTERFACE"
Term::Screen has a very minimal set of of fixed character terminal position
and character reading commands:
.IP "\fInew()\fR" 4
.IX Item "new()"
Initialize the screen. Does not clear the screen, but does home the cursor.
.IP "term(term)" 4
.IX Item "term(term)"
Sets or Gets the Term::Cap object used by this object.
.IP "rows(rows)" 4
.IX Item "rows(rows)"
Returns and/or sets the number of rows on the terminal.
.IP "cols(cols)" 4
.IX Item "cols(cols)"
Returns and/or sets the number of cols on the terminal.
.IP "at(row,col)" 4
.IX Item "at(row,col)"
Moves cursor to (row,col) where (0,0) is upper left corner, \- if the spot is
illegal does whatever 'cm' in termcap does, since that is what it uses.
.IP "resize(r,c)" 4
.IX Item "resize(r,c)"
Tell screen the new number of rows & cols physically you can skip the r & c
and get new checked vals from stty or termcap. Term::Screen does not
handle resize signals internally, but you can do it by checking and updating
screen size using this function.
.IP "\fInormal()\fR" 4
.IX Item "normal()"
Turn off any highlightling (bold, reverse)
.IP "\fIbold()\fR" 4
.IX Item "bold()"
The md value from termcap \- turn on bold usually
.IP "\fIreverse()\fR" 4
.IX Item "reverse()"
The mr value from termcap \- turn on reverse text often. these last
two default to whatever is available.
.IP "\fIclrscr()\fR" 4
.IX Item "clrscr()"
Clear the screen and home cursor
.IP "\fIclreol()\fR" 4
.IX Item "clreol()"
Clear to the end of the line \- cursor doesn't move
.IP "\fIclreos()\fR" 4
.IX Item "clreos()"
Clear to end of screen \- right and down, cursor doesn't move.
.IP "\fIil()\fR" 4
.IX Item "il()"
Insert blank line before line cursor is on, moving lower lines down.
.IP "\fIdl()\fR" 4
.IX Item "dl()"
Delete line cursor is on, moving lower lines up.
.IP "\fIic_exists()\fR" 4
.IX Item "ic_exists()"
Insert character option is available.
.IP "\fIic()\fR" 4
.IX Item "ic()"
Insert character at current position move rest to the right.
.IP "\fIdc_exists()\fR" 4
.IX Item "dc_exists()"
Delete char option exists and is available.
.IP "\fIdc()\fR" 4
.IX Item "dc()"
Delete character at current position moving rest to the left.
.PP
The following are the I/O functions. They provide standard useful
single character reading values. getch returns either a single char or
the name of a function key when a key is pressed. The only exception is
when you hit a character that is the start of a function key sequence.
In this case getch keeps waiting for the next char to see if it is fn key.
Generally this is the escape key, and why you need to hit esc twice.
To get a stright char, just use the regular 'gets' perl function. You
will need to echo it yourself if you want.
.IP "puts(str)" 4
.IX Item "puts(str)"
Prints \f(CW$s\fR and returns the screen object. Used to do things like
\&\f(CW\*(C`$scr\-\*(C'\fRat(10,0)\->puts(\*(L"Hi!\*(R")\->at(0,0);>. You can just use
print if you want.
.IP "\fIgetch()\fR" 4
.IX Item "getch()"
Returns just a char in raw mode. Function keys are returned as their
capability names, e.g. the up key would return \*(L"ku\*(R". See the
\&\f(CW\*(C`get_fn_keys\*(C'\fR function for what a lot of the names are. This will wait
for next char if in a possible fn key string, so you would need to type
\&'esc' 'esc' most likely to get out of getch, since 'esc' is usually the
leading char for function keys. You can use perl's getc, to go 'underneath'
getch if you want. See the table in \fIScreen::get_fn_keys()\fR for more
information.
.IP "def_key('name','input string')" 4
.IX Item "def_key('name','input string')"
Lets you define your own function key sequence. 'name' is what will be
returned by getch. 'input string' is what the fn key sends literally. This
will override any prev definitions of the input. A whole bunch of defaults
are defined for xterms rxvt's, etc. in the get_fn_keys function.
.IP "key_pressed([sec])" 4
.IX Item "key_pressed([sec])"
Returns true if there is a character waiting. You can pass an option time in
seconds to wait.
.IP "\fIecho()\fR" 4
.IX Item "echo()"
Tells getch to echo the input to the screen. (the default.)
.IP "\fInoecho()\fR" 4
.IX Item "noecho()"
Tells getch \s-1NOT\s0 to echo input to the screen.
.IP "\fIflush_input()\fR" 4
.IX Item "flush_input()"
Clears input buffer and removes any incoming chars.
.IP "stuff_input(str)" 4
.IX Item "stuff_input(str)"
Lets you stuff chars into the input buffer to be read like keystrokes.
This is only the \f(CW\*(C`getch\*(C'\fR method buffer, the underlying getc stuff
is not touched.
.SH "AUTHOR"
.IX Header "AUTHOR"
Term::Screen.pm by Mark Kaehny (kaehny@execpc.com)
Currently maintained by Jonathan Stowe <jns@gellyfish.com>
.SH "LICENSE AND COPYRIGHT"
.IX Header "LICENSE AND COPYRIGHT"
Please see the \s-1README\s0 file in the distribution kit for the license details
for this module.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Term::Cap, termcap, curses, stty, select

View File

@ -0,0 +1 @@
positioning screen based module

View File

@ -0,0 +1,6 @@
Term::Screen is a very simple screen positioning module
that should work wherever "Term::Cap" does. It is set up
for Unix using stty's but these dependences are isolated
by evals in the "new" constructor. Thus you may create a
child module implementing Screen with MS-DOS, ioctl, or
other means to get raw and unblocked input.

View File

@ -0,0 +1,4 @@
@comment subdir=devel/p5-Term-Screen cdrom=yes ftp=yes
@comment $OpenBSD: PLIST,v 1.1.1.1 2003/01/27 23:34:38 margarida Exp $
libdata/perl5/site_perl/Term/Screen.pm
man/man3p/Term::Screen.3p

View File

@ -0,0 +1,216 @@
/set type=dir uname=root gname=wheel mode=0755
.
etc
..
usr
local
bin
..
include
X11
..
..
info
..
lib
X11
app-defaults
..
..
..
libdata
perl5
site_perl
..
..
..
libexec
..
man
cat1
..
cat2
..
cat3
..
cat4
..
cat5
..
cat6
..
cat7
..
cat8
..
cat9
..
catl
..
catn
..
ja_JP.EUC
cat1
..
cat2
..
cat3
..
cat4
..
cat5
..
cat6
..
cat7
..
cat8
..
cat9
..
catl
..
catn
..
man1
..
man2
..
man3
..
man4
..
man5
..
man6
..
man7
..
man8
..
man9
..
manl
..
mann
..
..
man1
..
man2
..
man3
..
man4
..
man5
..
man6
..
man7
..
man8
..
man9
..
manl
..
mann
..
..
sbin
..
share
dict
..
doc
..
examples
..
misc
..
nls
C
..
da_DK.ISO_8859-1
..
de_AT.ISO_8859-1
..
de_CH.ISO_8859-1
..
de_DE.ISO_8859-1
..
el_GR.ISO_8859-7
..
en_AU.ISO_8859-1
..
en_CA.ISO_8859-1
..
en_GB.ISO_8859-1
..
en_US.ISO_8859-1
..
es_ES.ISO_8859-1
..
et_EE.ISO-8859-1
..
fi_FI.ISO_8859-1
..
fr_BE.ISO_8859-1
..
fr_CA.ISO_8859-1
..
fr_CH.ISO_8859-1
..
fr_FR.ISO_8859-1
..
hr_HR.ISO_8859-2
..
is_IS.ISO_8859-1
..
it_CH.ISO_8859-1
..
it_IT.ISO_8859-1
..
ja_JP.EUC
..
ko_KR.EUC
..
lt_LN.ASCII
..
lt_LN.ISO_8859-1
..
lt_LN.ISO_8859-2
..
nl_BE.ISO_8859-1
..
nl_NL.ISO_8859-1
..
no_NO.ISO_8859-1
..
pt_PT.ISO_8859-1
..
ru_RU.CP866
..
ru_RU.ISO_8859-5
..
ru_RU.KOI8-R
..
sv_SE.ISO_8859-1
..
uk_UA.KOI8-U
..
..
skel
..
..
..
..
var
db
..
log
..
spool
..
www type=dir uname=root gname=daemon mode=755