Re: listening to stdin in the controlling terminal after gtk_main is called



Well thank you Ben for your very speedy reply.

I'll see what i can do with it.

dan

On Wed, Sep 14, 2016 at 10:06 PM, Ben Iofel <iofelben gmail com> wrote:
create a GIOChannel with g_io_channel_unix_new() and then add it to the main
context with g_io_add_watch()

On Thu, Sep 15, 2016 at 12:52 AM Dan Hitt <dan hitt gmail com> wrote:

HI All,

I'm writing a gtk application and i would like it to listen to stdin
in the controlling terminal after gtk_main() is called.

So for example, when you type a carriage return in the controlling
terminal, all the characters which have been typed since the last
carriage return are gathered up into a string, and the app receives
some event containing the string, and it has some handler that can
interpret and deal with it.

This would be analogous to listening for key presses in a window,
except that they don't come from a window, and instead of arriving a
character at a time they'd arrive a string at a time.

Now, i imagine it cannot be quite that simple, because that doesn't
sound like any of the events listed in gdkevents.h.

But on the other hand something along these lines must be possible
since applications like mpv certainly do listen to their stdin and
respond to it (as well as listening to characters that are typed to
their windows).

And there should be a select() or something to make it possible for an
apparatus such as gtk to do this.

And i don't even know how to google around for a solution :(

So i'd appreciate any hints on how to do this.

(And although it would be awesome to be able to read a character at a
time from stdin, a line at a time would certainly do, and i'd probably
have to plan on line-at-a-time anyway for the case when the app was
launched from a emacs buffer.)

TIA!

dan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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