加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 终端:我在哪里?

发布时间:2020-12-16 06:20:28 所属栏目:大数据 来源:网络整理
导读:是否有变量或函数,它可以告诉我光标的实际位置? #!/usr/bin/env perluse 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-g
是否有变量或函数,它可以告诉我光标的实际位置?

#!/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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读