David Lichteblau <[EMAIL PROTECTED]> writes:

> note that there is an (incomplete) curses interface for CMUCL (I can't
> find the URL right now, but IIRC it is even liked from the CMUCL
> homepage).
> 
> (Or are you the author of the code I'm thinking of...?)

It's Craig Brozefsky's, and it's called CURL.  Andreas Hinze pointed
me toward it, at http://www.red-bean.com/~craig/curl/ .  He doesn't
seem to have touched it for a few years, though.

I looked at it for a while, but one of the things I don't like about
it is that it is based on CLOS.  I wanted to provide a library that
wouldn't require CLOS, but that would be CLOS friendly for developers
who wanted to build on it.  There's plenty of smaller programs that
could use ncurses that aren't complex enough to warrant a CLOS-based
design.

Of course, a CLIM interface is necessarily in CLOS.  But it shouldn't
be necessary to use CLIM to interface to ncurses.  IMHO.

> Also, I've got a curses interface 90% done.  It's not FFI-based, but
> written in (mostly) portable Lisp and portable C, using my
> world-controller script (that is, Unix domain sockets) to connect them.

Why did you not go the FFI route?  Seems to me that even though FFIs
are non-portable (although UFFI alleviates this to a certain extent),
doing things with an external process is more clumsy than the FFI
would be.

> Currently there are basic drawing and input functions and curses-based
> Gray streams (that is, trivial I/O like a CMUCL lisp REPL in a curses
> window works).  Mouse support is not done yet, but will be Real Soon
> Now.

Mouse support is actually pretty easy with ncurses.  It just requires
calling getch() and checking that KEY_MOUSE was returned, then using
the mouse functions to get mouse events from the special mouse event
queue.  Deciphering the mouse events of course requires bit bashing,
but that can be easily encapsulated.

One *super important* thing to know is that although much of ncurses
is implemented in CPP macros there is a magic switch you can turn on
to replace all the macros with real functions.  This is necessary for
using ncurses with C++, for example.  Or with Objective C.  It also
makes most of the nasty stuff you have to do with bit manipulation
unnecessary, because you don't have to duplicate all the CPP macros in
Lisp.  My solution was to build a small C object with no code in it
that sets the magic switch (-DNCURSES_NOMACROS) and then includes the
ncurses.h header.  Loading this into Lisp makes all the functions
available, with no (well, nearly no) CPP macro requirements.

'james

-- 
James A. Crippen <[EMAIL PROTECTED]> ,-./-.  Anchorage, Alaska,
Lambda Unlimited: Recursion 'R' Us   |  |/  | USA, 61.20939N, -149.767W
Y = \f.(\x.f(xx)) (\x.f(xx))         |  |\  | Earth, Sol System,
Y(F) = F(Y(F))                        \_,-_/  Milky Way.

Reply via email to