read/ edit line from stdin

C

Clemens Hepper

Hello,
for my project confux (http://confux.sourceforge.net) I want to read
a line from stdin.
But I don't want the user to type a new line. I want so display a
value which the user can edit.

For example I want to ask the user for a hostname and I print
"localhost", the user modified it to "localserver" and I read it
after <return>.

What is the fastest way to realize that? I do NOT want to use curses
(yet) ;-).

mfg
- eth
 
J

James Stroud

Clemens said:
Hello,
for my project confux (http://confux.sourceforge.net) I want to read
a line from stdin.
But I don't want the user to type a new line. I want so display a
value which the user can edit.

For example I want to ask the user for a hostname and I print
"localhost", the user modified it to "localserver" and I read it
after <return>.

What is the fastest way to realize that? I do NOT want to use curses
(yet) ;-).

mfg
- eth

Why don't you just make "localhost" the default and have the user enter
the complete name if they want it different. Seems like this is the way
every CL program I've ever seen works.

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
C

Clemens Hepper

It's a bit more complicated.
The field has a default and a preassigned Value.

The default is p.e. 'localhost' and the value is 'www.gentoo.org'.
Then localhost is chosen if the value is erased to ''. But i want to
make it easy to keep the preassigned value!
So if nothing is typed 'www.gentoo.org' should be used.

I just thought that extending the commandline input interface would
be quite useful.
I want a text field that can be edited like common GUI-TextFields on
command line...

mfg
- eth
 
D

Dennis Lee Bieber

I just thought that extending the commandline input interface would
be quite useful.
I want a text field that can be edited like common GUI-TextFields on
command line...
There's no true common way to do that -- it all depends upon the
control codes that the current console window/terminal support... Hence
the use of "termcaps" and curses packages on UNIX/LINUX... After all, if
you are connecting via an old Tektronix storage display terminal, you'd
have to flash erase the entire screen and redraw everything just to
"overwrite" one character field.

Old IBM 3270s, as I recall, ran in a "page mode" where text changes
where local to the display, and then sent to the application as a
sequence of (x, y)<new text> information. (and updates to the display
were done similarly).

VT100 (200, 300, 400) and the CBM Amiga used a common set of escape
codes to move around on the screen. OTOH; I don't even know if a plain
WinXP "command prompt" HAS any control code capability...

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,289
Messages
2,571,448
Members
48,126
Latest member
ToneyChun2

Latest Threads

Top