tags:

views:

39

answers:

1

I use editline library in my program, for user commands input in shell. But becides shell, program have a gui interface, so I need to run editline's readline() function in separate thread, because it blocks until Enter pressed. Is there a way to use readline() function without blocking, so I could avoid separate thread usage?

A: 

Why not making the GUI thread run in a different thread and leave the console input in the main thread. You can push events to the GUI thread after reading from command line. It is much simpler in my opinion.

This works of course if your GUI allows you to run it in a different thread than the main one.

LATER EDIT: Couldn't you just create a text control/window and take the input from there? Once you press Enter it clears input - just like typing messages at a console? I believe it is much simpler to have everything in the GUI

Iulian Şerbănoiu
The problem is that I have a restriction and program will be executed in one thread.
Sasun Hambardzumyan
see my later edit above
Iulian Şerbănoiu