* lispref/modes.texi (Region to Refontify): Rename from "Region to Fontify".
[emacs.git] / lisp / sb-image.el
blobe4af3c0d7ef554025d39036987974be7ed2120ab
1 ;;; sb-image --- Image management for speedbar
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005,
4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; Keywords: file, tags, tools
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
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.
31 ;; By splitting out that hard part into this file, and avoiding byte
32 ;; compilation, one copy speedbar can support all these platforms together.
34 ;; This file requires the `image' package if it is available.
36 (require 'ezimage)
38 ;;; Code:
39 (defcustom speedbar-use-images ezimage-use-images
40 "Non-nil if speedbar should display icons."
41 :group 'speedbar
42 :version "21.1"
43 :type 'boolean)
45 (defalias 'defimage-speedbar 'defezimage)
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)
72 "List of text and image associations.")
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))))
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*"
88 (with-current-buffer "*Speedbar Images*"
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)))))))
106 (provide 'sb-image)
108 ;; arch-tag: 6b05accd-e8b8-4290-8379-f063f3dacabb
109 ;;; sb-image.el ends here