annotate lisp/sb-image.el @ 68132:91ac87e90cb5

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