微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐