1 ;;; wl-demo.el -- Opening demo on Wanderlust.
3 ;; Copyright (C) 1998,1999,2000,2001 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000,2001 Katsumi Yamaoka <yamaoka@jpl.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, net news
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defconst wl-demo-copyright-notice
35 "Copyright (C) 1998-2001 Yuuichi Teranishi <teranisi@gohome.org>")
39 (require 'wl-highlight)
41 (defconst wl-demo-icon-name (concat "wl-" (wl-version-status) "-logo"))
43 ;; Avoid byte compile warnings.
45 (defalias-maybe 'bitmap-compose 'ignore)
46 (defalias-maybe 'bitmap-decode-xbm 'ignore)
47 (defalias-maybe 'bitmap-read-xbm-buffer 'ignore)
48 (defalias-maybe 'bitmap-read-xbm-file 'ignore)
49 (defalias-maybe 'create-image 'ignore)
50 (defalias-maybe 'device-on-window-system-p 'ignore)
51 (defalias-maybe 'display-graphic-p 'ignore)
52 (defalias-maybe 'frame-char-height 'ignore)
53 (defalias-maybe 'frame-char-width 'ignore)
54 (defalias-maybe 'frame-parameter 'ignore)
55 (defalias-maybe 'image-type-available-p 'ignore)
56 (defalias-maybe 'insert-image 'ignore)
57 (defalias-maybe 'make-extent 'ignore)
58 (defalias-maybe 'make-glyph 'ignore)
59 (defalias-maybe 'propertize 'ignore)
60 (defalias-maybe 'set-extent-end-glyph 'ignore)
61 (defalias-maybe 'set-glyph-face 'ignore)
62 (defalias-maybe 'set-specifier 'ignore)
63 (defalias-maybe 'window-pixel-height 'ignore)
64 (defalias-maybe 'window-pixel-width 'ignore))
70 (defvar wl-logo-ascii " o$ oo$$$$$$ooo
71 oo$$$ o$$ o$$$\"\"\"\"\"\"$$$$$o
72 $$$$$$\" o$$$\" o$\"\" \"$$$
76 o$$ oo$\" \"$$$o $ o$$
77 $$$$\"\" \"$$oo$ o o$\"
78 \"$$o \"$$$o oooo$\"\"
82 Yet Another Message Interface On Emacsen")
85 (defmacro wl-demo-with-temp-file-buffer (file &rest forms)
86 "Create a temporary buffer, insert FILE's contents without
87 any conversions and evaluate FORMS there like `progn'."
89 (let ((coding-system-for-read 'binary)
90 (input-coding-system '*noconv*)
92 file-name-handler-alist
94 insert-file-contents-access-hook
95 insert-file-contents-post-hook
96 insert-file-contents-pre-hook
97 interpreter-mode-alist)
98 (insert-file-contents (, file))
100 (put 'wl-demo-with-temp-file-buffer 'lisp-indent-function 1))
103 (defmacro wl-logo-xpm ()
104 ;; (WIDTH HEIGHT DATA)
105 (let ((file (expand-file-name
106 (concat wl-demo-icon-name ".xpm")
108 (if (file-exists-p file)
109 (wl-demo-with-temp-file-buffer file
111 (concat "\"[\t ]*\\([0-9]+\\)[\t ]+\\([0-9]+\\)"
112 "[\t ]+[0-9]+[\t ]+[0-9]+[\t ]*\""))
114 (string-to-number (match-string 1))
115 (string-to-number (match-string 2))
117 (defmacro wl-logo-xbm ()
118 ;; (WIDTH HEIGHT DATA)
119 (let ((file (expand-file-name
120 (concat wl-demo-icon-name ".xbm")
122 (if (file-exists-p file)
123 (wl-demo-with-temp-file-buffer file
124 (let ((case-fold-search t)
126 (search-forward "width")
127 (setq width (read (current-buffer)))
128 (goto-char (point-min))
129 (search-forward "height")
130 (setq height (read (current-buffer)))
131 (goto-char (point-min))
133 (delete-region (point-min) (point))
134 (while (re-search-forward "[^0-9a-fx]+" nil t)
136 (goto-char (point-min))
138 (while (search-forward "0x" nil t)
139 (replace-match "\\\\x"))
140 (goto-char (point-max))
142 (goto-char (point-min))
143 (list 'list width height (read (current-buffer))))))))
144 (defmacro wl-logo-bitmap ()
145 ;; (DECODED-P . DATA)
146 (let ((file (expand-file-name (concat wl-demo-icon-name ".xbm")
148 (if (file-exists-p file)
149 (if (condition-case nil (require 'bitmap) (error nil))
150 (list 'cons t (bitmap-decode-xbm
151 (bitmap-read-xbm-file file)))
152 (wl-demo-with-temp-file-buffer file
153 (list 'cons nil (buffer-string))))))))
155 (let ((xpm (wl-logo-xpm)))
156 (if (and xpm (or (and (featurep 'xemacs)
158 (and (condition-case nil (require 'image) (error nil))
159 (image-type-available-p 'xpm))))
161 (put 'wl-logo-xpm 'width (car xpm))
162 (put 'wl-logo-xpm 'height (nth 1 xpm))
163 (put 'wl-logo-xpm 'image
164 (if (featurep 'xemacs)
165 (make-glyph (vector 'xpm ':data (nth 2 xpm)))
166 (create-image (nth 2 xpm) 'xpm t))))))
168 (let ((xbm (wl-logo-xbm))
169 (bm (wl-logo-bitmap)))
170 (if (and xbm (or (featurep 'xemacs)
172 (condition-case nil (require 'bitmap) (error nil))))
174 (put 'wl-logo-xbm 'width (car xbm))
175 (put 'wl-logo-xbm 'height (nth 1 xbm))
176 (put 'wl-logo-xbm 'image
179 (make-glyph (vector 'xbm ':data xbm)))
181 (create-image (nth 2 xbm) 'xbm t
182 ':width (car xbm) ':height (nth 1 xbm)))
184 (let ((default-enable-multibyte-characters t)
187 (let* ((cmp (if (car bm)
191 (bitmap-decode-xbm (bitmap-read-xbm-buffer
196 (insert (bitmap-compose (aref cmp 0)))
198 (insert "\n" (bitmap-compose (aref cmp i)))
200 (buffer-string))))))))))
202 (defun wl-demo (&optional image-type)
203 "Demo on the startup screen.
204 Optional IMAGE-TYPE overrides the variable `wl-demo-display-logo'."
206 (if (and image-type (interactive-p))
207 (let* ((selection (append
208 (if (and (get 'wl-logo-xbm 'width)
209 (cond ((featurep 'xemacs)
210 (device-on-window-system-p))
215 (if (and (get 'wl-logo-xpm 'width)
216 (or (and (featurep 'xemacs)
218 (device-on-window-system-p))
222 (image-type-available-p 'xpm))))
225 (type (completing-read "Image type: " selection nil t)))
226 (setq image-type (if (assoc type selection)
227 (cdr (assoc type selection)))))
228 (setq image-type (or image-type wl-demo-display-logo)))
229 (let ((demo-buf (let ((default-enable-multibyte-characters t)
231 (default-line-spacing 0))
232 (get-buffer-create "*WL Demo*"))))
233 (switch-to-buffer demo-buf)
235 (setq truncate-lines t)
236 (cond ((featurep 'xemacs)
237 (if (device-on-window-system-p)
239 (if (boundp 'default-gutter-visible-p)
240 (set-specifier (symbol-value 'default-gutter-visible-p)
242 (set-specifier (symbol-value 'scrollbar-height) 0 demo-buf)
243 (set-specifier (symbol-value 'scrollbar-width) 0 demo-buf))))
244 ((and wl-on-emacs21 (display-graphic-p))
245 (make-local-hook 'kill-buffer-hook)
246 (let* ((frame (selected-frame))
247 (toolbar (frame-parameter frame 'tool-bar-lines)))
248 (modify-frame-parameters frame '((tool-bar-lines)))
252 (let ((frame (, frame)))
253 (when (frame-live-p frame)
254 (, (if (and toolbar (> toolbar 0))
255 (` (modify-frame-parameters
256 frame '((tool-bar-lines . (, toolbar)))))))
258 'fringe (, (face-background 'fringe frame)) frame)))))
260 (set-face-background 'fringe (face-background 'default frame)
262 (let ((logo (cond ((eq 'xbm image-type)
263 (if (and (get 'wl-logo-xbm 'width)
264 (cond ((featurep 'xemacs)
265 (device-on-window-system-p))
270 ((eq 'xpm image-type)
271 (if (and (get 'wl-logo-xpm 'width)
272 (or (and (featurep 'xemacs)
274 (device-on-window-system-p))
278 (image-type-available-p 'xpm))))
284 (let ((lw (get logo 'width))
285 (lh (get logo 'height))
286 (image (get logo 'image)))
289 (if (eq 'wl-logo-xbm logo)
290 (set-glyph-face image 'wl-highlight-logo-face))
291 (setq rest (- wh 1 (/ (+ (* lh wh) (window-pixel-height) -1)
292 (window-pixel-height))))
293 (insert-char ?\ (max 0 (/ (- (* (window-pixel-width) (1+ ww))
295 2 (window-pixel-width))))
296 (set-extent-end-glyph (make-extent (point) (point)) image))
299 (if (eq 'wl-logo-xbm logo)
300 (let ((bg (face-background 'wl-highlight-logo-face))
301 (fg (face-foreground 'wl-highlight-logo-face)))
303 (plist-put (cdr image) ':background bg))
305 (plist-put (cdr image) ':foreground fg))))
306 (setq rest (/ (- (* wh (frame-char-height)) lh 1)
307 (frame-char-height)))
308 (insert (propertize " " 'display
309 (list 'space ':align-to
310 (max 0 (/ (- (* (frame-char-width)
312 2 (frame-char-width))))))
313 (insert-image image))
316 (put-text-property (point-min) (point) 'face
317 'wl-highlight-logo-face)
318 (setq rest (/ (- (* 16 wh) lh 8) 16))
319 (indent-rigidly (point-min) (point-max)
320 (/ (- (* 8 (1+ ww)) lw) 16))))
321 (goto-char (point-min)))
322 (insert (or wl-logo-ascii (product-name (product-find 'wl-version))))
323 (put-text-property (point-min) (point) 'face 'wl-highlight-logo-face)
324 (setq rest (- wh (count-lines (point-min) (point)) 1))
325 (let ((lw (current-column))
326 (lh (count-lines (point-min) (point))))
327 (while (progn (beginning-of-line) (not (bobp)))
329 (setq lw (max lw (current-column))))
330 (indent-rigidly (point) (point-max) (max 0 (/ (- ww lw) 2)))))
331 (insert-char ?\n (max 0 (/ (- rest 4) 2)))
332 (goto-char (point-max))
334 (let ((start (point))
335 (text (format (cond ((<= rest 2)
336 "version %s - \"%s\"\n%s")
338 "version %s - \"%s\"\n\n%s")
340 "\nversion %s - \"%s\"\n\n%s"))
341 (product-version-string (product-find 'wl-version))
342 (product-code-name (product-find 'wl-version))
343 wl-demo-copyright-notice)))
345 (let ((bg (face-background 'wl-highlight-demo-face))
346 (fg (face-foreground 'wl-highlight-demo-face)))
347 (insert (propertize text
348 'face (nconc '(variable-pitch :slant oblique)
350 (list ':background bg))
352 (list ':foreground fg))))))
354 (put-text-property start (point) 'face 'wl-highlight-demo-face))
355 (let ((fill-column ww))
356 (center-region start (point))))
357 (goto-char (point-min))
358 (sit-for (if (featurep 'lisp-float-type) (/ (float 5) (float 10)) 1))
362 (product-provide (provide 'wl-demo) (require 'wl-version))
364 ;;; wl-demo.el ends here