mayer@hplabsz.HPL.HP.COM (Niels Mayer) (12/07/89)
In article <1795@accuvax.nwu.edu> sandell@ferret.ils.nwu.edu (Greg Sandell) writes: > >I would like to hear from anybody who is involved (or has been involved) >in using X-Windows in a LISP environment. The obvious problem is that >there is a wealth of information on using X in a 'C' programming >environment, but very little with regard to LISP. I'm not sure I'd want to interface xlib to lisp at all, or if I did, just do so minimally. Most people wouldn't want to use Xlib in C, why should they have to put up with that level of detail in a high-level language like Lisp? Personally, I've found that the Xtoolkit + the Motif widget set makes for an excellent interface at the lisp level. Furthermore, I've found that large lisp systems, such as any Common Lisp runing on unix, are a big hinderance in creating applications that can be delivered to customers. These "professional" Lisp systems have earned a well-deserved reputation as being big & slow processes that swap/thrash out all your other applications -- that's not acceptable if you are trying to create an application that works alongside other tools in a Unix system. To add insult to injury, when you finally deliver your CL application you or your customers/users often get to pay a licencing fee for the lisp subsystem embedded in the application. That situation certainly wasn't going to get us anywhere in our research in building and evaluating CSCW, groupware and multimedia applications. The usefulness of such systems can rarely be demonstrated by demoing "laboratory curiosity" applications; evaluating such technologies requires applications be delivered to early adopters of the technology with a minimum of extraneous hassles (e.g. runtime licenses, huge systems) and that the delivered application be customizable so that it can be integrated into the environment of a particular workgroup. To this end, I created WINTERP as a platform for our work, and it has turned out to be a very useful tool that I wanted to share with others. WINTERP is now available via anonymous ftp at expo.lcs.mit.edu:contrib/winterp.tar.Z and will hopefully appear on the X11r4 contrib tape. It is a rapid prototyping, development, and delivery environment for applications using the MOTIF user interface toolkit. WINTERP is based on David Betz's XLISP interpreter (comp.lang.lisp.x), which is a small subset of Common Lisp that runs on PC's. WINTERP makes extensive use of XLISP's Smalltalk-like extensions for object oriented programming: All the Motif widget classes are actually implemented as XLISP classes, Xtoolkit functions become methods on the widget base class. Motif "Convenience Functions" become methods on particular classes. Because Motif Classes look like normal XLISP classes inside WINTERP, you may extend the functionality of existing widget classes in Lisp via subclassing, or by adding new methods to existing widget classes. An example is often more illustrative -- evaluating the following form in WINTERP results in the display of a "hello world" window which sends me mail and prints "hello world" on stdout each time the button is clicked: (let* ((top_w (send TOP_LEVEL_SHELL_WIDGET_CLASS :new :XMN_TITLE "hello world" ;note auto string->XmString conv :XMN_ICON_NAME "hello world")) ;ditto (but_w (send XM_PUSH_BUTTON_WIDGET_CLASS :new :managed top_w :XMN_FOREGROUND "red" ;note auto string->Pixel conv :XMN_BACKGROUND "black" :XMN_FONT_LIST "8x16")) ;note auto string->FontList cv ) (send but_w :add_callback :XMN_ARM_CALLBACK '() '((system "echo \"Hello World Run!\" | mailx mayer@hplabs.hp.com") (format t "hello world\n"))) (send top_w :realize) ) WINTERP should run on any unix system that can run Xwindows and TCP Sockets. WINTERP has been tested on HP9000s3xx (68030), HP9000s8xx (HP PA-RISC), and Sun 3's. The directory expo.lcs.mit.edu:contrib/WINTERP.binary contains compiled binaries for running WINTERP on HPUX systems. Unlike Elk, WINTERP requires no assembly language and is fully interactive. WINTERP is not a builder, although it has features that allow you to interactively send arbitrary messages to widget-objects by mousing on a widget. Many builder like features could be added to WINTERP by writing WINTERP-lisp code to exend it's functionality. Similarly, WINTERP isn't a UIMS, although it could serve as a good platform for building a UIMS. I know of one user that is planning to use WINTERP as a UIMS for a larger program implemented in Lucid Common Lisp: Since WINTERP's lisp listener is a TCP socket, it is easy to send commands to WINTERP from other applications. XLISP makes it very easy to add new language primitives as interfaces to other C-implemented user-code or libraries. Thus, programming with WINTERP is often a hybrid of lisp and C programming. An application may be prototyped in WINTERP-lisp, but previously existing code, low level routines, other libraries, etc can be added at the C level. Once prototype code has evolved and stabilized, one may want to recode the implementation of some modules in C while maintaining the same lisp interface to the rest of the system. Applications can thus *evolve* from prototype to deliverable, instead of forcing them to be recoded under a delivery platform. ============================================================================== For more information, this is the README file for WINTERP: INTRODUCTION: ============= WINTERP is a rapid prototyping, development and delivery enviropnment for building complex, customizable applications. It uses the OSF Motif Toolkit, which is based on the X11 Xtoolkit intrinsics. WINTERP contains a small lisp interpreter which is based on the popular XLISP interpreter. Infact the name "WINTERP" is just an abbreviation for "Widget INTERPreter". As an application prototyping environment, WINTERP is akin to a graphical gnuemacs in that it uses a mini-lisp interpreter to glue together various C-Implemented primitive operations. In gnuemacs, these operations consist mostly of manipulating text within editor buffers -- infact text-buffers are a "first-class" type in gnuemacs. WINTERP makes the widget a first class type, and represents them as real objects using the XLISP object system (a smalltalk-like object system). The syntax resulting from marrying XLISP objects and motif widgets is far cleaner than UIL, using straight C, etc. Furthermore, since WINTERP is interactive, you can try out small changes incrementally, and modify the look and functionality of an application on-the-fly. A very useful interactive primitive, 'get_moused_widget' allows you to send arbitrary messages to widgets just by pointing at them with the mouse. WINTERP contains an interface to gnuemacs' lisp-mode which allows you to type lisp forms into a gnuemacs editor buffer, and issue a simple command to send a form off to WINTERP's lisp-listener for evaluation. WINTERP's lisp-listener is infact a TCP socket, which means that you can easily allow other applications to talk to a WINTERP-based application. In directory ./WINTERP/src-client, you'll find the WINTERP client program 'wl' which sends the lisp form specified on it's command line off to the WINTERP server (./WINTERP/src-server/WINTERP). In the same directory, you'll find the emacs-lisp customization file 'WINTERP.el' which talks to the WINTERP server via 'wl'. ------------------------------------------------------------------------------ RUNNING WINTERP: ================ 1) start up the WINTERP program (./winterp/src-server/winterp) in a terminal emulator window. WINTERP will then popup a small "quit-button" and will proceed to send the results of lisp evaluation to stdout and stderr. If you give it the right lisp input, it will begin popping up windows too... 2) make sure you've installed the WINTERP client program './winterp/src-client/wl' somewhere on your search path; start up gnuemacs. 3) In gnuemacs, load the emacs-lisp file ./winterp/src-client/winterp.el. (Use M-x load-file, or do (load "<pathname>/winterp") in your ~/.emacs file) 4) in gnuemacs, visit one of the example programs in ./winterp/examples: a good start might be the simple search browser application built upon the unix 'grep' command -- ./winterp/examples/grep-br.lsp'. After visiting the file, the buffer you're in should be in 'lisp'-mode. Place the point somewhere within a lisp s-expression (aka, inbetween the opening and closing parens of a lisp statement), and hit C-M-X to send the expression you're pointing at to WINTERP. If you don't like hitting C-M-X, you can rebind the gnuemacs function winterp-send-defun to a more accessible key. 5) browse around the various files in winterp/examples and evaluate various forms.... If you don't use gnuemacs, you can still send lisp input to WINTERP, although it's much less elegant. While WINTERP is running inside a terminal emulator, just use the 'wl' command to send forms to the lisp interpreter. For example assuming you started WINTERP while cd'd to ./winterp/examples, just issue the following command to the shell wl '(load "popup-menu")' The best way to see the power of combining Motif widgets with XLISP objects is to take a look at the ./winterp/examples directory, which contains a few interesting examples. (e.g mail-br.lsp, bitmap-br.lsp, grep-br.lsp) and a few files that should show you how to do things... ------------------------------------------------------------------------------ DOCUMENTATION: ============== XLISP -- see doc/xlisp.doc, doc/INFO2.0, doc/INFO2.1, doc/README.XLISP WINTERP -- I'm still writing up the documentation. the file doc/winterp.doc.raw may provide some hints on the methods and primitives added to XLISP for WINTERP. This file will eventually be transformed into the real documentation. ------------------------------------------------------------------------------ BUILDING WINTERP: ================ So far, WINTERP has run succesfully on the following machines/OS's * HP9000s3xx running HPUX 7.0 or HPUX 6.5 * HP9000s8xx running HPUX 7.0 or HPUX 3.1 * Sun 3 running the latest SunOS. I don't think you should have any problems getting WINTERP running on other machines. If you do, please tell me what you did to fix it. Oh, of course, you will need to have the OSF Motif widgets on your machine. ------------------------------------------------------------------------------- Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com Human-Computer Interaction Department Hewlett-Packard Laboratories Palo Alto, CA. *