Add arch tagline
[emacs.git] / lisp / sb-image.el
blob7f3d0cac7f58c25807faec3f8003f141c07339ab
1 ;;; sb-image --- Image management for speedbar
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005,
4 ;; 2006, 2007 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, or (at your option)
14 ;; 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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; Supporting Image display for Emacs 20 and less, Emacs 21, and XEmacs,
29 ;; is a challenging task, which doesn't take kindly to being byte compiled.
30 ;; When sharing speedbar.elc between these three applications, the Image
31 ;; support can get lost.
33 ;; By splitting out that hard part into this file, and avoiding byte
34 ;; compilation, one copy speedbar can support all these platforms together.
36 ;; This file requires the `image' package if it is available.
38 (require 'ezimage)
40 ;;; Code:
41 (defcustom speedbar-use-images ezimage-use-images
42 "*Non-nil if speedbar should display icons."
43 :group 'speedbar
44 :version "21.1"
45 :type 'boolean)
47 (defalias 'defimage-speedbar 'defezimage)
49 (defvar speedbar-expand-image-button-alist
50 '(("<+>" . ezimage-directory-plus)
51 ("<->" . ezimage-directory-minus)
52 ("< >" . ezimage-directory)
53 ("[+]" . ezimage-page-plus)
54 ("[-]" . ezimage-page-minus)
55 ("[?]" . ezimage-page)
56 ("[ ]" . ezimage-page)
57 ("{+}" . ezimage-box-plus)
58 ("{-}" . ezimage-box-minus)
59 ("<M>" . ezimage-mail)
60 ("<d>" . ezimage-document-tag)
61 ("<i>" . ezimage-info-tag)
62 (" =>" . ezimage-tag)
63 (" +>" . ezimage-tag-gt)
64 (" ->" . ezimage-tag-v)
65 (">" . ezimage-tag)
66 ("@" . ezimage-tag-type)
67 (" @" . ezimage-tag-type)
68 ("*" . ezimage-checkout)
69 ("#" . ezimage-object)
70 ("!" . ezimage-object-out-of-date)
71 ("//" . ezimage-label)
72 ("%" . ezimage-lock)
74 "List of text and image associations.")
76 (defun speedbar-insert-image-button-maybe (start length)
77 "Insert an image button based on text starting at START for LENGTH chars.
78 If buttontext is unknown, just insert that text.
79 If we have an image associated with it, use that image."
80 (when speedbar-use-images
81 (let ((ezimage-expand-image-button-alist
82 speedbar-expand-image-button-alist))
83 (ezimage-insert-image-button-maybe start length))))
85 (defun speedbar-image-dump ()
86 "Dump out the current state of the Speedbar image alist.
87 See `speedbar-expand-image-button-alist' for details."
88 (interactive)
89 (with-output-to-temp-buffer "*Speedbar Images*"
90 (save-excursion
91 (set-buffer "*Speedbar Images*")
92 (goto-char (point-max))
93 (insert "Speedbar image cache.\n\n")
94 (let ((start (point)) (end nil))
95 (insert "Image\tText\tImage Name")
96 (setq end (point))
97 (insert "\n")
98 (put-text-property start end 'face 'underline))
99 (let ((ia speedbar-expand-image-button-alist))
100 (while ia
101 (let ((start (point)))
102 (insert (car (car ia)))
103 (insert "\t")
104 (speedbar-insert-image-button-maybe start
105 (length (car (car ia))))
106 (insert (car (car ia)) "\t" (format "%s" (cdr (car ia))) "\n"))
107 (setq ia (cdr ia)))))))
109 (provide 'sb-image)
111 ;; arch-tag: 6b05accd-e8b8-4290-8379-f063f3dacabb
112 ;;; sb-image.el ends here