in reply to Re^4: Avoid newline echoing so I can capture a line and reprompt over it
in thread Avoid newline echoing so I can capture a line and reprompt over it

Here is a working example:
use Term::ReadKey; my $prompt = "Gimme a char: "; while (1) { # updated to use the erase-to-EOL escape sequence print "\r$prompt\e[K"; my $key = ""; my $str = ""; ReadMode "cbreak"; do { print $key; $str .= $key; $key = ReadKey; } while $key ne "\n"; ReadMode "normal"; }
_____________________________________________________
Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
  • Comment on Re^5: Avoid newline echoing so I can capture a line and reprompt over it
  • Download Code

Replies are listed 'Best First'.
Re^6: Avoid newline echoing so I can capture a line and reprompt over it
by hlen (Beadle) on Sep 02, 2004 at 14:47 UTC
    Thanks a lot, japhy.. that's great. doowah2004, that wouldn't work because context line is not actually a static line, there's a screen of unexpected context lines being received and scrolling up, and I can't just clear them.

    Cheers