perl – 终端:我在哪里?

前端之家收集整理的这篇文章主要介绍了perl – 终端:我在哪里?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否有变量或函数,它可以告诉我光标的实际位置?

#!/usr/bin/env perl
use warnings;
use 5.012;

use Term::ReadKey;
use Term::Cap;
use POSIX;

my( $col,$row ) = GetTerminalSize();

my $termios = new POSIX::Termios;
$termios->getattr;
my $ospeed = $termios->getospeed;

my $terminal = Tgetent Term::Cap { TERM => undef,OSPEED => $ospeed };

# some movement ...

# at which position (x/y) is the cursor now?

解决方法

我不认为你可以使用termcap确定光标位置.

The termutils manual说:

If you plan to use the relative cursor motion commands in an application program,you must know what the starting cursor position is. To do this,you must keep track of the cursor position and update the records each time anything is output to the terminal,including graphic characters.

猜你在找的Perl相关文章