Re: Main Loop, IO Channels and my CLI



Ø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().

Then:
Can this be a bug? It work fine unless I use a special scandinavian
letter in my commands. Do I have to convert my string at any time? How?
(I'm using win32 command prompt window)

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.

Cheers,
                       -Tristan




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