annotate lisp/sb-image.el @ 96642:aee1275a4e6e

*** empty log message ***
author Martin Rudalics <rudalics@gmx.at>
date Sun, 13 Jul 2008 07:35:15 +0000
parents ee5932bf781d
children d42aff5ca541
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
74442
b2e5081b9320 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005,
79721
73661ddc7ac7 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
65752
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: file, tags, tools
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
65752
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
14 ;; (at your option) any later version.
65752
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; 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
17 ;; 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
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
65752
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; 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
27 ;; 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
28 ;; 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
29 ;; support can get lost.
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; 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
32 ;; 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
33 ;;
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; 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
35
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (require 'ezimage)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;;; Code:
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (defcustom speedbar-use-images ezimage-use-images
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 "*Non-nil if speedbar should display icons."
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 :group 'speedbar
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 :version "21.1"
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 :type 'boolean)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (defalias 'defimage-speedbar 'defezimage)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (defvar speedbar-expand-image-button-alist
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 '(("<+>" . ezimage-directory-plus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ("<->" . ezimage-directory-minus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ("< >" . ezimage-directory)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ("[+]" . ezimage-page-plus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ("[-]" . ezimage-page-minus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ("[?]" . ezimage-page)
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-box-plus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ("{-}" . ezimage-box-minus)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ("<M>" . ezimage-mail)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ("<d>" . ezimage-document-tag)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ("<i>" . ezimage-info-tag)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (" =>" . ezimage-tag)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (" +>" . ezimage-tag-gt)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (" ->" . ezimage-tag-v)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 (">" . ezimage-tag)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ("@" . ezimage-tag-type)
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-checkout)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 ("#" . ezimage-object)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ("!" . ezimage-object-out-of-date)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ("//" . ezimage-label)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ("%" . ezimage-lock)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 )
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 "List of text and image associations.")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 (defun speedbar-insert-image-button-maybe (start length)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 "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
76 If buttontext is unknown, just insert that text.
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 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
78 (when speedbar-use-images
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (let ((ezimage-expand-image-button-alist
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 speedbar-expand-image-button-alist))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (ezimage-insert-image-button-maybe start length))))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 (defun speedbar-image-dump ()
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 "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
85 See `speedbar-expand-image-button-alist' for details."
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (interactive)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (with-output-to-temp-buffer "*Speedbar Images*"
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (save-excursion
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (set-buffer "*Speedbar Images*")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (goto-char (point-max))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (insert "Speedbar image cache.\n\n")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (let ((start (point)) (end nil))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (insert "Image\tText\tImage Name")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (setq end (point))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 (insert "\n")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (put-text-property start end 'face 'underline))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (let ((ia speedbar-expand-image-button-alist))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (while ia
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (let ((start (point)))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (insert (car (car ia)))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (insert "\t")
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (speedbar-insert-image-button-maybe start
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (length (car (car ia))))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (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
105 (setq ia (cdr ia)))))))
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (provide 'sb-image)
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108
65779
103ed0b7e567 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 65752
diff changeset
109 ;; arch-tag: 6b05accd-e8b8-4290-8379-f063f3dacabb
65752
12e5c2513853 * speedbar.el: New version 1.0pre3.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 ;;; sb-image.el ends here