# Is possible to edit text field in console?

**URL:** <https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678>\
**Category:** ruby-talk\
**Created:** [17 September 2007 05:18 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678 "2007-09-17T05:18:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Cloyd](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Cloyd](https://rubytalk.org/u/Tom_Cloyd)\
**Post date:** [17 September 2007 05:18 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/1 "2007-09-17T05:18:45Z")

</div>

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.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Jon\_Hawkins](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@Jon\_Hawkins](https://rubytalk.org/u/Jon_Hawkins)\
**Post date:** [17 September 2007 06:52 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/2 "2007-09-17T06:52:02Z")

</div>

Tom Cloyd wrote:

> 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. 🙂

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Tom\_Cloyd](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Cloyd](https://rubytalk.org/u/Tom_Cloyd)\
**Post date:** [17 September 2007 07:19 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/3 "2007-09-17T07:19:38Z")

</div>

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!

Michael Linfield wrote:

> **···**
>
> > Tom Cloyd wrote:
> > 
> > > 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. 🙂
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Michael\_W\_Ryder1](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Michael\_W\_Ryder1](https://rubytalk.org/u/Michael_W_Ryder1)\
**Post date:** [17 September 2007 07:50 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/4 "2007-09-17T07:50:19Z")

</div>

Michael Linfield wrote:

> Tom Cloyd wrote:
> 
> > 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. 🙂

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.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Hungereck1](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@Sebastian\_Hungereck1](https://rubytalk.org/u/Sebastian_Hungereck1)\
**Post date:** [17 September 2007 09:14 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/5 "2007-09-17T09:14:17Z")

</div>

Michael Linfield wrote:

> 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.

> **···**
>
> --  
> Jabber: sepp2k@jabber.org  
> ICQ: 205544826

---

<div class="post-metadata">

**Author:** ![James\_Britt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@James\_Britt](https://rubytalk.org/u/James_Britt)\
**Post date:** [17 September 2007 15:26 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/6 "2007-09-17T15:26:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Todd\_Burch](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Todd\_Burch](https://rubytalk.org/u/Todd_Burch)\
**Post date:** [17 September 2007 16:13 UTC](https://rubytalk.org/t/is-possible-to-edit-text-field-in-console/40678/7 "2007-09-17T16:13:10Z")

</div>

John Joyce wrote:

> 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

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
