forked from Shirakumo/trial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.lisp
38 lines (29 loc) · 1.02 KB
/
window.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#|
This file is a part of trial
(c) 2016 Shirakumo http://tymoon.eu ([email protected])
Author: Nicolas Hafner <[email protected]>
|#
(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))