* align.el:
[bpt/emacs.git] / lisp / sb-image.el
CommitLineData
58bd8bf9
CY
1;;; sb-image --- Image management for speedbar
2
c90f2757 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005,
409cc4a3 4;; 2006, 2007, 2008 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.
76If buttontext is unknown, just insert that text.
77If 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.
85See `speedbar-expand-image-button-alist' for details."
86 (interactive)
87 (with-output-to-temp-buffer "*Speedbar Images*"
88 (save-excursion
89 (set-buffer "*Speedbar Images*")
90 (goto-char (point-max))
91 (insert "Speedbar image cache.\n\n")
92 (let ((start (point)) (end nil))
93 (insert "Image\tText\tImage Name")
94 (setq end (point))
95 (insert "\n")
96 (put-text-property start end 'face 'underline))
97 (let ((ia speedbar-expand-image-button-alist))
98 (while ia
99 (let ((start (point)))
100 (insert (car (car ia)))
101 (insert "\t")
102 (speedbar-insert-image-button-maybe start
103 (length (car (car ia))))
104 (insert (car (car ia)) "\t" (format "%s" (cdr (car ia))) "\n"))
105 (setq ia (cdr ia)))))))
106
107(provide 'sb-image)
108
dceb5300 109;; arch-tag: 6b05accd-e8b8-4290-8379-f063f3dacabb
58bd8bf9 110;;; sb-image.el ends here