Commit | Line | Data |
---|---|---|
58bd8bf9 CY |
1 | ;;; sb-image --- Image management for speedbar |
2 | ||
c90f2757 | 3 | ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, |
114f9c96 | 4 | ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
58bd8bf9 CY |
5 | |
6 | ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
7 | ;; Keywords: file, tags, tools | |
58bd8bf9 CY |
8 | |
9 | ;; This file is part of GNU Emacs. | |
10 | ||
eb3fa2cf | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
58bd8bf9 | 12 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
13 | ;; the Free Software Foundation, either version 3 of the License, or |
14 | ;; (at your option) any later version. | |
58bd8bf9 CY |
15 | |
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
58bd8bf9 CY |
23 | |
24 | ;;; Commentary: | |
25 | ;; | |
26 | ;; Supporting Image display for Emacs 20 and less, Emacs 21, and XEmacs, | |
27 | ;; is a challenging task, which doesn't take kindly to being byte compiled. | |
28 | ;; When sharing speedbar.elc between these three applications, the Image | |
29 | ;; support can get lost. | |
30 | ;; | |
31 | ;; By splitting out that hard part into this file, and avoiding byte | |
32 | ;; compilation, one copy speedbar can support all these platforms together. | |
33 | ;; | |
34 | ;; This file requires the `image' package if it is available. | |
35 | ||
36 | (require 'ezimage) | |
37 | ||
38 | ;;; Code: | |
39 | (defcustom speedbar-use-images ezimage-use-images | |
9201cc28 | 40 | "Non-nil if speedbar should display icons." |
58bd8bf9 CY |
41 | :group 'speedbar |
42 | :version "21.1" | |
43 | :type 'boolean) | |
44 | ||
45 | (defalias 'defimage-speedbar 'defezimage) | |
46 | ||
47 | (defvar speedbar-expand-image-button-alist | |
48 | '(("<+>" . ezimage-directory-plus) | |
49 | ("<->" . ezimage-directory-minus) | |
50 | ("< >" . ezimage-directory) | |
51 | ("[+]" . ezimage-page-plus) | |
52 | ("[-]" . ezimage-page-minus) | |
53 | ("[?]" . ezimage-page) | |
54 | ("[ ]" . ezimage-page) | |
55 | ("{+}" . ezimage-box-plus) | |
56 | ("{-}" . ezimage-box-minus) | |
57 | ("<M>" . ezimage-mail) | |
58 | ("<d>" . ezimage-document-tag) | |
59 | ("<i>" . ezimage-info-tag) | |
60 | (" =>" . ezimage-tag) | |
61 | (" +>" . ezimage-tag-gt) | |
62 | (" ->" . ezimage-tag-v) | |
63 | (">" . ezimage-tag) | |
64 | ("@" . ezimage-tag-type) | |
65 | (" @" . ezimage-tag-type) | |
66 | ("*" . ezimage-checkout) | |
67 | ("#" . ezimage-object) | |
68 | ("!" . ezimage-object-out-of-date) | |
69 | ("//" . ezimage-label) | |
70 | ("%" . ezimage-lock) | |
71 | ) | |
72 | "List of text and image associations.") | |
73 | ||
74 | (defun speedbar-insert-image-button-maybe (start length) | |
75 | "Insert an image button based on text starting at START for LENGTH chars. | |
76 | If buttontext is unknown, just insert that text. | |
77 | If we have an image associated with it, use that image." | |
78 | (when speedbar-use-images | |
79 | (let ((ezimage-expand-image-button-alist | |
80 | speedbar-expand-image-button-alist)) | |
81 | (ezimage-insert-image-button-maybe start length)))) | |
82 | ||
83 | (defun speedbar-image-dump () | |
84 | "Dump out the current state of the Speedbar image alist. | |
85 | See `speedbar-expand-image-button-alist' for details." | |
86 | (interactive) | |
87 | (with-output-to-temp-buffer "*Speedbar Images*" | |
7fdbcd83 | 88 | (with-current-buffer "*Speedbar Images*" |
58bd8bf9 CY |
89 | (goto-char (point-max)) |
90 | (insert "Speedbar image cache.\n\n") | |
91 | (let ((start (point)) (end nil)) | |
92 | (insert "Image\tText\tImage Name") | |
93 | (setq end (point)) | |
94 | (insert "\n") | |
95 | (put-text-property start end 'face 'underline)) | |
96 | (let ((ia speedbar-expand-image-button-alist)) | |
97 | (while ia | |
98 | (let ((start (point))) | |
99 | (insert (car (car ia))) | |
100 | (insert "\t") | |
101 | (speedbar-insert-image-button-maybe start | |
102 | (length (car (car ia)))) | |
103 | (insert (car (car ia)) "\t" (format "%s" (cdr (car ia))) "\n")) | |
104 | (setq ia (cdr ia))))))) | |
105 | ||
106 | (provide 'sb-image) | |
107 | ||
dceb5300 | 108 | ;; arch-tag: 6b05accd-e8b8-4290-8379-f063f3dacabb |
58bd8bf9 | 109 | ;;; sb-image.el ends here |