-
Notifications
You must be signed in to change notification settings - Fork 7
/
tree.lisp
54 lines (44 loc) · 1.58 KB
/
tree.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;;; Generated from org-mode, do not edit
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload '("iup" "iup-controls" "uiop")))
(defpackage #:iup-examples.tree
(:use #:common-lisp)
(:export #:tree))
(in-package #:iup-examples.tree)
(defun get-dir (pathname)
(assert (uiop:directory-pathname-p pathname))
(loop for pathname in (uiop:directory* (make-pathname :name :wild :defaults pathname))
if (uiop:directory-pathname-p pathname)
collect pathname into dirs
else
collect pathname into files
finally (return (values dirs files))))
(defun fill-tree (tree id pathname)
(multiple-value-bind
(dirs files)
(get-dir pathname)
(dolist (file files)
(setf (iup:attribute tree :addleaf) (namestring file)))
(dolist (dir dirs)
(setf (iup:attribute tree :addbranch) (namestring dir)))
(setf (iup:attribute tree :title) (namestring pathname))))
(defun map-callback (handle)
(fill-tree handle 0 "/")
iup:+default+)
(defun branchopen-callback (handle id)
(setf (iup:attribute handle (format nil "DELNODE~A" id)) "CHILDREN")
(fill-tree handle id (iup:attribute handle (format nil "TITLE~A" id)))
iup:+default+)
(defun tree ()
(iup:with-iup ()
(let* ((tree (iup:tree :minsize "200x300"
:map_cb 'map-callback
:branchopen_cb 'branchopen-callback))
(dialog (iup:dialog tree :title "Tree Example")))
(iup:show dialog)
(iup:main-loop))))
#-sbcl (tree)
#+sbcl
(sb-int:with-float-traps-masked
(:divide-by-zero :invalid)
(tree))