NAME
MarpaX::Database::Terminfo::Interface - Terminfo interface
VERSION
version 0.012
SYNOPSIS
use MarpaX::Database::Terminfo::Interface qw/:all/;
use Log::Log4perl qw/:easy/;
use Log::Any::Adapter;
use Log::Any qw/$log/;
#
# Init log
#
our $defaultLog4perlConf = '
log4perl.rootLogger = WARN, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr = 0
log4perl.appender.Screen.layout = PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %d %-5p %6P %m{chomp}%n
';
Log::Log4perl::init(\$defaultLog4perlConf);
Log::Any::Adapter->set('Log4perl');
tgetent('ansi');
DESCRIPTION
This modules implements a terminfo X/open-compliant interface.
SUBROUTINES/METHODS
new($class, $opts)
Instance an object. An optional $opt is a reference to a hash:
- $opts->{file} or $ENV{MARPAX_DATABASE_TERMINFO_FILE}
-
File path to the terminfo database. This module will then parse it using Marpa. If set to any true value, this setting has precedence over the following txt key/value.
- $opts->{txt} or $ENV{MARPAX_DATABASE_TERMINFO_TXT}
-
Text version of the terminfo database. This module will then parse it using Marpa. If set to any true value, this setting has precedence over the following bin key/value.
- $opts->{bin} or $ENV{MARPAX_DATABASE_TERMINFO_BIN}
-
Path to a binary version of the terminfo database, created using Sereal. This module is distributed with such a binary file, which contains the GNU ncurses definitions. The default behaviour is to use this file.
- $opts->{caps} or $ENV{MARPAX_DATABASE_TERMINFO_CAPS}
-
Path to a text version of the terminfo<->termcap translation. This module is distributed with GNU ncurses translation files, namely: ncurses-Caps (default), ncurses-Caps.aix4 (default on AIX), ncurses-Caps.hpux11 (default on HP/UX), ncurses-Caps.keys, ncurses-Caps.osf1r5 (default on OSF1) and ncurses-Caps.uwin.
- $opts->{cache_stubs} or $ENV{MARPAX_DATABASE_TERMINFO_CACHE_STUBS}
-
Flag saying if the compiled stubs of string features should be cached. Default is true.
- $opts->{cache_stubs_as_txt} or $ENV{MARPAX_DATABASE_TERMINFO_CACHE_STUBS_AS_TXT}
-
Flag saying if the string versions (i.e. not compiled) stubs of string features should be cached or not. Default is true.
- $opts->{stubs_txt} or $ENV{MARPAX_DATABASE_TERMINFO_STUBS_TXT}
-
Path to a text version of the terminfo string features<->stubs mapping, created using Data::Dumper. The content of this file is the text version of all stubs, that will be compiled if needed. This option is used only if cache_stubs is on. If set to any true value, this setting has precedence over the following bin key/value. Mostly useful for debugging or readability: the created stubs are immediately comprehensive, and if there is a bug in them, this option could be used.
- $opts->{stubs_bin} or $ENV{MARPAX_DATABASE_TERMINFO_STUBS_BIN}
-
Path to a binary version of the terminfo string features<->stubs mapping, created using Sereal module. The content of this file is the text version of all stubs, that will all be compiled if needed. This option is used only if cache_stubs is on. This module is distributed with such a binary file, which contains the GNU ncurses stubs definitions. The default behaviour is to use this file.
- $opts->{bsd_tputs} or $ENV{MARPAX_DATABASE_TERMINFO_BSD_TPUTS}
-
Specific to ancient BSD programs, like nethack, that likes to get systematic delays. Default is false.
- $opts->{use_env} or $ENV{MARPAX_DATABASE_TERMINFO_USE_ENV}
-
Initial value of use_env boolean, saying if lines and columns specified in terminfo are used or not. Default value is true. Please refer to the use_env() method.
Default terminal setup is done using the $ENV{TERM} environment variable, if it exist, or 'unknown'. The database used is not a compiled database as with GNU ncurses, therefore the environment variable TERMINFO is not used. Instead, a compiled database should a perl's Sereal version of a text database parsed by Marpa. See $ENV{MARPAX_DATABASE_TERMINFO_BIN} upper.
_terminfo_db($self)
Internal function. Returns the raw database, in the form of an array of hashes.
_terminfo_current($self)
Internal function. Returns the current terminfo entry.
_t2other($self)
Internal function. Returns the terminfo->termcap translation hash.
_c2other($self)
Internal function. Returns the terminfo->termcap translation hash.
_capalias($self)
Internal function. Returns the termcap aliases.
_infoalias($self)
Internal function. Returns the termcap aliases.
_terminfo_init($self)
Internal function. Initialize if needed and if possible the current terminfo. Returns a pointer to the current terminfo entry.
flush($self, $cb, @args);
Defines a flush callback function $cb with optional @arguments. Such callback is used in some case like a delay. If called as $self->flush(), returns undef or a reference to an array containing [$cb, @args].
tgetent($self, $name[, $fh])
Loads the entry for $name. Returns 1 on success, 0 if no entry, -1 if the terminfo database could not be found. This function will warn if the database has a problem. $name must be an alias in the terminfo database. If multiple entries have the same alias, the first that matches is taken. The variables PC, UP and BC are set by tgetent to the terminfo entry's data for pad_char, cursor_up and backspace_if_not_bs, respectively. The variable ospeed is set in a system-specific coding to reflect the terminal speed, or $ENV{MARPAX_DATABASE_TERMINFO_OSPEED} if defined, otherwise we attempt to get the value using POSIX interface, or "13". ospeed should be a value between 0 and 15, or 4097 and 4105, or 4107 and 4111. The variable baudrate can be $ENV{MARPAX_DATABASE_TERMINFO_BAUDRATE} (unchecked! i.e. at your own risk) or is derived from ospeed, or "9600". $fh is an optional opened filehandle, used to guess about baudrate and ospeed. Defaults to fileno(\*STDIN) or 0. When loading a terminfo, termcap and variable entries are automatically derived using the caps parameter as documented in _new_instance().
delay($self, $ms)
Do a delay of $ms milliseconds when producing the output. If the current terminfo variable no_pad_char is true, or if there is no PC variable, do a system sleep. Otherwise use the PC variable as many times as necessary followed by a flush callback. Do nothing if outside of a "producing output" context (i.e. tputs(), etc...). Please note that delay by itself in the string is not recognized as a grammar lexeme. This is tputs() that is seeing the delay.
tgetflag($self, $id)
Gets the boolean value for termcap entry $id, or 0 if not available. Only the first two characters of the id parameter are compared in lookups.
tigetflag($self, $id)
Gets the boolean value for terminfo entry $id. Returns the value -1 if $id is not a boolean capability, or 0 if it is canceled or absent from the terminal description.
tvgetflag($self, $id)
Search for the boolean variable $id. Return true if found, false in all other cases.
tgetnum($self, $id)
Stores the numeric value for termcap entry $id, or -1 if not available. Only the first two characters of the id parameter are compared in lookups.
tigetnum($self, $id)
Gets the numeric value for terminfo entry $id. Returns the value -2 if $id is not a numeric capability, or -1 if it is canceled or absent from the terminal description.
tvgetnum($self, $id, [$areap])
Search for the numeric variable $id. If found, return true and store its value in the eventual ${$areap}, return false in all other cases.
tgetstr($self, $id, [$areap])
Returns a reference to termcap string entry for $id, or zero if it is not available. If $areap is defined and is a reference: if $id is a string then the found value is inserted at current pos()isition in ${$areap} and pos()isition is updated, otherwise (i.e. boolean and numeric cases) ${$areap} is overwritten with the found value. Only the first two characters of the id parameter are compared in lookups.
tigetstr($self, $id)
Returns a reference to terminfo string entry for $id, or -1 if $id is not a string capabilitty, or 0 it is canceled or absent from terminal description.
tvgetstr($self, $id, [$areap])
Search for the string variable $id. If found, return true and insert its value at pos()istion of eventual ${$areap}, this pos() being updated after the insert, return false in all other cases.
tputs($self, $str, $affcnt, $outc, @outcArgs)
Applies padding information to the string $str and outputs it. The $str must be a terminfo string variable or the return value from tparm(), tgetstr(), or tgoto(). $affcnt is the number of lines affected, or 1 if not applicable. $outc is a putchar-like routine to which the characters are passed, one at a time, as first argument, and @outcArgs as remaining arguments.
putp($self, $str)
Calls $self->tputs($str, 1, sub {print STDOUT shift}). Note that the output of putp always goes to stdout, not to the fildes specified in setupterm..
tparm($self, $string, @param)
Instantiates the string $string with parameters @param. Returns the string with the parameters applied.
tgoto($self, $string, $col, $row)
Instantiates the parameters into the given capability. The output from this routine is to be passed to tputs.
use_env($self[, $boolean])
Returns or set the use_env boolean. $boolean can be anything, this is internally convert to either 0 or 1.
SEE ALSO
Unix Documentation Project - terminfo
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=MarpaX-Database-Terminfo. You will be notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/jddurand/marpax-database-terminfo
git clone git://github.com/jddurand/marpax-database-terminfo.git
AUTHOR
jddurand <jeandamiendurand@free.fr>
CONTRIBUTOR
Jean-Damien Durand <jeandamiendurand@free.fr>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Jean-Damien Durand.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.