in reply to Re^3: 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 what the code I'm trying to work on does:
sub getlineUnix { my $message; eval { local $SIG{ALRM} = sub { $old = $readline::line; die }; alarm($config{timeout}) unless $^O =~ /win32/i; $message = $term->readline("Talk: ", $old); $old = $readline::line = ''; alarm(0) unless $^O =~ /win32/i; }; $message; }
But I think the call to readline is the only important one
in there. Here's what I think it comes down to in
Term::ReadLine:
sub get_line { my $self = shift; $self->Tk_loop if $Term::ReadLine::toloop && defined &Tk::DoOneEvent +; my $in = $self->IN; local ($/) = "\n"; return scalar <$in>; }

Replies are listed 'Best First'.
Re^5: Avoid newline echoing so I can capture a line and reprompt over it
by japhy (Canon) on Sep 02, 2004 at 13:26 UTC
    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
      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
Re^5: Avoid newline echoing so I can capture a line and reprompt over it
by japhy (Canon) on Sep 02, 2004 at 13:18 UTC
    I think the general algorithm would be to turn off echoing and use some function that reads one character at a time, echoing it if it's NOT a newline, and stopping the input procedure when it IS a newline.
    _____________________________________________________
    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