Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 1.02 KB
#|
This file is a part of trial
(c) 2016 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:org.shirakumo.fraf.trial)
(defvar *windows* ())
(defun window (name &optional (errorp T))
(or (etypecase name
((and symbol (not null)) (find name *windows* :key #'name))
(integer (nth name *windows*)))
(when errorp (error "No window with name ~s found." name))))
(defun register-window (window)
(when (and (name window) (window (name window) NIL))
(cerror "Override the window." "There already is a window with name ~s." (name window)))
(push window *windows*)
window)
(defun deregister-window (window)
(setf *windows* (remove window *windows*))
window)
(defun list-windows ()
*windows*)
(defclass window ()
((name :initarg :name :accessor name))
(:default-initargs :name NIL))
(defmethod initialize-instance :after ((window window) &key)
(register-window window))
(defmethod finalize :after ((window window))
(deregister-window window))