0

I am reading user input text with getstr(). Instead of waiting for the user to press enter, I would like to read the input each time it is changed and re-render other parts of the screen based on the input.

Is this possible with getstr()? How? If not, what's the simplest/easiest alternative?

jdeo
  • 1

1 Answers1

0

Not with getstr(), but it's certainly possible with curses. You just have to read each keypress one at a time, via getch() -- and, if you want an editable buffer, you have to recreate something like the functionality of getstr() yourself. (I'd post an example, but what I have is in C rather than Python.)

William McBrine
  • 2,166
  • 11
  • 7
  • That would be quite a bit of work for something relatively simple that I am trying to achieve. In the python curses modules there is a textbox object that apparently supports the typical readline capabilities. I could spawn another thread and read from it using its gather() method, at least if it does what I think it does. I will try, hopefully getch() still works while editing a textbox on other thread. This way I can use it to detect changes... If there's an easier way to do this, please post it. – jdeo Jul 08 '15 at 22:21
  • please post your example in C. I did what I described in my last comment but there are many issues such as the cursor jumping around. – jdeo Jul 10 '15 at 08:38