;;;; This file is part of cl-ncurses, an ncurses interface for Common Lisp, ;;;; Copyright (c) 2004 Marcelo Ramos ;;;; ;;;; Permission is hereby granted, free of charge, to any person obtaining ;;;; a copy of this software and associated documentation files (the ;;;; "Software"), to deal in the Software without restriction, including ;;;; without limitation the rights to use, copy, modify, merge, publish, ;;;; distribute, sublicense, and/or sell copies of the Software, and to ;;;; permit persons to whom the Software is furnished to do so, subject to ;;;; the following conditions: ;;;; ;;;; The above copyright notice and this permission notice shall be included ;;;; in all copies or substantial portions of the Software. ;;;; ;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ;;;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ;;;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ;;;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (in-package :cl-user) (eval-when (:execute :load-toplevel :compile-toplevel) (defpackage :cl-ncurses (:use :cl :uffi) (:export "*STDSCR*" "*LINES*" "*COLS*"))) (in-package :cl-ncurses) (defvar *ncurses-search-paths* '("/usr/local/lib/" "/usr/lib/" "/lib/") "The paths where to search the ncurses shared library") (defparameter *ncurses-path* (find-foreign-library "libncurses" *ncurses-search-paths* :drive-letters '("C" "D" "E") :types '("so" "a" "dylib" "dll"))) (cond (*ncurses-path* (format t "~&;;; Loading ~s" *ncurses-path*) (load-foreign-library *ncurses-path* :module "cl-ncurses")) (t (warn "Unable to load ncurses."))) ; Types (def-foreign-type bool :int) (def-foreign-type char-ptr :pointer-void) (def-foreign-type chtype :int) (def-foreign-type file-ptr :pointer-void) (def-foreign-type screen-ptr :pointer-void) (def-foreign-type window-ptr :pointer-void) ; null pointer to fill not used arguments required by ; some functions (e.g. wcolor-set and color-set) (defconstant *NULLPTR* +null-cstring-pointer+) (defmacro def (ret args &rest names) "A convenience macro for UFFI definitions." `(progn ,@(mapcar (lambda (name) `(export (def-function ,name ,args :module "cl-ncurses" :returning ,ret))) names)))