Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Capture user input AND read after it has been modified

by Allasso (Monk)
on Apr 29, 2019 at 00:54 UTC ( [id://1233097]=perlquestion: print w/replies, xml ) Need Help??

Allasso has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a small editor that runs inside a terminal window. I am currently capturing user input using the following construct:
use IO::Handle; my $stdin = new IO::Handle; $stdin->fdopen( fileno( STDIN ), "r" ) || die "Cannot open STDIN"; while ( my $char = $stdin->getc() ) { # ... etc etc
The capturing is to deal with such things as arrow keys so the user (me) can navigate and more easily edit text before submitting. I am wondering if there is a way, AFTER the user has done their editing, and submits, can the text that is displayed in the terminal be read in its updated form from the terminal? This would save me having to track every input event to construct the final string. Thanks!

Replies are listed 'Best First'.
Re: Capture user input AND read after it has been modified
by LanX (Saint) on Apr 29, 2019 at 01:17 UTC
      Oh yeah, forgot to mention, relying on Cpan modules would definitely be a headache for me. I am hopping around to different machines frequently, and I can't be geeking around trying to install modules in unfamiliar environments when I just need to run a script pronto, especially say, a Mac that doesn't have dev tools installed, etc. Non-reliance on Cpan gives me maximum portability.

        Except under Win, there should be vi on most machines...

        Regards from the past, Sincerely yours, hdb

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1233097]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found