Tristan Van Berkom wrote: > Øystein Johansen wrote: > >> Hi, >> >> I've just made a small glib code that read commands from from a command >> line interface prompt. It uses g_main_loop and a g_io_channel. I've >> attached the code. >> >> First: >> It nearly works as expected. The callback is called each time I enter a >> command, and it's parsed to the command handler. 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? >> >> >> > You need to get raw keyboard input from your terminal, in unix > you can use tcsetattr(). > >> Example: >> myprompt> hello >> You typed: hello >> myprompt> Æsop >> >> ** (gnubg.exe:3128): WARNING **: Something went wrong >> Invalid byte sequence in conversion input > You might want to change the encoding on the io > channel.. if you set it to NULL then it should work. Thank you! Adding this line: g_io_channel_set_encoding (channel, NULL, &error); makes it work. Thank you! Now let me try finding the right codepage as Tor suggests. Hmmm.... gcc -o mycli commandsystem.o -LC:/GTK/lib -lglib-2.0 -lintl -liconv -lkernel32 commandsystem.o(.text+0x3f):commandsystem.c: undefined reference to `GetConsoleCP' It doesn't link? (Yes, I do add -lkernel32) -Øystein
Attachment:
signature.asc
Description: OpenPGP digital signature