guile-gtk-general
[Top][All Lists]
Advanced

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

GdkEvent and... a REPL!


From: Andy Wingo
Subject: GdkEvent and... a REPL!
Date: Thu, 23 Oct 2003 22:37:52 +0200
User-agent: Mutt/1.5.4i

Hey again,

I made some simple wrappings for GdkEvent. It's just one function,
gdk-event->event-struct, that has to be implemented for each kind of
event. Right now it's only implemented for GdkEventKey.

And with that, I now have a working graphical REPL. Woop! I was thinking
before about using a terminal and trying to emulate termminal control
characters and such to do line editing, but then it dawned on me how
stupid that was. I also did some googling and found Neil Jerram's work
on guile-gui, and decided to steal it. It's GPL. Marius, maybe he needs
papers? Dunno.

But the essence of the solution is that it's a GtkTextView<->GtkEntry
pair, although both are subclassed. The TextView is written to on a soft
output port, and the entry is read from on a soft input port. It uses
Neil's continuation-passing code (similar to what is in
continuations.scm) to only return from a read on entry activation. So
it's just a normal top-repl that reads from widgets instead of the
console. Rather elegant if you ask me.

I chose to go with the GtkEntry-style interface because GtkEntry already
has a lot of keybindings, you can mouse around in it if you want, and
Neil's code does history (kindof flaky right now, but it's probably my
fault) and parenthesis matching. Neat-o!

There are still some issues, but it's definitely worth a try. It's
especially nice in guile-gtk, because you can interact with Gtk+ and the
REPL at the same time. It doesn't take any more time to load up, either,
since you have to load (gnome gtk) either way.

You can find the code in gnome/gtk/graphical-repl.scm and
examples/gtk/repl.scm.

Cheers,

wingo.




reply via email to

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