.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .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. \*(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- .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" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" 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 "AnyEvent::TermKey 3pm" .TH AnyEvent::TermKey 3pm "2018-12-31" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" "AnyEvent::TermKey" \- terminal key input using "libtermkey" with "AnyEvent" .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use AnyEvent::TermKey qw( FORMAT_VIM KEYMOD_CTRL ); \& use AnyEvent; \& \& my $cv = AnyEvent\->condvar; \& \& my $aetk = AnyEvent::TermKey\->new( \& term => \e*STDIN, \& \& on_key => sub { \& my ( $key ) = @_; \& \& print "Got key: ".$key\->termkey\->format_key( $key, FORMAT_VIM )."\en"; \& \& $cv\->send if $key\->type_is_unicode and \& $key\->utf8 eq "C" and \& $key\->modifiers & KEYMOD_CTRL; \& }, \& ); \& \& $cv\->recv; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class implements an asynchronous perl wrapper around the \f(CW\*(C`libtermkey\*(C'\fR library, which provides an abstract way to read keypress events in terminal-based programs. It yields structures that describe keys, rather than simply returning raw bytes as read from the \s-1TTY\s0 device. .PP It internally uses an instance of Term::TermKey to access the underlying C library. For details on general operation, including the representation of keypress events as objects, see the documentation on that class. .PP Proxy methods exist for normal accessors of \f(CW\*(C`Term::TermKey\*(C'\fR, and the usual behaviour of the \f(CW\*(C`getkey\*(C'\fR or other methods is instead replaced by the \&\f(CW\*(C`on_key\*(C'\fR event. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .ie n .SS "$aetk = AnyEvent::TermKey\->new( %args )" .el .SS "\f(CW$aetk\fP = AnyEvent::TermKey\->new( \f(CW%args\fP )" .IX Subsection "$aetk = AnyEvent::TermKey->new( %args )" This function returns a new instance of a \f(CW\*(C`AnyEvent::TermKey\*(C'\fR object. It takes the following named arguments: .IP "term => \s-1IO\s0 or \s-1INT\s0" 8 .IX Item "term => IO or INT" Optional. File handle or \s-1POSIX\s0 file descriptor number for the file handle to use as the connection to the terminal. If not supplied \f(CW\*(C`STDIN\*(C'\fR will be used. .IP "on_key => \s-1CODE\s0" 8 .IX Item "on_key => CODE" \&\s-1CODE\s0 reference to the key-event handling callback. Will be passed an instance of a \f(CW\*(C`Term::TermKey::Key\*(C'\fR structure: .Sp .Vb 1 \& $on_key\->( $key ) .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS "$tk = $aetk\->termkey" .el .SS "\f(CW$tk\fP = \f(CW$aetk\fP\->termkey" .IX Subsection "$tk = $aetk->termkey" Returns the \f(CW\*(C`Term::TermKey\*(C'\fR object being used to access the \f(CW\*(C`libtermkey\*(C'\fR library. Normally should not be required; the proxy methods should be used instead. See below. .ie n .SS "$flags = $aetk\->get_flags" .el .SS "\f(CW$flags\fP = \f(CW$aetk\fP\->get_flags" .IX Subsection "$flags = $aetk->get_flags" .ie n .SS "$aetk\->set_flags( $flags )" .el .SS "\f(CW$aetk\fP\->set_flags( \f(CW$flags\fP )" .IX Subsection "$aetk->set_flags( $flags )" .ie n .SS "$canonflags = $aetk\->get_canonflags" .el .SS "\f(CW$canonflags\fP = \f(CW$aetk\fP\->get_canonflags" .IX Subsection "$canonflags = $aetk->get_canonflags" .ie n .SS "$aetk\->set_canonflags( $canonflags )" .el .SS "\f(CW$aetk\fP\->set_canonflags( \f(CW$canonflags\fP )" .IX Subsection "$aetk->set_canonflags( $canonflags )" .ie n .SS "$msec = $aetk\->get_waittime" .el .SS "\f(CW$msec\fP = \f(CW$aetk\fP\->get_waittime" .IX Subsection "$msec = $aetk->get_waittime" .ie n .SS "$aetk\->set_waittime( $msec )" .el .SS "\f(CW$aetk\fP\->set_waittime( \f(CW$msec\fP )" .IX Subsection "$aetk->set_waittime( $msec )" .ie n .SS "$str = $aetk\->get_keyname( $sym )" .el .SS "\f(CW$str\fP = \f(CW$aetk\fP\->get_keyname( \f(CW$sym\fP )" .IX Subsection "$str = $aetk->get_keyname( $sym )" .ie n .SS "$sym = $aetk\->keyname2sym( $keyname )" .el .SS "\f(CW$sym\fP = \f(CW$aetk\fP\->keyname2sym( \f(CW$keyname\fP )" .IX Subsection "$sym = $aetk->keyname2sym( $keyname )" .ie n .SS "( $ev, $button, $line, $col ) = $aetk\->interpret_mouse( $key )" .el .SS "( \f(CW$ev\fP, \f(CW$button\fP, \f(CW$line\fP, \f(CW$col\fP ) = \f(CW$aetk\fP\->interpret_mouse( \f(CW$key\fP )" .IX Subsection "( $ev, $button, $line, $col ) = $aetk->interpret_mouse( $key )" .ie n .SS "$str = $aetk\->format_key( $key, $format )" .el .SS "\f(CW$str\fP = \f(CW$aetk\fP\->format_key( \f(CW$key\fP, \f(CW$format\fP )" .IX Subsection "$str = $aetk->format_key( $key, $format )" .ie n .SS "$key = $aetk\->parse_key( $str, $format )" .el .SS "\f(CW$key\fP = \f(CW$aetk\fP\->parse_key( \f(CW$str\fP, \f(CW$format\fP )" .IX Subsection "$key = $aetk->parse_key( $str, $format )" .ie n .SS "$key = $aetk\->parse_key_at_pos( $str, $format )" .el .SS "\f(CW$key\fP = \f(CW$aetk\fP\->parse_key_at_pos( \f(CW$str\fP, \f(CW$format\fP )" .IX Subsection "$key = $aetk->parse_key_at_pos( $str, $format )" .ie n .SS "$cmp = $aetk\->keycmp( $key1, $key2 )" .el .SS "\f(CW$cmp\fP = \f(CW$aetk\fP\->keycmp( \f(CW$key1\fP, \f(CW$key2\fP )" .IX Subsection "$cmp = $aetk->keycmp( $key1, $key2 )" These methods all proxy to the \f(CW\*(C`Term::TermKey\*(C'\fR object, and allow transparent use of the \f(CW\*(C`AnyEvent::TermKey\*(C'\fR object as if it was a subclass. Their arguments, behaviour and return value are therefore those provided by that class. For more detail, see the Term::TermKey documentation. .SH "AUTHOR" .IX Header "AUTHOR" Paul Evans