is possible to edit text field in console?

T

Tom Cloyd

A beginner question for sure, but one on which I'm stuck: I'm trying to
determine if it's possible, by any means whatsoever, to display a line
of text on the console and allow the user to edit it, before pressing
Enter to cause it to be read back in. As far as I can tell, this is only
possible in a GUI display object. Before I move in that direction I
thought I'd check to see if I've missed anything.

Thanks for any help anyone has.

t.
 
M

Michael Linfield

Tom said:
A beginner question for sure, but one on which I'm stuck: I'm trying to
determine if it's possible, by any means whatsoever, to display a line
of text on the console and allow the user to edit it, before pressing
Enter to cause it to be read back in. As far as I can tell, this is only
possible in a GUI display object. Before I move in that direction I
thought I'd check to see if I've missed anything.

Thanks for any help anyone has.

t.

I dont quite understand why you would in fact want to have a line of
text that can be edited in a console...They would have to backspace to
change anything which would defeat the purpose. A GUI would be the way
to go in this case, and if u need help with that just say so. :)
 
T

Tom Cloyd

Thanks. You are, of course, right. I'm a Windows refugee in the process
of moving to Kubuntu, and I have little experience with the console, so
I overlooked this obvious fact about having to backspace. Ooops. So, GUI
it is. Onward!
 
M

Michael W. Ryder

Michael said:
I dont quite understand why you would in fact want to have a line of
text that can be edited in a console...They would have to backspace to
change anything which would defeat the purpose. A GUI would be the way
to go in this case, and if u need help with that just say so. :)

I have a C routine that does exactly this without using any GUI. It
recognizes the keys to move and edit. Since it does not display the
keys pressed I am not sure if this is possible in Ruby without using
something like Curses. The original version used the hardware directly
and will probably not work with most current Operating Systems but it
was an easy conversion to use Curses.
 
S

Sebastian Hungerecker

Michael said:
I dont quite understand why you would in fact want to have a line of
text that can be edited in a console... They would have to backspace to
change anything which would defeat the purpose.

No, they wouldn't. Do you have to hit backspace if you want to edit a command
in irb? Do you have to hit backspace to edit text in any non-GUI texteditor?

A GUI would be the way
to go in this case, and if u need help with that just say so. :)

A GUI or readline or curses.
 
J

John Joyce

For console-based apps, you really would do well with the NCurses
library.

The best documentation of it is a book that just came out by Dan
Gookin. Good writer. His work kicked off the entire line of for
Dummies books (even though some books in that line are terrible, but
not his).
NCurses is a C library, but there are some Ruby bindings to it.
 
T

Todd Burch

John said:
For console-based apps, you really would do well with the NCurses
library.

The best documentation of it is a book that just came out by Dan
Gookin. Good writer. His work kicked off the entire line of for
Dummies books (even though some books in that line are terrible, but
not his).
NCurses is a C library, but there are some Ruby bindings to it.

I just bought this book last week. Great book. First book I've even
bought where one of the appendices (Appendix A - NCurses library
reference) is the majority of the book.

Todd
 

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
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top