Re: Main Loop, IO Channels and my CLI



Ø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? 

--tml




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]