0
はTerm::ReadKeyはそれを行うことができ、同様の方法でTerm::TermKeyとカーソル位置のホールドを取得することが可能です:Term :: TermKeyでカーソルの位置を捕まえることがどうにかできますか?
#!/usr/bin/env perl
use warnings;
use 5.12.0;
use Term::ReadKey;
ReadMode 4;
system('clear') == 0 or die $?;
print "Hello world\n" x 4;
print "go to column 21 -> |";
print "\e[6n";
my ($x, $y) = getch();
say "Col: $x - Row: $y";
ReadMode 0;
sub getch {
my $c = ReadKey 0;
if ($c eq "\e") {
my $c = ReadKey 0.10;
if ($c eq '[') {
my $c = ReadKey 0;
if ($c =~ /\A\d/) {
my $c1 = ReadKey 0;
if ($c1 ne '~') {
my $y = 0 + $c;
while (1) {
last if $c1 eq ';';
$y = 10 * $y + $c1;
$c1 = ReadKey 0;
}
my $x = 0;
while (1) {
$c1 = ReadKey 0;
last if $c1 eq 'R';
$x = 10 * $x + $c1;
}
return $x, $y;
}
}
}
}
}
libtermkey 0.15(私はAlien :: libtermkeyアップデートを期待しています:)をインストールする方法がわからないので、まだ試してみることができませんでした。 –
あなたは元のアップストリームのtarballからインストールできます...;) また、Alien :: libtermkeyのアップデートもあります。 – LeoNerd
'is_position'を' type_is_position'に置き換えると動作します。 –