是否有变量或函数,它可以告诉我光标的实际位置?
#!/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确定光标位置.
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.