简体   繁体   中英

Editline with non-blocking input

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM