Mercurial > emacs
annotate lisp/tree-widget.el @ 68278:125d04254c22
(custom-buffer-create-internal): State in the text above
the whole buffer buttons that they do not operate on hidden items.
(custom-face-menu): Use `custom-face-save' instead of
`custom-face-save-command'.
(custom-face-save-command): Make it an alias for `custom-face-save'
and declare it obsolete.
(custom-face-save): Doc fix.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Thu, 19 Jan 2006 23:26:04 +0000 |
parents | 5955934355f2 |
children | 3bd95f4f2941 |
rev | line source |
---|---|
55588 | 1 ;;; tree-widget.el --- Tree widget |
2 | |
63465
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
55588 | 4 |
5 ;; Author: David Ponce <david@dponce.com> | |
6 ;; Maintainer: David Ponce <david@dponce.com> | |
7 ;; Created: 16 Feb 2001 | |
8 ;; Keywords: extensions | |
9 | |
10 ;; This file is part of GNU Emacs | |
11 | |
12 ;; This program is free software; you can redistribute it and/or | |
13 ;; modify it under the terms of the GNU General Public License as | |
14 ;; published by the Free Software Foundation; either version 2, or (at | |
15 ;; your option) any later version. | |
16 | |
17 ;; This program is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with this program; see the file COPYING. If not, write to | |
64091 | 24 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
55588 | 26 |
27 ;;; Commentary: | |
28 ;; | |
29 ;; This library provide a tree widget useful to display data | |
30 ;; structures organized in a hierarchical order. | |
31 ;; | |
32 ;; The following properties are specific to the tree widget: | |
33 ;; | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
34 ;; :open |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
35 ;; Set to non-nil to expand the tree. By default the tree is |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
36 ;; collapsed. |
55588 | 37 ;; |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
38 ;; :node |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
39 ;; Specify the widget used to represent the value of a tree node. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
40 ;; By default this is an `item' widget which displays the |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
41 ;; tree-widget :tag property value if defined, or a string |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
42 ;; representation of the tree-widget value. |
55588 | 43 ;; |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
44 ;; :keep |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
45 ;; Specify a list of properties to keep when the tree is collapsed |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
46 ;; so they can be recovered when the tree is expanded. This |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
47 ;; property can be used in child widgets too. |
55588 | 48 ;; |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
49 ;; :expander (obsoletes :dynargs) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
50 ;; Specify a function to be called to dynamically provide the |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
51 ;; tree's children in response to an expand request. This function |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
52 ;; will be passed the tree widget and must return a list of child |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
53 ;; widgets. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
54 ;; |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
55 ;; *Please note:* Child widgets returned by the :expander function |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
56 ;; are stored in the :args property of the tree widget. To speed |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
57 ;; up successive expand requests, the :expander function is not |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
58 ;; called again when the :args value is non-nil. To refresh child |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
59 ;; values, it is necessary to set the :args property to nil, then |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
60 ;; redraw the tree. |
55588 | 61 ;; |
64985 | 62 ;; :open-icon (default `tree-widget-open-icon') |
63 ;; :close-icon (default `tree-widget-close-icon') | |
64 ;; :empty-icon (default `tree-widget-empty-icon') | |
65 ;; :leaf-icon (default `tree-widget-leaf-icon') | |
66 ;; Those properties define the icon widgets associated to tree | |
67 ;; nodes. Icon widgets must derive from the `tree-widget-icon' | |
68 ;; widget. The :tag and :glyph-name property values are | |
69 ;; respectively used when drawing the text and graphic | |
70 ;; representation of the tree. The :tag value must be a string | |
71 ;; that represent a node icon, like "[+]" for example. The | |
72 ;; :glyph-name value must the name of an image found in the current | |
73 ;; theme, like "close" for example (see also the variable | |
74 ;; `tree-widget-theme'). | |
55588 | 75 ;; |
64985 | 76 ;; :guide (default `tree-widget-guide') |
77 ;; :end-guide (default `tree-widget-end-guide') | |
78 ;; :no-guide (default `tree-widget-no-guide') | |
79 ;; :handle (default `tree-widget-handle') | |
80 ;; :no-handle (default `tree-widget-no-handle') | |
81 ;; Those properties define `item'-like widgets used to draw the | |
82 ;; tree guide lines. The :tag property value is used when drawing | |
83 ;; the text representation of the tree. The graphic look and feel | |
84 ;; is given by the images named "guide", "no-guide", "end-guide", | |
85 ;; "handle", and "no-handle" found in the current theme (see also | |
86 ;; the variable `tree-widget-theme'). | |
87 ;; | |
88 ;; These are the default :tag values for icons, and guide lines: | |
55588 | 89 ;; |
64985 | 90 ;; open-icon "[-]" |
91 ;; close-icon "[+]" | |
92 ;; empty-icon "[X]" | |
93 ;; leaf-icon "" | |
94 ;; guide " |" | |
95 ;; no-guide " " | |
96 ;; end-guide " `" | |
97 ;; handle "-" | |
98 ;; no-handle " " | |
55588 | 99 ;; |
64985 | 100 ;; The text representation of a tree looks like this: |
101 ;; | |
102 ;; [-] 1 (open-icon :node) | |
103 ;; |-[+] 1.0 (guide+handle+close-icon :node) | |
104 ;; |-[X] 1.1 (guide+handle+empty-icon :node) | |
105 ;; `-[-] 1.2 (end-guide+handle+open-icon :node) | |
106 ;; |- 1.2.1 (no-guide+no-handle+guide+handle+leaf-icon leaf) | |
107 ;; `- 1.2.2 (no-guide+no-handle+end-guide+handle+leaf-icon leaf) | |
55588 | 108 ;; |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
109 ;; By default, images will be used instead of strings to draw a |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
110 ;; nice-looking tree. See the `tree-widget-image-enable', |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
111 ;; `tree-widget-themes-directory', and `tree-widget-theme' options for |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
112 ;; more details. |
55588 | 113 |
114 ;;; History: | |
115 ;; | |
116 | |
117 ;;; Code: | |
118 (eval-when-compile (require 'cl)) | |
119 (require 'wid-edit) | |
120 | |
121 ;;; Customization | |
122 ;; | |
123 (defgroup tree-widget nil | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
124 "Customization support for the Tree Widget library." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
55594
diff
changeset
|
125 :version "22.1" |
55588 | 126 :group 'widgets) |
127 | |
128 (defcustom tree-widget-image-enable | |
129 (not (or (featurep 'xemacs) (< emacs-major-version 21))) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
130 "*Non-nil means that tree-widget will try to use images." |
55588 | 131 :type 'boolean |
132 :group 'tree-widget) | |
133 | |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
134 (defvar tree-widget-themes-load-path |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
135 '(load-path |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
136 (let ((dir (if (fboundp 'locate-data-directory) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
137 (locate-data-directory "tree-widget") ;; XEmacs |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
138 data-directory))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
139 (and dir (list dir (expand-file-name "images" dir)))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
140 ) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
141 "List of locations where to search for the themes sub-directory. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
142 Each element is an expression that will be evaluated to return a |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
143 single directory or a list of directories to search. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
144 |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
145 The default is to search in the `load-path' first, then in the |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
146 \"images\" sub directory in the data directory, then in the data |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
147 directory. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
148 The data directory is the value of the variable `data-directory' on |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
149 Emacs, and what `(locate-data-directory \"tree-widget\")' returns on |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
150 XEmacs.") |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
151 |
55588 | 152 (defcustom tree-widget-themes-directory "tree-widget" |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
153 "*Name of the directory where to look up for image themes. |
55588 | 154 When nil use the directory where the tree-widget library is located. |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
155 When a relative name is specified, try to locate that sub directory in |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
156 the locations specified in `tree-widget-themes-load-path'. |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
157 The default is to use the \"tree-widget\" relative name." |
55588 | 158 :type '(choice (const :tag "Default" "tree-widget") |
159 (const :tag "With the library" nil) | |
160 (directory :format "%{%t%}:\n%v")) | |
161 :group 'tree-widget) | |
162 | |
163 (defcustom tree-widget-theme nil | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
164 "*Name of the theme where to look up for images. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
165 It must be a sub directory of the directory specified in variable |
64985 | 166 `tree-widget-themes-directory'. The default theme is \"default\". |
167 When an image is not found in a theme, it is searched in the default | |
168 theme. | |
55588 | 169 |
64985 | 170 A complete theme must at least contain images with these file names |
171 with a supported extension (see also `tree-widget-image-formats'): | |
172 | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
173 \"guide\" |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
174 A vertical guide line. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
175 \"no-guide\" |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
176 An invisible vertical guide line. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
177 \"end-guide\" |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
178 End of a vertical guide line. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
179 \"handle\" |
64985 | 180 Horizontal guide line that joins the vertical guide line to an icon. |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
181 \"no-handle\" |
64985 | 182 An invisible handle. |
183 | |
184 Plus images whose name is given by the :glyph-name property of the | |
185 icon widgets used to draw the tree. By default these images are used: | |
186 | |
187 \"open\" | |
188 Icon associated to an expanded tree. | |
189 \"close\" | |
190 Icon associated to a collapsed tree. | |
191 \"empty\" | |
192 Icon associated to an expanded tree with no child. | |
193 \"leaf\" | |
194 Icon associated to a leaf node." | |
55588 | 195 :type '(choice (const :tag "Default" nil) |
196 (string :tag "Name")) | |
197 :group 'tree-widget) | |
198 | |
199 (defcustom tree-widget-image-properties-emacs | |
200 '(:ascent center :mask (heuristic t)) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
201 "*Default properties of Emacs images." |
55588 | 202 :type 'plist |
203 :group 'tree-widget) | |
204 | |
205 (defcustom tree-widget-image-properties-xemacs | |
206 nil | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
207 "*Default properties of XEmacs images." |
55588 | 208 :type 'plist |
209 :group 'tree-widget) | |
64985 | 210 |
211 (defcustom tree-widget-space-width 0.5 | |
212 "Amount of space between an icon image and a node widget. | |
213 Must be a valid space :width display property." | |
214 :group 'tree-widget | |
215 :type 'sexp) | |
55588 | 216 |
217 ;;; Image support | |
218 ;; | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
219 (eval-and-compile ;; Emacs/XEmacs compatibility stuff |
55588 | 220 (cond |
221 ;; XEmacs | |
222 ((featurep 'xemacs) | |
223 (defsubst tree-widget-use-image-p () | |
224 "Return non-nil if image support is currently enabled." | |
225 (and tree-widget-image-enable | |
226 widget-glyph-enable | |
227 (console-on-window-system-p))) | |
228 (defsubst tree-widget-create-image (type file &optional props) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
229 "Create an image of type TYPE from FILE, and return it. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
230 Give the image the specified properties PROPS." |
55588 | 231 (apply 'make-glyph `([,type :file ,file ,@props]))) |
232 (defsubst tree-widget-image-formats () | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
233 "Return the alist of image formats/file name extensions. |
55588 | 234 See also the option `widget-image-file-name-suffixes'." |
235 (delq nil | |
236 (mapcar | |
237 #'(lambda (fmt) | |
238 (and (valid-image-instantiator-format-p (car fmt)) fmt)) | |
239 widget-image-file-name-suffixes))) | |
240 ) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
241 ;; Emacs |
55588 | 242 (t |
243 (defsubst tree-widget-use-image-p () | |
244 "Return non-nil if image support is currently enabled." | |
245 (and tree-widget-image-enable | |
246 widget-image-enable | |
247 (display-images-p))) | |
248 (defsubst tree-widget-create-image (type file &optional props) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
249 "Create an image of type TYPE from FILE, and return it. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
250 Give the image the specified properties PROPS." |
55588 | 251 (apply 'create-image `(,file ,type nil ,@props))) |
252 (defsubst tree-widget-image-formats () | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
253 "Return the alist of image formats/file name extensions. |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
254 See also the option `widget-image-conversion'." |
55588 | 255 (delq nil |
256 (mapcar | |
257 #'(lambda (fmt) | |
258 (and (image-type-available-p (car fmt)) fmt)) | |
259 widget-image-conversion))) | |
260 )) | |
261 ) | |
262 | |
263 ;; Buffer local cache of theme data. | |
264 (defvar tree-widget--theme nil) | |
265 | |
266 (defsubst tree-widget-theme-name () | |
267 "Return the current theme name, or nil if no theme is active." | |
268 (and tree-widget--theme (aref tree-widget--theme 0))) | |
269 | |
270 (defsubst tree-widget-set-theme (&optional name) | |
271 "In the current buffer, set the theme to use for images. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
272 The current buffer must be where the tree widget is drawn. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
273 Optional argument NAME is the name of the theme to use. It defaults |
55588 | 274 to the value of the variable `tree-widget-theme'. |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
275 Does nothing if NAME is already the current theme." |
55588 | 276 (or name (setq name (or tree-widget-theme "default"))) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
277 (unless (string-equal name (tree-widget-theme-name)) |
55588 | 278 (set (make-local-variable 'tree-widget--theme) |
279 (make-vector 4 nil)) | |
280 (aset tree-widget--theme 0 name))) | |
281 | |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
282 (defun tree-widget--locate-sub-directory (name path) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
283 "Locate the sub-directory NAME in PATH. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
284 Return the absolute name of the directory found, or nil if not found." |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
285 (let (dir elt) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
286 (while (and (not dir) (consp path)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
287 (setq elt (condition-case nil (eval (car path)) (error nil)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
288 path (cdr path)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
289 (cond |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
290 ((stringp elt) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
291 (setq dir (expand-file-name name elt)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
292 (or (file-accessible-directory-p dir) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
293 (setq dir nil))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
294 ((and elt (not (equal elt (car path)))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
295 (setq dir (tree-widget--locate-sub-directory name elt))))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
296 dir)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
297 |
55588 | 298 (defun tree-widget-themes-directory () |
299 "Locate the directory where to search for a theme. | |
300 It is defined in variable `tree-widget-themes-directory'. | |
301 Return the absolute name of the directory found, or nil if the | |
302 specified directory is not accessible." | |
303 (let ((found (aref tree-widget--theme 1))) | |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
304 (cond |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
305 ;; The directory was not found. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
306 ((eq found 'void) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
307 (setq found nil)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
308 ;; The directory is available in the cache. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
309 (found) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
310 ;; Use the directory where this library is located. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
311 ((null tree-widget-themes-directory) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
312 (setq found (locate-library "tree-widget")) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
313 (when found |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
314 (setq found (file-name-directory found)) |
55588 | 315 (or (file-accessible-directory-p found) |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
316 (setq found nil)))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
317 ;; Check accessibility of absolute directory name. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
318 ((file-name-absolute-p tree-widget-themes-directory) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
319 (setq found (expand-file-name tree-widget-themes-directory)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
320 (or (file-accessible-directory-p found) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
321 (setq found nil))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
322 ;; Locate a sub-directory in `tree-widget-themes-load-path'. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
323 (t |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
324 (setq found (tree-widget--locate-sub-directory |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
325 tree-widget-themes-directory |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
326 tree-widget-themes-load-path)))) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
327 ;; Store the result in the cache for later use. |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
328 (aset tree-widget--theme 1 (or found 'void)) |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
329 found)) |
55588 | 330 |
331 (defsubst tree-widget-set-image-properties (props) | |
332 "In current theme, set images properties to PROPS." | |
333 (aset tree-widget--theme 2 props)) | |
334 | |
335 (defun tree-widget-image-properties (file) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
336 "Return the properties of an image in current theme. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
337 FILE is the absolute file name of an image. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
338 |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
339 If there is a \"tree-widget-theme-setup\" library in the theme |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
340 directory, where is located FILE, load it to setup theme images |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
341 properties. Typically it should contain something like this: |
55588 | 342 |
343 (tree-widget-set-image-properties | |
344 (if (featurep 'xemacs) | |
345 '(:ascent center) | |
346 '(:ascent center :mask (heuristic t)) | |
347 )) | |
348 | |
64985 | 349 When there is no \"tree-widget-theme-setup\" library in the current |
350 theme directory, load the one from the default theme, if available. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
351 Default global properties are provided for respectively Emacs and |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
352 XEmacs in the variables `tree-widget-image-properties-emacs', and |
55588 | 353 `tree-widget-image-properties-xemacs'." |
354 ;; If properties are in the cache, use them. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
355 (let ((plist (aref tree-widget--theme 2))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
356 (unless plist |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
357 ;; Load tree-widget-theme-setup if available. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
358 (load (expand-file-name "tree-widget-theme-setup" |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
359 (file-name-directory file)) t t) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
360 ;; If properties have been setup, use them. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
361 (unless (setq plist (aref tree-widget--theme 2)) |
64985 | 362 ;; Try from the default theme. |
363 (load (expand-file-name "../default/tree-widget-theme-setup" | |
364 (file-name-directory file)) t t) | |
365 ;; If properties have been setup, use them. | |
366 (unless (setq plist (aref tree-widget--theme 2)) | |
367 ;; By default, use supplied global properties. | |
368 (setq plist (if (featurep 'xemacs) | |
369 tree-widget-image-properties-xemacs | |
370 tree-widget-image-properties-emacs)) | |
371 ;; Setup the cache. | |
372 (tree-widget-set-image-properties plist)))) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
373 plist)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
374 |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
375 (defconst tree-widget--cursors |
65747
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
376 ;; Pointer shapes when the mouse pointer is over inactive |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
377 ;; tree-widget images. This feature works since Emacs 22, and |
cfaa6269b03d
(tree-widget-themes-load-path): New variable.
David Ponce <david@dponce.com>
parents:
65649
diff
changeset
|
378 ;; ignored on older versions, and XEmacs. |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
379 '( |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
380 ("guide" . arrow) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
381 ("no-guide" . arrow) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
382 ("end-guide" . arrow) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
383 ("handle" . arrow) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
384 ("no-handle" . arrow) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
385 )) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
386 |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
387 (defun tree-widget-lookup-image (name) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
388 "Look up in current theme for an image with NAME. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
389 Search first in current theme, then in default theme (see also the |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
390 variable `tree-widget-theme'). |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
391 Return the first image found having a supported format, or nil if not |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
392 found." |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
393 (let ((default-directory (tree-widget-themes-directory))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
394 (when default-directory |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
395 (let (file (theme (tree-widget-theme-name))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
396 (catch 'found |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
397 (dolist (dir (if (string-equal theme "default") |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
398 '("default") (list theme "default"))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
399 (dolist (fmt (tree-widget-image-formats)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
400 (dolist (ext (cdr fmt)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
401 (setq file (expand-file-name (concat name ext) dir)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
402 (and |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
403 (file-readable-p file) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
404 (file-regular-p file) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
405 (throw |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
406 'found |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
407 (tree-widget-create-image |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
408 (car fmt) file |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
409 ;; Add the pointer shape |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
410 (cons :pointer |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
411 (cons |
64985 | 412 (or (cdr (assoc name tree-widget--cursors)) |
413 'hand) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
414 (tree-widget-image-properties file))))))))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
415 nil))))) |
55588 | 416 |
417 (defun tree-widget-find-image (name) | |
418 "Find the image with NAME in current theme. | |
419 NAME is an image file name sans extension. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
420 Return the image found, or nil if not found." |
55588 | 421 (when (tree-widget-use-image-p) |
422 ;; Ensure there is an active theme. | |
423 (tree-widget-set-theme (tree-widget-theme-name)) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
424 (let ((image (assoc name (aref tree-widget--theme 3)))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
425 ;; The image NAME is found in the cache. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
426 (if image |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
427 (cdr image) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
428 ;; Search the image in current, and default themes. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
429 (prog1 |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
430 (setq image (tree-widget-lookup-image name)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
431 ;; Store image reference in the cache for later use. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
432 (push (cons name image) (aref tree-widget--theme 3)))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
433 ))) |
55588 | 434 |
435 ;;; Widgets | |
436 ;; | |
66187
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
437 (defun tree-widget-button-click (event) |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
438 "Move to the position clicked on, and if it is a button, invoke it. |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
439 EVENT is the mouse event received." |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
440 (interactive "e") |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
441 (mouse-set-point event) |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
442 (let ((pos (widget-event-point event))) |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
443 (if (get-char-property pos 'button) |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
444 (widget-button-click event)))) |
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
445 |
55588 | 446 (defvar tree-widget-button-keymap |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
447 (let ((km (make-sparse-keymap))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
448 (if (boundp 'widget-button-keymap) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
449 ;; XEmacs |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
450 (progn |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
451 (set-keymap-parent km widget-button-keymap) |
66187
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
452 (define-key km [button1] 'tree-widget-button-click)) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
453 ;; Emacs |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
454 (set-keymap-parent km widget-keymap) |
66187
5955934355f2
(tree-widget-button-click): New function.
David Ponce <david@dponce.com>
parents:
65747
diff
changeset
|
455 (define-key km [down-mouse-1] 'tree-widget-button-click)) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
456 km) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
457 "Keymap used inside node buttons. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
458 Handle mouse button 1 click on buttons.") |
55588 | 459 |
64985 | 460 (define-widget 'tree-widget-icon 'push-button |
461 "Basic widget other tree-widget icons are derived from." | |
55588 | 462 :format "%[%t%]" |
463 :button-keymap tree-widget-button-keymap ; XEmacs | |
464 :keymap tree-widget-button-keymap ; Emacs | |
64985 | 465 :create 'tree-widget-icon-create |
466 :action 'tree-widget-icon-action | |
467 :help-echo 'tree-widget-icon-help-echo | |
55588 | 468 ) |
469 | |
64985 | 470 (define-widget 'tree-widget-open-icon 'tree-widget-icon |
471 "Icon for an expanded tree-widget node." | |
472 :tag "[-]" | |
473 :glyph-name "open" | |
55588 | 474 ) |
475 | |
64985 | 476 (define-widget 'tree-widget-empty-icon 'tree-widget-icon |
477 "Icon for an expanded tree-widget node with no child." | |
478 :tag "[X]" | |
479 :glyph-name "empty" | |
55588 | 480 ) |
481 | |
64985 | 482 (define-widget 'tree-widget-close-icon 'tree-widget-icon |
483 "Icon for a collapsed tree-widget node." | |
484 :tag "[+]" | |
485 :glyph-name "close" | |
55588 | 486 ) |
487 | |
64985 | 488 (define-widget 'tree-widget-leaf-icon 'tree-widget-icon |
489 "Icon for a tree-widget leaf node." | |
490 :tag "" | |
491 :glyph-name "leaf" | |
492 :button-face 'default | |
55588 | 493 ) |
494 | |
495 (define-widget 'tree-widget-guide 'item | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
496 "Vertical guide line." |
55588 | 497 :tag " |" |
498 ;;:tag-glyph (tree-widget-find-image "guide") | |
499 :format "%t" | |
500 ) | |
501 | |
502 (define-widget 'tree-widget-end-guide 'item | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
503 "End of a vertical guide line." |
55588 | 504 :tag " `" |
505 ;;:tag-glyph (tree-widget-find-image "end-guide") | |
506 :format "%t" | |
507 ) | |
508 | |
509 (define-widget 'tree-widget-no-guide 'item | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
510 "Invisible vertical guide line." |
55588 | 511 :tag " " |
512 ;;:tag-glyph (tree-widget-find-image "no-guide") | |
513 :format "%t" | |
514 ) | |
515 | |
516 (define-widget 'tree-widget-handle 'item | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
517 "Horizontal guide line that joins a vertical guide line to a node." |
64985 | 518 :tag "-" |
55588 | 519 ;;:tag-glyph (tree-widget-find-image "handle") |
520 :format "%t" | |
521 ) | |
522 | |
523 (define-widget 'tree-widget-no-handle 'item | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
524 "Invisible handle." |
55588 | 525 :tag " " |
526 ;;:tag-glyph (tree-widget-find-image "no-handle") | |
527 :format "%t" | |
528 ) | |
529 | |
530 (define-widget 'tree-widget 'default | |
531 "Tree widget." | |
532 :format "%v" | |
533 :convert-widget 'widget-types-convert-widget | |
534 :value-get 'widget-value-value-get | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
535 :value-delete 'widget-children-value-delete |
55588 | 536 :value-create 'tree-widget-value-create |
64985 | 537 :action 'tree-widget-action |
538 :help-echo 'tree-widget-help-echo | |
539 :open-icon 'tree-widget-open-icon | |
540 :close-icon 'tree-widget-close-icon | |
541 :empty-icon 'tree-widget-empty-icon | |
542 :leaf-icon 'tree-widget-leaf-icon | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
543 :guide 'tree-widget-guide |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
544 :end-guide 'tree-widget-end-guide |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
545 :no-guide 'tree-widget-no-guide |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
546 :handle 'tree-widget-handle |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
547 :no-handle 'tree-widget-no-handle |
55588 | 548 ) |
549 | |
550 ;;; Widget support functions | |
551 ;; | |
552 (defun tree-widget-p (widget) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
553 "Return non-nil if WIDGET is a tree-widget." |
55588 | 554 (let ((type (widget-type widget))) |
555 (while (and type (not (eq type 'tree-widget))) | |
556 (setq type (widget-type (get type 'widget-type)))) | |
557 (eq type 'tree-widget))) | |
558 | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
559 (defun tree-widget-node (widget) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
560 "Return WIDGET's :node child widget. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
561 If not found, setup an `item' widget as default. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
562 Signal an error if the :node widget is a tree-widget. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
563 WIDGET is, or derives from, a tree-widget." |
55588 | 564 (let ((node (widget-get widget :node))) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
565 (if node |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
566 ;; Check that the :node widget is not a tree-widget. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
567 (and (tree-widget-p node) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
568 (error "Invalid tree-widget :node %S" node)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
569 ;; Setup an item widget as default :node. |
55588 | 570 (setq node `(item :tag ,(or (widget-get widget :tag) |
571 (widget-princ-to-string | |
572 (widget-value widget))))) | |
573 (widget-put widget :node node)) | |
574 node)) | |
575 | |
576 (defun tree-widget-keep (arg widget) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
577 "Save in ARG the WIDGET's properties specified by :keep." |
55588 | 578 (dolist (prop (widget-get widget :keep)) |
579 (widget-put arg prop (widget-get widget prop)))) | |
580 | |
581 (defun tree-widget-children-value-save (widget &optional args node) | |
582 "Save WIDGET children values. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
583 WIDGET is, or derives from, a tree-widget. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
584 Children properties and values are saved in ARGS if non-nil, else in |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
585 WIDGET's :args property value. Properties and values of the |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
586 WIDGET's :node sub-widget are saved in NODE if non-nil, else in |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
587 WIDGET's :node sub-widget." |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
588 (let ((args (cons (or node (widget-get widget :node)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
589 (or args (widget-get widget :args)))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
590 (children (widget-get widget :children)) |
55588 | 591 arg child) |
592 (while (and args children) | |
593 (setq arg (car args) | |
594 args (cdr args) | |
595 child (car children) | |
596 children (cdr children)) | |
597 (if (tree-widget-p child) | |
598 ;;;; The child is a tree node. | |
599 (progn | |
600 ;; Backtrack :args and :node properties. | |
601 (widget-put arg :args (widget-get child :args)) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
602 (widget-put arg :node (widget-get child :node)) |
55588 | 603 ;; Save :open property. |
604 (widget-put arg :open (widget-get child :open)) | |
605 ;; The node is open. | |
606 (when (widget-get child :open) | |
607 ;; Save the widget value. | |
608 (widget-put arg :value (widget-value child)) | |
609 ;; Save properties specified in :keep. | |
610 (tree-widget-keep arg child) | |
611 ;; Save children. | |
612 (tree-widget-children-value-save | |
613 child (widget-get arg :args) (widget-get arg :node)))) | |
614 ;;;; Another non tree node. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
615 ;; Save the widget value. |
55588 | 616 (widget-put arg :value (widget-value child)) |
617 ;; Save properties specified in :keep. | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
618 (tree-widget-keep arg child))))) |
64985 | 619 |
620 ;;; Widget creation | |
621 ;; | |
622 (defvar tree-widget-before-create-icon-functions nil | |
623 "Hooks run before to create a tree-widget icon. | |
624 Each function is passed the icon widget not yet created. | |
625 The value of the icon widget :node property is a tree :node widget or | |
626 a leaf node widget, not yet created. | |
627 This hook can be used to dynamically change properties of the icon and | |
628 associated node widgets. For example, to dynamically change the look | |
629 and feel of the tree-widget by changing the values of the :tag | |
630 and :glyph-name properties of the icon widget. | |
631 This hook should be local in the buffer setup to display widgets.") | |
55588 | 632 |
64985 | 633 (defun tree-widget-icon-create (icon) |
634 "Create the ICON widget." | |
635 (run-hook-with-args 'tree-widget-before-create-icon-functions icon) | |
636 (widget-put icon :tag-glyph | |
637 (tree-widget-find-image (widget-get icon :glyph-name))) | |
638 ;; Ensure there is at least one char to display the image. | |
639 (and (widget-get icon :tag-glyph) | |
640 (equal "" (or (widget-get icon :tag) "")) | |
641 (widget-put icon :tag " ")) | |
642 (widget-default-create icon) | |
643 ;; Insert space between the icon and the node widget. | |
644 (insert-char ? 1) | |
645 (put-text-property | |
646 (1- (point)) (point) | |
647 'display (list 'space :width tree-widget-space-width))) | |
55588 | 648 |
649 (defun tree-widget-value-create (tree) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
650 "Create the TREE tree-widget." |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
651 (let* ((node (tree-widget-node tree)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
652 (flags (widget-get tree :tree-widget--guide-flags)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
653 (indent (widget-get tree :indent)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
654 ;; Setup widget's image support. Looking up for images, and |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
655 ;; setting widgets' :tag-glyph is done here, to allow to |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
656 ;; dynamically change the image theme. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
657 (widget-image-enable (tree-widget-use-image-p)) ; Emacs |
55588 | 658 (widget-glyph-enable widget-image-enable) ; XEmacs |
659 children buttons) | |
63482
0f66f455f7d7
(tree-widget-value-create): Simplify last change.
David Ponce <david@dponce.com>
parents:
63467
diff
changeset
|
660 (and indent (not (widget-get tree :parent)) |
63467
c4d3f401bf34
eval-and-compile inlined functions so they will
David Ponce <david@dponce.com>
parents:
63465
diff
changeset
|
661 (insert-char ?\ indent)) |
55588 | 662 (if (widget-get tree :open) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
663 ;;;; Expanded node. |
63465
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
664 (let ((args (widget-get tree :args)) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
665 (xpandr (or (widget-get tree :expander) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
666 (widget-get tree :dynargs))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
667 (guide (widget-get tree :guide)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
668 (noguide (widget-get tree :no-guide)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
669 (endguide (widget-get tree :end-guide)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
670 (handle (widget-get tree :handle)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
671 (nohandle (widget-get tree :no-handle)) |
63465
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
672 (guidi (tree-widget-find-image "guide")) |
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
673 (noguidi (tree-widget-find-image "no-guide")) |
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
674 (endguidi (tree-widget-find-image "end-guide")) |
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
675 (handli (tree-widget-find-image "handle")) |
64985 | 676 (nohandli (tree-widget-find-image "no-handle"))) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
677 ;; Request children at run time, when not already done. |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
678 (when (and (not args) xpandr) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
679 (setq args (mapcar 'widget-convert (funcall xpandr tree))) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
680 (widget-put tree :args args)) |
65613
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
681 ;; Defer the node widget creation after icon creation. |
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
682 (widget-put tree :node (widget-convert node)) |
64985 | 683 ;; Create the icon widget for the expanded tree. |
55588 | 684 (push (widget-create-child-and-convert |
65649
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
685 tree (widget-get tree (if args :open-icon :empty-icon)) |
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
686 ;; Pass the node widget to child. |
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
687 :node (widget-get tree :node)) |
55588 | 688 buttons) |
64985 | 689 ;; Create the tree node widget. |
65613
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
690 (push (widget-create-child tree (widget-get tree :node)) |
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
691 children) |
64985 | 692 ;; Update the icon :node with the created node widget. |
693 (widget-put (car buttons) :node (car children)) | |
694 ;; Create the tree children. | |
55588 | 695 (while args |
64985 | 696 (setq node (car args) |
697 args (cdr args)) | |
63465
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
698 (and indent (insert-char ?\ indent)) |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
699 ;; Insert guide lines elements from previous levels. |
63465
1df1bb151415
(tree-widget-super-format-handler)
David Ponce <david@dponce.com>
parents:
59996
diff
changeset
|
700 (dolist (f (reverse flags)) |
55588 | 701 (widget-create-child-and-convert |
702 tree (if f guide noguide) | |
703 :tag-glyph (if f guidi noguidi)) | |
704 (widget-create-child-and-convert | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
705 tree nohandle :tag-glyph nohandli)) |
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
706 ;; Insert guide line element for this level. |
55588 | 707 (widget-create-child-and-convert |
708 tree (if args guide endguide) | |
709 :tag-glyph (if args guidi endguidi)) | |
710 ;; Insert the node handle line | |
711 (widget-create-child-and-convert | |
712 tree handle :tag-glyph handli) | |
64985 | 713 (if (tree-widget-p node) |
714 ;; Create a sub-tree node. | |
715 (push (widget-create-child-and-convert | |
716 tree node :tree-widget--guide-flags | |
717 (cons (if args t) flags)) | |
718 children) | |
719 ;; Create the icon widget for a leaf node. | |
55588 | 720 (push (widget-create-child-and-convert |
64985 | 721 tree (widget-get tree :leaf-icon) |
722 ;; At this point the node widget isn't yet created. | |
723 :node (setq node (widget-convert | |
724 node :tree-widget--guide-flags | |
725 (cons (if args t) flags))) | |
726 :tree-widget--leaf-flag t) | |
727 buttons) | |
728 ;; Create the leaf node widget. | |
729 (push (widget-create-child tree node) children) | |
730 ;; Update the icon :node with the created node widget. | |
731 (widget-put (car buttons) :node (car children))))) | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
732 ;;;; Collapsed node. |
65613
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
733 ;; Defer the node widget creation after icon creation. |
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
734 (widget-put tree :node (widget-convert node)) |
64985 | 735 ;; Create the icon widget for the collapsed tree. |
55588 | 736 (push (widget-create-child-and-convert |
65649
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
737 tree (widget-get tree :close-icon) |
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
738 ;; Pass the node widget to child. |
e2b8d96a5a4f
(tree-widget-value-create): Fix previous change.
David Ponce <david@dponce.com>
parents:
65613
diff
changeset
|
739 :node (widget-get tree :node)) |
55588 | 740 buttons) |
64985 | 741 ;; Create the tree node widget. |
65613
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
742 (push (widget-create-child tree (widget-get tree :node)) |
cc7dd4ad84cd
(tree-widget-value-create): Save the converted tree :node widget.
David Ponce <david@dponce.com>
parents:
64985
diff
changeset
|
743 children) |
64985 | 744 ;; Update the icon :node with the created node widget. |
745 (widget-put (car buttons) :node (car children))) | |
746 ;; Save widget children and buttons. The tree-widget :node child | |
747 ;; is the first element in :children. | |
55588 | 748 (widget-put tree :children (nreverse children)) |
64985 | 749 (widget-put tree :buttons buttons))) |
750 | |
751 ;;; Widget callbacks | |
752 ;; | |
753 (defsubst tree-widget-leaf-node-icon-p (icon) | |
754 "Return non-nil if ICON is a leaf node icon. | |
755 That is, if its :node property value is a leaf node widget." | |
756 (widget-get icon :tree-widget--leaf-flag)) | |
757 | |
758 (defun tree-widget-icon-action (icon &optional event) | |
759 "Handle the ICON widget :action. | |
760 If ICON :node is a leaf node it handles the :action. The tree-widget | |
761 parent of ICON handles the :action otherwise. | |
762 Pass the received EVENT to :action." | |
763 (let ((node (widget-get icon (if (tree-widget-leaf-node-icon-p icon) | |
764 :node :parent)))) | |
765 (widget-apply node :action event))) | |
766 | |
767 (defun tree-widget-icon-help-echo (icon) | |
768 "Return the help-echo string of ICON. | |
769 If ICON :node is a leaf node it handles the :help-echo. The tree-widget | |
770 parent of ICON handles the :help-echo otherwise." | |
771 (let* ((node (widget-get icon (if (tree-widget-leaf-node-icon-p icon) | |
772 :node :parent))) | |
773 (help-echo (widget-get node :help-echo))) | |
774 (if (functionp help-echo) | |
775 (funcall help-echo node) | |
776 help-echo))) | |
777 | |
778 (defvar tree-widget-after-toggle-functions nil | |
779 "Hooks run after toggling a tree-widget expansion. | |
780 Each function is passed a tree-widget. If the value of the :open | |
781 property is non-nil the tree has been expanded, else collapsed. | |
782 This hook should be local in the buffer setup to display widgets.") | |
783 | |
784 (defun tree-widget-action (tree &optional event) | |
785 "Handle the :action of the TREE tree-widget. | |
786 That is, toggle expansion of the TREE tree-widget. | |
787 Ignore the EVENT argument." | |
788 (let ((open (not (widget-get tree :open)))) | |
789 (or open | |
790 ;; Before to collapse the node, save children values so next | |
791 ;; open can recover them. | |
792 (tree-widget-children-value-save tree)) | |
793 (widget-put tree :open open) | |
794 (widget-value-set tree open) | |
795 (run-hook-with-args 'tree-widget-after-toggle-functions tree))) | |
796 | |
797 (defun tree-widget-help-echo (tree) | |
798 "Return the help-echo string of the TREE tree-widget." | |
799 (if (widget-get tree :open) | |
800 "Collapse node" | |
801 "Expand node")) | |
55588 | 802 |
803 (provide 'tree-widget) | |
804 | |
64077
f823765b0fab
Improve header Commentary section.
David Ponce <david@dponce.com>
parents:
63482
diff
changeset
|
805 ;; arch-tag: c3a1ada2-1663-41dc-9d16-2479ed8320e8 |
55588 | 806 ;;; tree-widget.el ends here |