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