guile-user
[Top][All Lists]
Advanced

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

Re: emebedding guile line command interpretor


From: Neil Jerram
Subject: Re: emebedding guile line command interpretor
Date: 05 Feb 2001 22:43:49 +0000

>>>>> "Georges" == Georges KO <address@hidden> writes:

    Georges> Neil Jerram <address@hidden> writes:
    >> You really need to provide more details of your scenario.

    [ details - thanks ]

    >> Broadly, you have three options:
    >> 
    >> 1. Run the GUI and the guile shell in different threads, with
    >> each thread waiting only for its own input.

    [ ... ]

    Georges>     That way, Dr Geo would be programmable in any
    Georges> language, as long as it can spit expressions
    Georges> understandable by the Guile part of Dr Geo...

This is the plan for Guile in general.  The tricky part is the "as
long as it can spit expressions understandable by the Guile part".
Please be sure to let the Guile maintainers know if you make any big
progress on this!

    >> 2. Give control to the guile shell, and write an input port
    >> that selects for input for both the shell and the GUI.  3. Give
    >> control to the GUI, and tell the GUI to check also for input
    >> for the guile shell (if it supports such function).
    >> 
    >> So, is this the problem?  If so, what is the GUI written in?
    >> (X, Gtk, ...)

    Georges>     GTk.

Right.  Personally, I'd go for option 3.  To see roughly what you need
to do, take a look at the files gtk-1.2/gtk.scm and gtk/event-repl.scm
in the guile-gtk distribution.  In summary:

- Use gtk-input-add to specify a file descriptor and a non-blocking
  read procedure for input into the Guile repl.  Whenever the read
  procedure reads some characters into its buffer, it calls (read) --
  via repl-input and a soft port -- to find out whether it has a
  complete expression yet; if it has, it evaluates it.

- Call gtk-main.

This is good if you're happy for the Guile repl to use standard input
and output.  But you probably prefer it to be in another window.  This
will make the input side easier but the output side harder.

On the input side, you don't need gtk-input-add anymore, as Gtk
already monitors input from all your application's windows.  Instead,
you just need to call repl-input from your character event handler for
that window.

On the output side, you need to persuade readline to display to a Gtk
widget rather than to a terminal.  A quick look at the readline manual
suggests that you might be able to do this using
rl_redisplay_function.

Regards,
        Neil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]