English 中文(简体)
任期: 追捕暴徒和主要压力的正确途径是什么?
原标题:Term::TermKey: What is the right way to catch mouseevents and keypresses?

这为主要压力而不是烟雾。 我应在此作什么改动,以使之发挥作用(。 术语:TermKey?

#!/usr/bin/env perl
use warnings;
use 5.12.0;
use utf8;
use Term::TermKey qw(FLAG_UTF8);
my $tk = Term::TermKey->new( *STDIN );
binmode STDOUT,  :encoding(utf-8)  if $tk->get_flags & FLAG_UTF8;

while( 1 ) {
    my $key;
    $tk->waitkey( $key );

    if ( $key->type_is_mouse ) {
        my ( $ev, $button, $line, $col ) = $tk->interpret_mouse( $key );
        say "event : $ev";
        say "button: $button";
        say "line  : $line";
        say "col   : $col";
    }
    else {
        say "<", $tk->format_key( $key, 0 ), ">";
    }
}
最佳回答

当我启动使用权时,它就能够运作。

#!/usr/bin/env perl
use warnings;
use 5.12.0;
use utf8;
use Term::TermKey qw(FLAG_UTF8);
my $tk = Term::TermKey->new( *STDIN );
binmode STDOUT,  :encoding(utf-8)  if $tk->get_flags & FLAG_UTF8;

$|++;

print "e[?1003h";

say "Quit with "q"";
while( 1 ) {
    my $key;
    $tk->waitkey( $key );

    if ( $key->type_is_mouse ) {
        my ( $ev, $button, $line, $col ) = $tk->interpret_mouse( $key );
        say "event : $ev";
        say "button: $button";
        say "line  : $line";
        say "col   : $col";
    }
    else {
        say "<", $tk->format_key( $key, 0 ), ">";
        last if $tk->format_key( $key, 0 ) eq  q ;
    }
}

print "e[?1003l";
问题回答

暂无回答




相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签