Tor Lillqvist wrote: > Øystein Johansen writes: > > However, I want to expand this to system to use automatic string > > completion, (the system provided in glib), for all available > > commands. Now it only handles command as I press enter. I guess I > > need a extra callback for each keypress. This callback can check if > > I press <TAB> and then call g_completion_complete(), but how do I > > attach such a signal to the main loop? > > Ah, I forgot to answer this part. I am afraid you might run into > difficulty in doing this on Win32. > > Or maybe it isn't that hard? There is an API SetConsoleMode(), and > mode bits like "ENABLE_ECHO_INPUT" and "ENABLE_LINE_INPUT", so maybe > it's actually quite similar to Unix, and you can do > character-at-a-time input, and your own echo processing. Maybe all you > need to do is something like > > GetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), &mode); > mode &= ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT); > SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), mode); > > and it will Just Work? Wow! I just tried this, and it does indeed Just Work! Thanks. I must handle all the characters like backspace and return and so on, but it works... But, it doesn't work on linux.... How can I get character-at-a-time input from a linux console? -Øystein
Attachment:
signature.asc
Description: OpenPGP digital signature