Window creation/X11: Difference between revisions
Content added Content deleted
(omit autohotkey) |
(→Common Lisp: new example) |
||
Line 61: | Line 61: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Common Lisp}}== |
|||
{{trans|C}} |
|||
{{libheader|CLX}} |
|||
This example uses CLX, which is the de facto standard X11 library for Common Lisp. CLX is not a binding to Xlib; it is a Lisp library implementing the X11 protocol. |
|||
Note: This example was written in near-total ignorance of X11 by consulting the [http://www.cliki.net/CLX%20Manual CLX manual] to find equialents for the parts of the C example. It was also only tested with [[Mac OS X]] X11, which is not exactly normal. Do not take it as an complete example, well-tested, or good style. [Do, however, remove this disclaimer if you know better and have checked it.] |
|||
<lang lisp>;;; Single-file/interactive setup; large applications should define an ASDF system instead |
|||
(cl:require :asdf) |
|||
(asdf:operate 'asdf:load-op :clx) |
|||
(cl:defpackage #:rc-xlib-window |
|||
(:use #:cl #:xlib)) |
|||
(cl:in-package #:rc-xlib-window) |
|||
(let ((display (open-default-display))) |
|||
(unwind-protect |
|||
(let* ((window (create-window :parent (screen-root (display-default-screen display)) |
|||
:x 10 |
|||
:y 10 |
|||
:width 100 |
|||
:height 100 |
|||
:event-mask '(:exposure :key-press))) |
|||
(gc (create-gcontext :drawable window))) |
|||
(map-window window) |
|||
(event-case (display :discard-p t) |
|||
(exposure () |
|||
(draw-rectangle window gc 20 20 10 10 t) |
|||
(draw-glyphs window gc 10 40 "Hello, World!") |
|||
nil #| continue receiving events |#) |
|||
(key-press () |
|||
t #| non-nil result signals event-case to exit |#)))) |
|||
(close-display display))</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |