14
|
1 ;;; w3-display.el --- display engine v99999
|
|
2 ;; Author: wmperry
|
169
|
3 ;; Created: 1997/07/01 15:54:50
|
|
4 ;; Version: 1.192
|
14
|
5 ;; Keywords: faces, help, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
82
|
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
|
14
|
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
11 ;;;
|
|
12 ;;; This file is part of GNU Emacs.
|
|
13 ;;;
|
|
14 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
15 ;;; it under the terms of the GNU General Public License as published by
|
|
16 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
17 ;;; any later version.
|
|
18 ;;;
|
|
19 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
|
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22 ;;; GNU General Public License for more details.
|
|
23 ;;;
|
|
24 ;;; You should have received a copy of the GNU General Public License
|
|
25 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
26 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
27 ;;; Boston, MA 02111-1307, USA.
|
|
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
29 (require 'cl)
|
136
|
30 (eval-when-compile
|
|
31 (require 'w3-props))
|
14
|
32 (require 'css)
|
|
33 (require 'font)
|
|
34 (require 'w3-widget)
|
|
35 (require 'w3-imap)
|
|
36
|
165
|
37 (define-widget-keywords :active-face :emacspeak-help :href
|
|
38 :name :target :title :src)
|
88
|
39 (autoload 'sentence-ify "flame")
|
|
40 (autoload 'string-ify "flame")
|
|
41 (autoload '*flame "flame")
|
|
42 (if (not (fboundp 'flatten)) (autoload 'flatten "flame"))
|
|
43 (defvar w3-cookie-cache nil)
|
|
44
|
14
|
45 (defmacro w3-d-s-var-def (var)
|
|
46 (` (make-variable-buffer-local (defvar (, var) nil))))
|
|
47
|
108
|
48 (w3-d-s-var-def w3-display-label-marker)
|
14
|
49 (w3-d-s-var-def w3-display-open-element-stack)
|
|
50 (w3-d-s-var-def w3-display-alignment-stack)
|
|
51 (w3-d-s-var-def w3-display-list-stack)
|
82
|
52 (w3-d-s-var-def w3-display-form-id)
|
14
|
53 (w3-d-s-var-def w3-display-whitespace-stack)
|
|
54 (w3-d-s-var-def w3-display-font-family-stack)
|
|
55 (w3-d-s-var-def w3-display-font-weight-stack)
|
|
56 (w3-d-s-var-def w3-display-font-variant-stack)
|
|
57 (w3-d-s-var-def w3-display-font-size-stack)
|
|
58 (w3-d-s-var-def w3-face-color)
|
82
|
59 (w3-d-s-var-def w3-face-background-color)
|
14
|
60 (w3-d-s-var-def w3-active-faces)
|
|
61 (w3-d-s-var-def w3-active-voices)
|
|
62 (w3-d-s-var-def w3-current-form-number)
|
|
63 (w3-d-s-var-def w3-face-font-family)
|
|
64 (w3-d-s-var-def w3-face-font-weight)
|
|
65 (w3-d-s-var-def w3-face-font-variant)
|
|
66 (w3-d-s-var-def w3-face-font-size)
|
|
67 (w3-d-s-var-def w3-face-font-family)
|
|
68 (w3-d-s-var-def w3-face-font-size)
|
88
|
69 (w3-d-s-var-def w3-face-font-style)
|
14
|
70 (w3-d-s-var-def w3-face-font-spec)
|
|
71 (w3-d-s-var-def w3-face-text-decoration)
|
|
72 (w3-d-s-var-def w3-face-face)
|
|
73 (w3-d-s-var-def w3-face-descr)
|
165
|
74 (w3-d-s-var-def w3-face-background-image)
|
14
|
75 (w3-d-s-var-def w3-display-css-properties)
|
118
|
76 (w3-d-s-var-def w3-display-background-properties)
|
14
|
77
|
|
78 (eval-when-compile
|
|
79 (defmacro w3-get-attribute (attr)
|
|
80 (` (cdr-safe (assq (, attr) args))))
|
|
81
|
116
|
82 (defmacro w3-get-face-info (info &optional other)
|
14
|
83 (let ((var (intern (format "w3-face-%s" info))))
|
116
|
84 (` (push (w3-get-style-info (quote (, info)) node
|
124
|
85 (or (and (not w3-user-colors-take-precedence)
|
|
86 (cdr-safe (assq (quote (, other))
|
|
87 (nth 1 node))))
|
116
|
88 (car (, var))))
|
14
|
89 (, var)))))
|
|
90
|
|
91 (defmacro w3-pop-face-info (info)
|
|
92 (let ((var (intern (format "w3-face-%s" info))))
|
|
93 (` (pop (, var)))))
|
|
94
|
|
95 (defmacro w3-get-all-face-info ()
|
|
96 (`
|
|
97 (progn
|
|
98 (w3-get-face-info font-family)
|
118
|
99 ;; This is to handle the 'face' attribute on arbitrary elements
|
|
100 (if (cdr-safe (assq 'face (nth 1 node)))
|
|
101 (setf (car w3-face-font-family)
|
|
102 (append (car w3-face-font-family)
|
|
103 (split-string (cdr-safe
|
|
104 (assq 'face (nth 1 node)))
|
|
105 " *, *"))))
|
88
|
106 (w3-get-face-info font-style)
|
14
|
107 (w3-get-face-info font-weight)
|
|
108 (w3-get-face-info font-variant)
|
|
109 (w3-get-face-info font-size)
|
|
110 (w3-get-face-info text-decoration)
|
165
|
111 (w3-get-face-info background-image)
|
116
|
112 (w3-get-face-info color color)
|
|
113 (w3-get-face-info background-color bgcolor)
|
14
|
114 (setq w3-face-font-spec (make-font
|
|
115 :weight (car w3-face-font-weight)
|
|
116 :family (car w3-face-font-family)
|
|
117 :size (car w3-face-font-size))))))
|
|
118
|
|
119 (defmacro w3-pop-all-face-info ()
|
|
120 (`
|
|
121 (progn
|
|
122 (w3-pop-face-info font-family)
|
|
123 (w3-pop-face-info font-weight)
|
|
124 (w3-pop-face-info font-variant)
|
|
125 (w3-pop-face-info font-size)
|
88
|
126 (w3-pop-face-info font-style)
|
14
|
127 (w3-pop-face-info text-decoration)
|
165
|
128 (w3-pop-face-info background-image)
|
14
|
129 (w3-pop-face-info color)
|
82
|
130 (w3-pop-face-info background-color))))
|
14
|
131
|
|
132 )
|
|
133
|
82
|
134 (defvar w3-display-same-buffer nil)
|
14
|
135 (defvar w3-face-cache nil "Cache for w3-face-for-element")
|
|
136 (defvar w3-face-index 0)
|
|
137 (defvar w3-image-widgets-waiting nil)
|
|
138
|
|
139 (make-variable-buffer-local 'w3-last-fill-pos)
|
|
140
|
|
141 (defconst w3-fill-prefixes-vector
|
|
142 (let ((len 0)
|
|
143 (prefix-vector (make-vector 80 nil)))
|
|
144 (while (< len 80)
|
|
145 (aset prefix-vector len (make-string len ? ))
|
|
146 (setq len (1+ len)))
|
|
147 prefix-vector))
|
|
148
|
|
149 (defconst w3-line-breaks-vector
|
|
150 (let ((len 0)
|
|
151 (breaks-vector (make-vector 10 nil)))
|
|
152 (while (< len 10)
|
|
153 (aset breaks-vector len (make-string len ?\n))
|
|
154 (setq len (1+ len)))
|
|
155 breaks-vector))
|
|
156
|
165
|
157 (defsubst w3-pause ()
|
|
158 (save-excursion
|
|
159 (goto-char (or (symbol-value 'cur-viewing-pos) (point-min)))
|
|
160 (cond
|
169
|
161 (w3-running-xemacs
|
|
162 (if (and (not (sit-for 0)) (input-pending-p))
|
|
163 (condition-case ()
|
|
164 (dispatch-event (next-command-event))
|
|
165 (error nil))))
|
|
166 (t
|
165
|
167 (if (and (not (sit-for 0)) (input-pending-p))
|
|
168 (condition-case ()
|
|
169 (progn
|
|
170 (set 'cur-viewing-pos
|
|
171 (lookup-key w3-mode-map (vector (read-event))))
|
|
172 (case (symbol-value 'cur-viewing-pos)
|
|
173 ((w3-quit w3-leave-buffer) nil)
|
|
174 (otherwise (call-interactively (symbol-value 'cur-viewing-pos)))))
|
169
|
175 (error nil)))))
|
165
|
176 (set 'cur-viewing-pos (point))))
|
14
|
177
|
|
178 (defmacro w3-get-pad-string (len)
|
|
179 (` (cond
|
|
180 ((< (, len) 0)
|
|
181 "")
|
|
182 ((< (, len) 80)
|
|
183 (aref w3-fill-prefixes-vector (, len)))
|
|
184 (t (make-string (, len) ? )))))
|
|
185
|
|
186 (defsubst w3-set-fill-prefix-length (len)
|
|
187 (setq fill-prefix (if (< len (- (or w3-strict-width (window-width)) 4))
|
|
188 (w3-get-pad-string len)
|
|
189 (url-warn
|
|
190 'html
|
|
191 "Runaway indentation! Too deep for window width!")
|
|
192 fill-prefix)))
|
|
193
|
|
194 (defsubst w3-get-style-info (info node &optional default)
|
|
195 (or (cdr-safe (assq info w3-display-css-properties)) default))
|
|
196
|
|
197 (defun w3-decode-area-coords (str)
|
|
198 (let (retval)
|
|
199 (while (string-match "\\([ \t0-9]+\\),\\([ \t0-9]+\\)" str)
|
|
200 (setq retval (cons (vector (string-to-int (match-string 1 str))
|
|
201 (string-to-int (match-string 2 str))) retval)
|
|
202 str (substring str (match-end 0) nil)))
|
|
203 (if (string-match "\\([0-9]+\\)" str)
|
|
204 (setq retval (cons (vector (+ (aref (car retval) 0)
|
|
205 (string-to-int (match-string 1 str)))
|
|
206 (aref (car retval) 1)) retval)))
|
|
207 (nreverse retval)))
|
|
208
|
|
209 (defun w3-normalize-color (color)
|
|
210 (cond
|
|
211 ((valid-color-name-p color)
|
|
212 color)
|
|
213 ((valid-color-name-p (concat "#" color))
|
|
214 (concat "#" color))
|
|
215 ((string-match "[ \t\r\n]" color)
|
|
216 (w3-normalize-color
|
|
217 (mapconcat (function (lambda (x) (if (memq x '(?\t ?\r ?\n ? )) ""
|
|
218 (char-to-string x)))) color "")))
|
|
219 ((valid-color-name-p (font-normalize-color color))
|
|
220 (font-normalize-color color))
|
|
221 (t
|
|
222 (w3-warn 'html (format "Bad color specification: %s" color))
|
|
223 nil)))
|
|
224
|
|
225 (defsubst w3-voice-for-element (node)
|
|
226 (if (featurep 'emacspeak)
|
|
227 (let (family gain left right pitch pitch-range stress richness voice)
|
|
228 (setq family (w3-get-style-info 'voice-family node)
|
|
229 gain (w3-get-style-info 'gain node)
|
|
230 left (w3-get-style-info 'left-volume node)
|
|
231 right (w3-get-style-info 'right-volume node)
|
|
232 pitch (w3-get-style-info 'pitch node)
|
|
233 pitch-range (w3-get-style-info 'pitch-range node)
|
|
234 stress (w3-get-style-info 'stress node)
|
|
235 richness (w3-get-style-info 'richness node))
|
|
236 (if (or family gain left right pitch pitch-range stress richness)
|
|
237 (setq voice (dtk-personality-from-speech-style
|
|
238 (make-dtk-speech-style :family (or family 'paul)
|
|
239 :gain (or gain 5)
|
|
240 :left-volume (or left 5)
|
|
241 :right-volume (or right 5)
|
|
242 :average-pitch (or pitch 5)
|
|
243 :pitch-range (or pitch-range 5)
|
|
244 :stress (or stress 5)
|
|
245 :richness (or richness 5))))
|
|
246 (setq voice nil))
|
|
247 (or voice (car w3-active-voices)))))
|
|
248
|
|
249 (defun w3-make-face-emacs19 (name &optional doc-string temporary)
|
|
250 "Defines and returns a new FACE described by DOC-STRING.
|
|
251 If the face already exists, it is unmodified.
|
|
252 If TEMPORARY is non-nil, this face will cease to exist if not in use."
|
|
253 (make-face name))
|
|
254
|
|
255 (cond
|
|
256 ((not (fboundp 'make-face))
|
|
257 (fset 'w3-make-face 'ignore))
|
|
258 (w3-running-xemacs
|
|
259 (fset 'w3-make-face 'make-face))
|
|
260 (t
|
|
261 (fset 'w3-make-face 'w3-make-face-emacs19)))
|
|
262
|
|
263 (defsubst w3-face-for-element (node)
|
|
264 (w3-get-all-face-info)
|
|
265 (if (car w3-face-text-decoration)
|
|
266 (set-font-style-by-keywords w3-face-font-spec
|
|
267 (car w3-face-text-decoration)))
|
|
268 (if w3-face-font-variant
|
|
269 (set-font-style-by-keywords w3-face-font-spec
|
|
270 (car w3-face-font-variant)))
|
88
|
271 (if w3-face-font-style
|
|
272 (set-font-style-by-keywords w3-face-font-spec
|
|
273 (car w3-face-font-style)))
|
14
|
274 (setq w3-face-descr (list w3-face-font-spec
|
165
|
275 (car w3-face-background-image)
|
14
|
276 (car w3-face-color)
|
82
|
277 (car w3-face-background-color))
|
14
|
278 w3-face-face (cdr-safe (assoc w3-face-descr w3-face-cache)))
|
|
279 (if (or w3-face-face (not (or (car w3-face-color)
|
165
|
280 (car w3-face-background-image)
|
82
|
281 (car w3-face-background-color)
|
14
|
282 w3-face-font-spec)))
|
|
283 nil ; Do nothing, we got it already
|
|
284 (setq w3-face-face
|
|
285 (w3-make-face (intern (format "w3-style-face-%05d" w3-face-index))
|
|
286 "An Emacs-W3 face... don't edit by hand." t)
|
|
287 w3-face-index (1+ w3-face-index))
|
165
|
288 (if (car w3-face-background-image)
|
|
289 (w3-maybe-start-background-image-download
|
|
290 (car w3-face-background-image) w3-face-face))
|
14
|
291 (if w3-face-font-spec
|
108
|
292 (font-set-face-font w3-face-face w3-face-font-spec))
|
14
|
293 (if (car w3-face-color)
|
108
|
294 (font-set-face-foreground w3-face-face (car w3-face-color)))
|
82
|
295 (if (car w3-face-background-color)
|
108
|
296 (font-set-face-background w3-face-face (car w3-face-background-color)))
|
14
|
297 (setq w3-face-cache (cons
|
|
298 (cons w3-face-descr w3-face-face)
|
|
299 w3-face-cache)))
|
|
300 w3-face-face)
|
|
301
|
|
302 (defun w3-normalize-spaces (string)
|
|
303 ;; nuke spaces in the middle
|
|
304 (while (string-match "[ \t\r\n][ \r\t\n]+" string)
|
|
305 (setq string (concat (substring string 0 (1+ (match-beginning 0)))
|
|
306 (substring string (match-end 0)))))
|
|
307
|
|
308 ;; nuke spaces at the beginning
|
|
309 (if (string-match "^[ \t\r\n]+" string)
|
|
310 (setq string (substring string (match-end 0))))
|
|
311
|
|
312 ;; nuke spaces at the end
|
|
313 (if (string-match "[ \t\n\r]+$" string)
|
|
314 (setq string (substring string 0 (match-beginning 0))))
|
|
315 string)
|
|
316
|
|
317
|
165
|
318 (if (not (fboundp 'char-before))
|
|
319 (fset 'char-before 'preceding-char))
|
|
320
|
14
|
321 (defsubst w3-display-line-break (n)
|
|
322 (if (or
|
|
323 (memq (car w3-display-whitespace-stack) '(pre nowrap)) ; Been told
|
|
324 (= w3-last-fill-pos (point))
|
|
325 (> w3-last-fill-pos (point-max)))
|
165
|
326 (if (not (eq (char-before) ?\n))
|
|
327 (setq n (1+ n))) ; at least put one line in
|
14
|
328 (let ((fill-column (max (1+ (length fill-prefix)) fill-column))
|
|
329 width)
|
|
330 (case (car w3-display-alignment-stack)
|
|
331 (center
|
|
332 (fill-region-as-paragraph w3-last-fill-pos (point))
|
|
333 (center-region w3-last-fill-pos (point-max)))
|
|
334 ((justify full)
|
|
335 (fill-region-as-paragraph w3-last-fill-pos (point) t))
|
|
336 (right
|
|
337 (fill-region-as-paragraph w3-last-fill-pos (point))
|
|
338 (goto-char w3-last-fill-pos)
|
|
339 (catch 'fill-exit
|
|
340 (while (re-search-forward ".$" nil t)
|
|
341 (if (>= (setq width (current-column)) fill-column)
|
|
342 nil ; already justified, or error
|
|
343 (beginning-of-line)
|
118
|
344 (insert-char ? (- fill-column width) t)
|
14
|
345 (end-of-line)
|
|
346 (if (eobp)
|
|
347 (throw 'fill-exit t))
|
|
348 (condition-case ()
|
|
349 (forward-char 1)
|
|
350 (error (throw 'fill-exit t))))))
|
|
351 )
|
|
352 (otherwise ; Default is left justification
|
|
353 (fill-region-as-paragraph w3-last-fill-pos (point)))
|
|
354 ))
|
|
355 (setq n (1- n)))
|
|
356 (setq w3-last-fill-pos (point-max))
|
|
357 (insert (cond
|
|
358 ((<= n 0) "")
|
|
359 ((< n 10)
|
|
360 (aref w3-line-breaks-vector n))
|
|
361 (t
|
|
362 (make-string n ?\n)))))
|
|
363
|
|
364 (defsubst w3-munge-line-breaks-p ()
|
|
365 (eq (car w3-display-whitespace-stack) 'pre))
|
|
366
|
|
367 (defvar w3-display-nil-face (w3-make-face nil "Stub face... don't ask." t))
|
|
368
|
|
369 (defvar w3-scratch-start-point nil)
|
|
370
|
|
371 (defsubst w3-handle-string-content (string)
|
|
372 (setq w3-scratch-start-point (point))
|
|
373 (insert string)
|
|
374 (if (w3-munge-line-breaks-p)
|
|
375 (progn
|
|
376 (goto-char w3-scratch-start-point)
|
|
377 (if (not (search-forward "\n" nil t))
|
|
378 (subst-char-in-region w3-scratch-start-point (point-max) ?\r ?\n)
|
|
379 (subst-char-in-region w3-scratch-start-point (point-max) ?\r ? )))
|
|
380 (goto-char w3-scratch-start-point)
|
|
381 (while (re-search-forward
|
|
382 " [ \t\n\r]+\\|[\t\n\r][ \t\n\r]*"
|
|
383 nil 'move)
|
|
384 (replace-match " "))
|
|
385 (goto-char w3-scratch-start-point)
|
169
|
386 (if (and (memq (char-before) '(? ?\t ?\r ?\n))
|
14
|
387 (looking-at "[ \t\r\n]"))
|
|
388 (delete-region (point)
|
|
389 (progn
|
|
390 (skip-chars-forward " \t\r\n")
|
|
391 (point)))))
|
|
392 (goto-char (point-max))
|
|
393 (add-text-properties w3-scratch-start-point
|
98
|
394 (point) (list 'face w3-active-faces
|
102
|
395 'html-stack w3-display-open-element-stack
|
118
|
396 'start-open nil
|
|
397 'end-open nil
|
|
398 'front-sticky t
|
|
399 'rear-nonsticky nil
|
98
|
400 'duplicable t))
|
14
|
401 (if (car w3-active-voices)
|
|
402 (add-text-properties w3-scratch-start-point (point)
|
|
403 (list 'personality (car w3-active-voices))))
|
|
404 )
|
|
405
|
88
|
406 (defun w3-display-get-cookie (args)
|
|
407 (if (not (fboundp 'cookie))
|
|
408 "Sorry, no cookies today."
|
|
409 (let* ((href (or (w3-get-attribute 'href) (w3-get-attribute 'src)))
|
|
410 (fname (or (cdr-safe (assoc href w3-cookie-cache))
|
|
411 (url-generate-unique-filename "%s.cki")))
|
|
412 (st (or (cdr-safe (assq 'start args)) "Loading cookies..."))
|
|
413 (nd (or (cdr-safe (assq 'end args)) "Loading cookies... done.")))
|
|
414 (if (not (file-exists-p fname))
|
|
415 (save-excursion
|
|
416 (set-buffer (generate-new-buffer " *cookie*"))
|
|
417 (url-insert-file-contents href)
|
|
418 (write-region (point-min) (point-max) fname 5)
|
|
419 (setq w3-cookie-cache (cons (cons href fname) w3-cookie-cache))))
|
|
420 (cookie fname st nd))))
|
|
421
|
14
|
422 (defun w3-widget-echo (widget &rest ignore)
|
165
|
423 (let* ((url (widget-get widget :href))
|
|
424 (name (widget-get widget :name))
|
|
425 (text (buffer-substring (widget-get widget :from)
|
|
426 (widget-get widget :to)))
|
|
427 (title (widget-get widget :title))
|
|
428 (check w3-echo-link)
|
|
429 (msg nil))
|
82
|
430 (if url
|
|
431 (setq url (url-truncate-url-for-viewing url)))
|
14
|
432 (if name
|
|
433 (setq name (concat "anchor:" name)))
|
82
|
434 (if (not (listp check))
|
|
435 (setq check (cons check '(title url text name))))
|
|
436 (catch 'exit
|
|
437 (while check
|
|
438 (and (boundp (car check))
|
|
439 (stringp (symbol-value (car check)))
|
108
|
440 (> (length (symbol-value (car check))) 0)
|
82
|
441 (throw 'exit (symbol-value (car check))))
|
|
442 (pop check)))))
|
14
|
443
|
|
444 (defun w3-follow-hyperlink (widget &rest ignore)
|
165
|
445 (let* ((target (or (widget-get widget :target) w3-base-target))
|
|
446 (href (widget-get widget :href)))
|
14
|
447 (if target (setq target (intern (downcase target))))
|
|
448 (case target
|
|
449 ((_blank external)
|
|
450 (w3-fetch-other-frame href))
|
|
451 (_top
|
|
452 (delete-other-windows)
|
|
453 (w3-fetch href))
|
|
454 (otherwise
|
108
|
455 (w3-fetch href target)))))
|
14
|
456
|
|
457 (defun w3-balloon-help-callback (object &optional event)
|
|
458 (let* ((widget (widget-at (extent-start-position object)))
|
165
|
459 (href (widget-get widget :href)))
|
14
|
460 (if href
|
|
461 (url-truncate-url-for-viewing href)
|
|
462 nil)))
|
|
463
|
|
464
|
|
465 ;; Various macros
|
|
466 (eval-when-compile
|
122
|
467 (defmacro w3-node-visible-p ()
|
|
468 (` (not (eq (car break-style) 'none))))
|
|
469
|
14
|
470 (defmacro w3-handle-empty-tag ()
|
|
471 (`
|
|
472 (progn
|
|
473 (push (cons tag args) w3-display-open-element-stack)
|
|
474 (push content content-stack)
|
|
475 (setq content nil))))
|
|
476
|
|
477 (defmacro w3-handle-content (node)
|
|
478 (`
|
|
479 (progn
|
|
480 (push (cons tag args) w3-display-open-element-stack)
|
|
481 (push content content-stack)
|
100
|
482 (setq content (nth 2 (, node))))))
|
14
|
483
|
|
484 (defmacro w3-display-handle-list-type ()
|
|
485 (`
|
118
|
486 (add-text-properties
|
|
487 (point)
|
|
488 (progn
|
|
489 (case (car break-style)
|
|
490 (list-item
|
|
491 (let ((list-style (w3-get-style-info 'list-style-type node))
|
|
492 (list-num (if (car w3-display-list-stack)
|
|
493 (incf (car w3-display-list-stack))
|
|
494 1))
|
|
495 (margin (1- (car left-margin-stack)))
|
|
496 (indent (w3-get-style-info 'text-indent node 0)))
|
|
497 (if (> indent 0)
|
|
498 (setq margin (+ margin indent))
|
|
499 (setq margin (max 0 (- margin indent))))
|
|
500 (beginning-of-line)
|
|
501 (case list-style
|
|
502 ((disc circle square)
|
|
503 (insert (format (format "%%%dc" margin)
|
|
504 (or (cdr-safe (assq list-style w3-bullets))
|
|
505 ?o))))
|
|
506 ((decimal lower-roman upper-roman lower-alpha upper-alpha)
|
|
507 (let ((x (case list-style
|
|
508 (lower-roman
|
|
509 (w3-decimal-to-roman list-num))
|
|
510 (upper-roman
|
|
511 (upcase
|
|
512 (w3-decimal-to-roman list-num)))
|
|
513 (lower-alpha
|
|
514 (w3-decimal-to-alpha list-num))
|
|
515 (upper-alpha
|
|
516 (upcase
|
|
517 (w3-decimal-to-alpha list-num)))
|
|
518 (otherwise
|
|
519 (int-to-string list-num)))))
|
|
520 (insert (format (format "%%%ds." margin) x))
|
|
521 )
|
|
522 )
|
|
523 (otherwise
|
|
524 (insert (w3-get-pad-string margin)))
|
14
|
525 )
|
|
526 )
|
118
|
527 )
|
|
528 (otherwise
|
|
529 (insert (w3-get-pad-string (+ (car left-margin-stack)
|
|
530 (w3-get-style-info 'text-indent node 0)))))
|
14
|
531 )
|
118
|
532 (point))
|
|
533 (list 'start-open t
|
|
534 'end-open t
|
|
535 'rear-nonsticky nil
|
|
536 'face 'nil))))
|
14
|
537
|
|
538 (defmacro w3-display-set-margins ()
|
|
539 (`
|
|
540 (progn
|
|
541 (push (+ (w3-get-style-info 'margin-left node 0)
|
|
542 (car left-margin-stack)) left-margin-stack)
|
|
543 (push (-
|
|
544 (car right-margin-stack)
|
|
545 (w3-get-style-info 'margin-right node 0)) right-margin-stack)
|
|
546 (setq fill-column (car right-margin-stack))
|
|
547 (w3-set-fill-prefix-length (car left-margin-stack))
|
|
548 (w3-display-handle-list-type))))
|
|
549
|
|
550 (defmacro w3-display-restore-margins ()
|
|
551 (`
|
|
552 (progn
|
|
553 (pop right-margin-stack)
|
|
554 (pop left-margin-stack))))
|
|
555
|
|
556 (defmacro w3-display-handle-break ()
|
|
557 (`
|
|
558 (case (car break-style)
|
|
559 (block ; Full paragraph break
|
|
560 (if (eq (cadr break-style) 'list-item)
|
|
561 (setf (cadr break-style) 'line)
|
|
562 (w3-display-line-break 1))
|
|
563 (w3-display-set-margins)
|
|
564 (push
|
|
565 (w3-get-style-info 'white-space node
|
|
566 (car w3-display-whitespace-stack))
|
|
567 w3-display-whitespace-stack)
|
|
568 (push
|
|
569 (or (w3-get-attribute 'align)
|
|
570 (w3-get-style-info 'text-align node
|
|
571 (car w3-display-alignment-stack)))
|
|
572 w3-display-alignment-stack)
|
|
573 (and w3-do-incremental-display (w3-pause)))
|
|
574 ((line list-item) ; Single line break
|
|
575 (w3-display-line-break 0)
|
|
576 (w3-display-set-margins)
|
|
577 (push
|
|
578 (w3-get-style-info 'white-space node
|
|
579 (car w3-display-whitespace-stack))
|
|
580 w3-display-whitespace-stack)
|
|
581 (push
|
|
582 (w3-get-style-info 'text-align node
|
|
583 (or (w3-get-attribute 'align)
|
|
584 (car w3-display-alignment-stack)))
|
|
585 w3-display-alignment-stack))
|
|
586 (otherwise ; Assume 'inline' rendering as default
|
|
587 nil))
|
|
588 )
|
|
589 )
|
|
590
|
100
|
591 (defmacro w3-display-progress-meter ()
|
|
592 (`
|
|
593 (url-lazy-message "Drawing... %c" (aref "/|\\-" (random 4)))))
|
|
594
|
14
|
595 (defmacro w3-display-handle-end-break ()
|
|
596 (`
|
|
597 (case (pop break-style)
|
|
598 (block ; Full paragraph break
|
|
599 (w3-display-line-break 1)
|
|
600 (w3-display-restore-margins)
|
|
601 (pop w3-display-whitespace-stack)
|
|
602 (pop w3-display-alignment-stack)
|
|
603 (and w3-do-incremental-display (w3-pause)))
|
|
604 ((line list-item) ; Single line break
|
|
605 (w3-display-restore-margins)
|
|
606 (w3-display-line-break 0)
|
|
607 (pop w3-display-whitespace-stack)
|
|
608 (pop w3-display-alignment-stack))
|
|
609 (otherwise ; Assume 'inline' rendering as default
|
|
610 nil))
|
|
611 )
|
|
612 )
|
|
613 )
|
|
614
|
|
615 ;; <link> handling
|
|
616 (defun w3-parse-link (args)
|
|
617 (let* ((type (if (w3-get-attribute 'rel) 'rel 'rev))
|
|
618 (desc (w3-get-attribute type))
|
|
619 (dc-desc (and desc (downcase desc))) ; canonical case
|
|
620 (dest (w3-get-attribute 'href))
|
|
621 (plist (alist-to-plist args))
|
|
622 (node-1 (assq type w3-current-links))
|
|
623 (node-2 (and node-1 desc (or (assoc desc
|
|
624 (cdr node-1))
|
|
625 (assoc dc-desc
|
|
626 (cdr node-1)))))
|
|
627 )
|
|
628 ;; Canonicalize the case of link types we may look for
|
|
629 ;; specifically (toolbar etc.) since that's done with
|
|
630 ;; assoc. See `w3-mail-document-author' and
|
|
631 ;; `w3-link-toolbar', at least.
|
|
632 (if (member dc-desc w3-defined-link-types)
|
|
633 (setq desc dc-desc))
|
|
634 (if dest ; ignore if HREF missing
|
|
635 (cond
|
|
636 (node-2 ; Add to old value
|
|
637 (setcdr node-2 (cons plist (cdr node-2))))
|
|
638 (node-1 ; first rel/rev
|
|
639 (setcdr node-1 (cons (cons desc (list plist))
|
|
640 (cdr node-1))))
|
|
641 (t (setq w3-current-links
|
|
642 (cons (cons type (list (cons desc (list plist))))
|
|
643 w3-current-links)))))
|
|
644 (setq desc (and desc (intern dc-desc)))
|
|
645 (case desc
|
|
646 ((style stylesheet)
|
108
|
647 (if w3-honor-stylesheets
|
|
648 (w3-handle-style plist)))
|
14
|
649 (otherwise
|
|
650 )
|
|
651 )
|
|
652 )
|
|
653 )
|
|
654
|
|
655
|
|
656 ;; Image handling
|
|
657 (defun w3-maybe-start-image-download (widget)
|
165
|
658 (let* ((src (widget-get widget :src))
|
14
|
659 (cached-glyph (w3-image-cached-p src)))
|
98
|
660 (cond
|
|
661 ((and cached-glyph
|
|
662 (widget-glyphp cached-glyph)
|
|
663 (not (eq 'nothing
|
|
664 (image-instance-type
|
|
665 (glyph-image-instance cached-glyph)))))
|
|
666 (setq w3-image-widgets-waiting (cons widget w3-image-widgets-waiting)))
|
|
667 ((or w3-delay-image-loads ; Delaying images
|
|
668 (not (fboundp 'valid-specifier-domain-p)) ; Can't do images
|
|
669 (eq (device-type) 'tty)) ; Why bother?
|
|
670 (w3-add-delayed-graphic widget))
|
|
671 ((not (w3-image-loadable-p src nil)) ; Hey, we can't load it!
|
165
|
672 (mesage "Skipping image %s" (url-basepath src t))
|
98
|
673 (w3-add-delayed-graphic widget))
|
|
674 (t ; Grab the images
|
|
675 (let (
|
|
676 (url-request-method "GET")
|
|
677 (old-asynch url-be-asynchronous)
|
|
678 (url-request-data nil)
|
|
679 (url-request-extra-headers nil)
|
|
680 (url-source t)
|
|
681 (url-mime-accept-string (substring
|
|
682 (mapconcat
|
|
683 (function
|
|
684 (lambda (x)
|
|
685 (if x
|
|
686 (concat (car x) ",")
|
|
687 "")))
|
|
688 w3-allowed-image-types "")
|
|
689 0 -1))
|
|
690 (url-working-buffer (generate-new-buffer-name " *W3GRAPH*")))
|
|
691 (setq-default url-be-asynchronous t)
|
|
692 (setq w3-graphics-list (cons (cons src (make-glyph))
|
|
693 w3-graphics-list))
|
|
694 (save-excursion
|
|
695 (set-buffer (get-buffer-create url-working-buffer))
|
165
|
696 (setq url-current-callback-data (list src (widget-get widget 'buffer)
|
|
697 widget)
|
98
|
698 url-be-asynchronous t
|
|
699 url-current-callback-func 'w3-finalize-image-download)
|
|
700 (url-retrieve src))
|
|
701 (setq-default url-be-asynchronous old-asynch))))))
|
14
|
702
|
165
|
703 (defun w3-maybe-start-background-image-download (src face)
|
|
704 (let* ((cached-glyph (w3-image-cached-p src))
|
|
705 (buf (current-buffer)))
|
|
706 (cond
|
|
707 ((and cached-glyph
|
|
708 (widget-glyphp cached-glyph)
|
|
709 (not (eq 'nothing
|
|
710 (image-instance-type
|
|
711 (glyph-image-instance cached-glyph)))))
|
|
712 (set-face-background-pixmap face
|
|
713 (glyph-image-instance cached-glyph) buf))
|
|
714 ((or (not (fboundp 'valid-specifier-domain-p)) ; Can't do images
|
|
715 (eq (device-type) 'tty)) ; Why bother?
|
|
716 nil)
|
|
717 ((not (w3-image-loadable-p src nil)) ; Hey, we can't load it!
|
|
718 (mesage "Skipping image %s" (url-basepath src t))
|
|
719 nil)
|
|
720 (t ; Grab the images
|
|
721 (let (
|
|
722 (url-request-method "GET")
|
|
723 (old-asynch url-be-asynchronous)
|
|
724 (url-request-data nil)
|
|
725 (url-request-extra-headers nil)
|
|
726 (url-source t)
|
|
727 (url-mime-accept-string (substring
|
|
728 (mapconcat
|
|
729 (function
|
|
730 (lambda (x)
|
|
731 (if x
|
|
732 (concat (car x) ",")
|
|
733 "")))
|
|
734 w3-allowed-image-types "")
|
|
735 0 -1))
|
|
736 (url-working-buffer (generate-new-buffer-name " *W3GRAPH*")))
|
|
737 (setq-default url-be-asynchronous t)
|
|
738 (setq w3-graphics-list (cons (cons src (make-glyph))
|
|
739 w3-graphics-list))
|
|
740 (save-excursion
|
|
741 (set-buffer (get-buffer-create url-working-buffer))
|
|
742 (setq url-current-callback-data (list src buf 'background face)
|
|
743 url-be-asynchronous t
|
|
744 url-current-callback-func 'w3-finalize-image-download)
|
|
745 (url-retrieve src))
|
|
746 (setq-default url-be-asynchronous old-asynch))))))
|
|
747
|
|
748 (defun w3-finalize-image-download (url buffer &optional widget face)
|
14
|
749 (let ((glyph nil)
|
165
|
750 (node nil))
|
14
|
751 (message "Enhancing image...")
|
|
752 (setq glyph (image-normalize (cdr-safe (assoc url-current-mime-type
|
|
753 w3-image-mappings))
|
|
754 (buffer-string)))
|
|
755 (message "Enhancing image... done")
|
|
756 (kill-buffer (current-buffer))
|
|
757 (cond
|
|
758 ((w3-image-invalid-glyph-p glyph)
|
|
759 (setq glyph nil)
|
98
|
760 (message "Reading of %s failed." url))
|
14
|
761 ((eq (aref glyph 0) 'xbm)
|
|
762 (let ((temp-fname (url-generate-unique-filename "%s.xbm")))
|
|
763 (save-excursion
|
|
764 (set-buffer (generate-new-buffer " *xbm-garbage*"))
|
|
765 (erase-buffer)
|
|
766 (insert (aref glyph 2))
|
|
767 (setq glyph temp-fname)
|
|
768 (write-region (point-min) (point-max) temp-fname)
|
|
769 (kill-buffer (current-buffer)))
|
|
770 (setq glyph (make-glyph (list (cons 'x glyph))))
|
|
771 (condition-case ()
|
|
772 (delete-file temp-fname)
|
|
773 (error nil))))
|
|
774 (t
|
|
775 (setq glyph (make-glyph glyph))))
|
|
776 (setq node (assoc url w3-graphics-list))
|
|
777 (cond
|
|
778 ((and node glyph)
|
|
779 (set-glyph-image (cdr node) (glyph-image glyph)))
|
|
780 (glyph
|
|
781 (setq w3-graphics-list (cons (cons url glyph) w3-graphics-list)))
|
|
782 (t nil))
|
|
783
|
165
|
784 (cond
|
|
785 ((or (not buffer)
|
|
786 (not (widget-glyphp glyph))
|
|
787 (not (buffer-name buffer)))
|
|
788 nil)
|
|
789 ((and (eq widget 'background)
|
|
790 w3-running-xemacs)
|
|
791 (set-face-background-pixmap face
|
|
792 (glyph-image-instance glyph)
|
|
793 buffer))
|
|
794 ((not (eq widget 'background))
|
|
795 (save-excursion
|
|
796 (set-buffer buffer)
|
|
797 (if (eq major-mode 'w3-mode)
|
|
798 (widget-value-set widget glyph)
|
|
799 (setq w3-image-widgets-waiting
|
|
800 (cons widget w3-image-widgets-waiting))))))))
|
14
|
801
|
|
802 (defmacro w3-handle-image ()
|
|
803 (`
|
|
804 (let* ((height (w3-get-attribute 'height))
|
|
805 (width (w3-get-attribute 'width))
|
|
806 (src (or (w3-get-attribute 'src) "Error Image"))
|
|
807 (our-alt (cond
|
|
808 ((null w3-auto-image-alt) "")
|
|
809 ((eq t w3-auto-image-alt)
|
|
810 (concat "[IMAGE(" (url-basepath src t) ")] "))
|
|
811 ((stringp w3-auto-image-alt)
|
|
812 (format w3-auto-image-alt (url-basepath src t)))))
|
|
813 (alt (or (w3-get-attribute 'alt) our-alt))
|
116
|
814 (c nil)
|
14
|
815 (ismap (and (assq 'ismap args) 'ismap))
|
|
816 (usemap (w3-get-attribute 'usemap))
|
|
817 (base (w3-get-attribute 'base))
|
165
|
818 (href (and hyperlink-info (widget-get (cadr hyperlink-info) :href)))
|
|
819 (target (and hyperlink-info (widget-get (cadr hyperlink-info) :target)))
|
14
|
820 (widget nil)
|
|
821 (align (or (w3-get-attribute 'align)
|
|
822 (w3-get-style-info 'vertical-align node))))
|
116
|
823 (while (setq c (string-match "[\C-i\C-j\C-l\C-m]" alt))
|
|
824 (aset alt c ? ))
|
88
|
825 (if (assq '*table-autolayout w3-display-open-element-stack)
|
|
826 (insert alt)
|
|
827 (setq widget (widget-create 'image
|
|
828 :value-face w3-active-faces
|
165
|
829 :src src ; Where to load the image from
|
88
|
830 'alt alt ; Textual replacement
|
|
831 'ismap ismap ; Is it a server-side map?
|
|
832 'usemap usemap ; Is it a client-side map?
|
165
|
833 :href href ; Hyperlink destination
|
|
834 :target target
|
88
|
835 ))
|
|
836 (widget-put widget 'buffer (current-buffer))
|
|
837 (w3-maybe-start-image-download widget)
|
108
|
838 (if (widget-get widget :from)
|
|
839 (add-text-properties (widget-get widget :from)
|
|
840 (widget-get widget :to)
|
|
841 (list 'html-stack w3-display-open-element-stack)))
|
88
|
842 (goto-char (point-max))))))
|
14
|
843
|
|
844 ;; The table handling
|
|
845
|
165
|
846 (if (and w3-running-xemacs (featurep 'mule)
|
|
847 (not (find-charset 'w3-dingbats)))
|
136
|
848 (make-charset 'w3-dingbats "Dingbats character set for Emacs/W3"
|
|
849 '(registry "" dimension 1 chars 96 final ?:)))
|
|
850
|
|
851 (defun w3-make-char (oct)
|
|
852 (if (and w3-running-xemacs (featurep 'mule))
|
|
853 (make-char 'w3-dingbats (if (characterp oct) (char-int oct) oct))
|
|
854 oct))
|
|
855
|
116
|
856 (defvar w3-table-ascii-border-chars
|
165
|
857 [nil nil nil ?' nil ?- ?` ?- nil ?\\ ?| ?| ?/ ?- ?| ?+]
|
116
|
858 "*Vector of ascii characters to use to draw table borders.
|
|
859 This vector is used when terminal characters are unavailable")
|
|
860
|
|
861 (defvar w3-table-glyph-border-chars
|
|
862 [nil nil nil 11 nil 2 7 14 nil 3 8 6 1 15 4 5]
|
|
863 "Vector of characters to use to draw table borders.
|
|
864 This vector is used when terminal characters are used via glyphs")
|
|
865
|
|
866 (defvar w3-table-graphic-border-chars
|
136
|
867 (vector
|
|
868 nil
|
|
869 nil
|
|
870 nil
|
|
871 (w3-make-char ?j)
|
|
872 nil
|
|
873 (w3-make-char ?q)
|
|
874 (w3-make-char ?m)
|
|
875 (w3-make-char ?v)
|
|
876 nil
|
|
877 (w3-make-char ?k)
|
|
878 (w3-make-char ?x)
|
|
879 (w3-make-char ?u)
|
|
880 (w3-make-char ?l)
|
|
881 (w3-make-char ?w)
|
|
882 (w3-make-char ?t)
|
|
883 (w3-make-char ?n))
|
116
|
884 "Vector of characters to use to draw table borders.
|
|
885 This vector is used when terminal characters are used directly")
|
|
886
|
|
887 (defvar w3-table-border-chars w3-table-ascii-border-chars
|
|
888 "Vector of characters to use to draw table borders.
|
|
889 w3-setup-terminal-chars sets this to one of
|
|
890 w3-table-ascii-border-chars,
|
|
891 w3-table-glyph-border-chars, or
|
|
892 w3-table-graphic-border-chars.")
|
|
893
|
165
|
894 (defsubst w3-table-lookup-char (l u r b &optional char)
|
116
|
895 (aref w3-table-border-chars (logior (if l 1 0)
|
|
896 (if u 2 0)
|
|
897 (if r 4 0)
|
|
898 (if b 8 0))))
|
|
899
|
|
900 (defvar w3-terminal-properties nil)
|
|
901
|
|
902 (defsubst w3-insert-terminal-char (character &optional count inherit)
|
|
903 (if w3-terminal-properties
|
|
904 (set-text-properties (point)
|
|
905 (progn
|
|
906 (insert-char (or character ? )
|
|
907 (or count 1) inherit)
|
|
908 (point))
|
|
909 w3-terminal-properties)
|
|
910 (insert-char (or character ? ) (or count 1) inherit)))
|
|
911
|
|
912 (defsubst w3-horizontal-rule-char nil
|
|
913 (or w3-horizontal-rule-char (w3-table-lookup-char t nil t nil)))
|
|
914
|
165
|
915 (defun w3-setup-terminal-chars ()
|
116
|
916 "Try to find the best set of characters to draw table borders with.
|
|
917 On a console, this can trigger some Emacs display bugs.
|
|
918
|
|
919 Initializes a number of variables:
|
|
920 w3-terminal-properties to either nil or a list of properties including 'face
|
|
921 w3-table-border-chars to one of the the three other vectors"
|
|
922 (interactive)
|
|
923 (setq w3-table-border-chars w3-table-ascii-border-chars
|
|
924 w3-terminal-properties nil)
|
|
925 (cond
|
|
926 ((and w3-use-terminal-characters
|
|
927 (eq (device-type) 'x))
|
118
|
928 (if (and (find-face 'w3-table-hack-x-face)
|
|
929 (face-differs-from-default-p 'w3-table-hack-x-face))
|
|
930 nil
|
116
|
931 (make-face 'w3-table-hack-x-face)
|
118
|
932 (if (not (face-differs-from-default-p 'w3-table-hack-x-face))
|
|
933 (font-set-face-font 'w3-table-hack-x-face
|
|
934 (make-font :family "terminal"
|
|
935 :registry "*"
|
|
936 :encoding "*"
|
|
937 ))))
|
116
|
938 (cond
|
|
939 ((not (face-differs-from-default-p 'w3-table-hack-x-face))
|
|
940 nil)
|
|
941 ((and w3-use-terminal-glyphs (fboundp 'face-id))
|
|
942 (let ((id (face-id 'w3-table-hack-x-face))
|
|
943 (c (length w3-table-border-chars)))
|
|
944 (while (> (decf c) 0)
|
|
945 (if (aref w3-table-glyph-border-chars c)
|
|
946 (aset standard-display-table (aref w3-table-glyph-border-chars c)
|
|
947 (vector (+ (* 256 id)
|
|
948 (aref w3-table-graphic-border-chars c))))))
|
|
949 (setq w3-table-border-chars w3-table-glyph-border-chars
|
|
950 w3-terminal-properties nil)))
|
|
951 (t
|
|
952 (setq w3-table-border-chars w3-table-graphic-border-chars
|
|
953 w3-terminal-properties (list 'start-open t
|
|
954 'end-open t
|
|
955 'rear-nonsticky t
|
|
956 'w3-table-border t
|
|
957 'face 'w3-table-hack-x-face)))))
|
|
958 ((and w3-use-terminal-characters-on-tty
|
|
959 (eq (device-type) 'tty))
|
|
960 (let ((c (length w3-table-border-chars)))
|
|
961 (while (> (decf c) 0)
|
|
962 (and (aref w3-table-glyph-border-chars c)
|
|
963 (aref w3-table-graphic-border-chars c)
|
|
964 (standard-display-g1 (aref w3-table-glyph-border-chars c)
|
|
965 (aref w3-table-graphic-border-chars c)))))
|
|
966 (setq w3-table-border-chars w3-table-glyph-border-chars
|
|
967 w3-terminal-properties (list 'w3-table-border t)))
|
|
968 (t
|
|
969 nil))
|
|
970 w3-table-border-chars)
|
|
971
|
|
972 (defun w3-unsetup-terminal-characters nil
|
|
973 (interactive)
|
|
974 (w3-excise-terminal-characters (buffer-list))
|
|
975 (standard-display-default 1 15)
|
|
976 (setq w3-table-border-chars w3-table-ascii-border-chars))
|
|
977
|
|
978 (defun w3-excise-terminal-characters (buffs)
|
|
979 "Replace hacked characters with ascii characters in buffers BUFFS.
|
|
980 Should be run before restoring w3-table-border-chars to ascii characters.
|
|
981 This will only work if we used glyphs rather than text properties"
|
|
982 (interactive (list (list (current-buffer))))
|
|
983 (let ((inhibit-read-only t)
|
|
984 (tr (make-string 16 ? ))
|
|
985 (i 0))
|
|
986 (while (< i (length tr))
|
|
987 (aset tr i i)
|
|
988 (setq i (1+ i)))
|
|
989 (setq i 0)
|
|
990 (while (< i (length w3-table-border-chars))
|
|
991 (and (aref w3-table-border-chars i)
|
|
992 (< (aref w3-table-border-chars i) 16)
|
|
993 (aset tr
|
|
994 (aref w3-table-glyph-border-chars i)
|
|
995 (aref w3-table-ascii-border-chars i)))
|
|
996 (setq i (1+ i)))
|
|
997 (mapcar (function (lambda (buf)
|
|
998 (save-excursion
|
|
999 (set-buffer buf)
|
|
1000 (if (eq major-mode 'w3-mode)
|
|
1001 (translate-region (point-min)
|
|
1002 (point-max)
|
|
1003 tr)))))
|
|
1004 buffs)))
|
|
1005
|
|
1006
|
14
|
1007 (defvar w3-display-table-cut-words-p nil
|
|
1008 "*Whether to cut words that are oversized in table cells")
|
|
1009
|
|
1010 (defvar w3-display-table-force-borders nil
|
116
|
1011 "*Whether to always draw table borders
|
|
1012 Can sometimes make the structure of a document clearer")
|
14
|
1013
|
|
1014 (defun w3-display-table-cut ()
|
|
1015 (save-excursion
|
|
1016 (goto-char (point-min))
|
|
1017 (let ((offset -1))
|
|
1018 (while (< offset 0)
|
|
1019 (end-of-line)
|
|
1020 (setq offset (- fill-column (current-column)))
|
|
1021 (cond ((< offset 0)
|
|
1022 (condition-case nil
|
|
1023 (progn (forward-char offset)
|
|
1024 (insert ?\n))
|
|
1025 (error (setq offset 0))))
|
|
1026 ((not (eobp))
|
|
1027 (forward-line 1)
|
|
1028 (setq offset -1)))))))
|
|
1029
|
|
1030
|
|
1031 (defun w3-display-fix-widgets ()
|
|
1032 ;; Make markers belong to the right buffer
|
|
1033 (save-excursion
|
|
1034 (let ((st (point-min))
|
|
1035 (nd nil)
|
|
1036 (widget nil) parent
|
|
1037 (to-marker nil)
|
|
1038 (from-marker nil))
|
|
1039 (while (setq st (next-single-property-change st 'button))
|
|
1040 (setq nd (or (next-single-property-change st 'button) (point-max))
|
|
1041 widget (widget-at st)
|
|
1042 to-marker (and widget (widget-get widget :to))
|
|
1043 from-marker (and widget (widget-get widget :from))
|
|
1044 parent (and widget (widget-get widget :parent))
|
|
1045 )
|
|
1046 (if (not widget)
|
|
1047 nil
|
|
1048 (widget-put widget :from (set-marker (make-marker) st))
|
|
1049 (widget-put widget :to (set-marker (make-marker) nd))
|
|
1050 (if (not parent)
|
|
1051 nil
|
|
1052 (widget-put parent :from (set-marker (make-marker) st))
|
|
1053 (widget-put parent :to (set-marker (make-marker) nd))))
|
|
1054 (if (condition-case ()
|
|
1055 (get-text-property (1+ nd) 'button)
|
|
1056 (error nil))
|
|
1057 (setq st nd)
|
|
1058 (setq st (min (point-max) (1+ nd))))))))
|
|
1059
|
|
1060 (defun w3-size-of-tree (tree minmax)
|
98
|
1061 (declare (special args))
|
14
|
1062 (save-excursion
|
|
1063 (save-restriction
|
|
1064 (narrow-to-region (point) (point))
|
|
1065 ;; XXX fill-column set to 1 fails when fill-prefix is set
|
|
1066 ;; XXX setting fill-column at all isn't really right
|
|
1067 ;; for example <hr>s shouldn't be especially wide
|
|
1068 ;; we should set a flag that makes w3 never wrap a line
|
|
1069 (let ((fill-column (cond ((eq minmax 'min)
|
|
1070 3)
|
|
1071 ((eq minmax 'max)
|
|
1072 400)))
|
|
1073 (fill-prefix "")
|
|
1074 (w3-last-fill-pos (point-min))
|
|
1075 a retval
|
|
1076 (w3-do-incremental-display nil)
|
|
1077 (hr-regexp (concat "^"
|
|
1078 (regexp-quote
|
116
|
1079 (make-string 5 (w3-horizontal-rule-char)))
|
14
|
1080 "*$"))
|
|
1081 )
|
|
1082 ;;(push 'left w3-display-alignment-stack)
|
|
1083 (push (if (eq minmax 'max) 'nowrap) w3-display-whitespace-stack)
|
|
1084 (while tree
|
|
1085 (push (cons '*td args) w3-display-open-element-stack)
|
|
1086 (w3-display-node (pop tree)))
|
|
1087 (pop w3-display-whitespace-stack)
|
|
1088 (goto-char (point-min))
|
|
1089 (while (re-search-forward hr-regexp nil t)
|
|
1090 (replace-match "" t t))
|
|
1091 (goto-char (point-min))
|
|
1092 (while (not (eobp))
|
|
1093 ;; loop invariant: at beginning of uncounted line
|
|
1094 (end-of-line)
|
|
1095 (skip-chars-backward " ")
|
|
1096 (setq retval (cons (current-column)
|
|
1097 retval))
|
|
1098 (beginning-of-line 2))
|
|
1099 (if (= (point-min) (point-max))
|
|
1100 (setq retval 0)
|
|
1101 (setq retval (apply 'max (cons 0 retval))))
|
|
1102 (delete-region (point-min) (point-max))
|
|
1103 retval))))
|
|
1104
|
|
1105 (defun w3-display-table-dimensions (node)
|
|
1106 ;; fill-column sets maximum width
|
98
|
1107 (declare (special args))
|
14
|
1108 (let (min-vector
|
|
1109 max-vector
|
|
1110 rows cols
|
|
1111 ;;(w3-form-elements (and (boundp 'w3-form-elements) w3-form-elements))
|
|
1112 (table-info (assq 'w3-table-info (cadr node))))
|
|
1113
|
|
1114 (if table-info
|
|
1115 (setq min-vector (nth 1 table-info)
|
|
1116 max-vector (nth 2 table-info)
|
|
1117 rows (nth 3 table-info)
|
|
1118 cols (nth 4 table-info))
|
|
1119
|
|
1120 (push (cons '*table-autolayout args) w3-display-open-element-stack)
|
|
1121 (let (content
|
|
1122 cur
|
|
1123 (table-spans (list nil)) ; don't make this '(nil)
|
|
1124 ptr
|
|
1125 col
|
|
1126 constraints
|
|
1127
|
|
1128 colspan rowspan min max)
|
|
1129 (setq content (nth 2 node))
|
|
1130 (setq rows 0 cols 0)
|
|
1131 (while content
|
|
1132 (setq cur (pop content))
|
|
1133 (if (stringp cur)
|
|
1134 nil
|
|
1135 (case (car cur)
|
138
|
1136 ((thead tfoot col colgroup)
|
|
1137 (if (nth 2 cur)
|
|
1138 (setq content (append (nth 2 cur) content))))
|
14
|
1139 (tr
|
|
1140 (setq col 0)
|
|
1141 (setq rows (1+ rows))
|
|
1142 (setq ptr table-spans)
|
|
1143 (mapcar
|
|
1144 (function
|
|
1145 (lambda (td)
|
|
1146 (setq colspan (string-to-int (or (cdr-safe (assq 'colspan (nth 1 td))) "1"))
|
|
1147 rowspan (string-to-int (or (cdr-safe (assq 'rowspan (nth 1 td))) "1"))
|
|
1148 min (w3-size-of-tree (nth 2 td) 'min)
|
|
1149 max (w3-size-of-tree (nth 2 td) 'max)
|
|
1150 )
|
|
1151 (while (eq (car-safe (car-safe (cdr ptr))) col)
|
|
1152 (setq col (+ col (cdr (cdr (car (cdr ptr))))))
|
|
1153 (if (= 0 (decf (car (cdr (car (cdr ptr))))))
|
|
1154 (pop (cdr ptr))
|
|
1155 (setq ptr (cdr ptr))))
|
|
1156 (push (list col colspan min max)
|
|
1157 constraints)
|
|
1158 (if (= rowspan 1) nil
|
|
1159 (push (cons col (cons (1- rowspan) colspan)) (cdr ptr))
|
|
1160 (setq ptr (cdr ptr)))
|
|
1161 (setq col (+ col colspan))
|
|
1162 ))
|
|
1163 (nth 2 cur))
|
|
1164 (while (cdr ptr)
|
|
1165 (if (= 0 (decf (car (cdr (car (cdr ptr))))))
|
|
1166 (pop (cdr ptr))
|
|
1167 (setq ptr (cdr ptr))))
|
|
1168 (setq cols (max cols col))
|
|
1169 )
|
|
1170 (caption
|
|
1171 nil)
|
|
1172 (otherwise
|
|
1173 (setq content (nth 2 cur)))
|
|
1174 )
|
|
1175 )
|
|
1176 )
|
|
1177 (setq constraints (sort constraints
|
|
1178 (function
|
|
1179 (lambda (a b)
|
|
1180 (< (cadr a) (cadr b)))))
|
|
1181 min-vector (make-vector cols 0)
|
|
1182 max-vector (make-vector cols 0))
|
|
1183 (let (start end i mincellwidth maxcellwidth)
|
|
1184 (mapcar (function (lambda (c)
|
|
1185 (cond ((= (cadr c) 1)
|
|
1186 (aset min-vector (car c)
|
|
1187 (max (aref min-vector (car c))
|
|
1188 (nth 2 c)))
|
|
1189 (aset max-vector (car c)
|
|
1190 (max (aref max-vector (car c))
|
|
1191 (nth 3 c))))
|
|
1192 (t
|
|
1193 (setq start (car c)
|
|
1194 end (+ (car c) (cadr c))
|
|
1195 mincellwidth 0
|
|
1196 maxcellwidth 0
|
|
1197 i start)
|
|
1198 (while (< i end)
|
|
1199 (setq mincellwidth (+ mincellwidth
|
|
1200 (aref min-vector i))
|
|
1201 maxcellwidth (+
|
|
1202 maxcellwidth
|
|
1203 (aref max-vector i))
|
|
1204 i (1+ i)))
|
|
1205 (setq i start)
|
|
1206 (if (= mincellwidth 0)
|
|
1207 ;; if existing width is 0 divide evenly
|
|
1208 (while (< i end)
|
|
1209 (aset min-vector i
|
|
1210 (/ (nth 2 c) (cadr c)))
|
|
1211 (aset max-vector i
|
|
1212 (/ (nth 3 c) (cadr c)))
|
|
1213 (setq i (1+ i)))
|
|
1214 ;; otherwise weight it by existing widths
|
|
1215 (while (< i end)
|
|
1216 (aset min-vector i
|
|
1217 (max (aref min-vector i)
|
|
1218 (/ (* (nth 2 c)
|
|
1219 (aref min-vector i))
|
|
1220 mincellwidth)))
|
|
1221 (aset max-vector i
|
|
1222 (max (aref max-vector i)
|
|
1223 (/ (* (nth 3 c)
|
|
1224 (aref max-vector i))
|
|
1225 maxcellwidth)))
|
|
1226 (setq i (1+ i))))
|
|
1227 ))))
|
|
1228 constraints)))
|
|
1229 (push (cons 'w3-table-info
|
|
1230 (list min-vector max-vector rows cols))
|
|
1231 (cadr node))
|
|
1232 (pop w3-display-open-element-stack))
|
|
1233
|
|
1234 (let (max-width
|
|
1235 min-width
|
|
1236 ret-vector
|
|
1237 col
|
|
1238 )
|
|
1239
|
|
1240
|
|
1241 (setq max-width (apply '+ (append max-vector (list cols 1))))
|
|
1242 (setq min-width (apply '+ (append min-vector (list cols 1))))
|
|
1243
|
|
1244 ;; the comments in the cond are excerpts from rfc1942 itself
|
|
1245 (cond
|
|
1246 ;; 1. The minimum table width is equal to or wider than the available
|
|
1247 ;; space. In this case, assign the minimum widths and allow the
|
|
1248 ;; user to scroll horizontally. For conversion to braille, it will
|
|
1249 ;; be necessary to replace the cells by references to notes
|
|
1250 ;; containing their full content. By convention these appear
|
|
1251 ;; before the table.
|
|
1252 ((>= min-width fill-column)
|
|
1253 (setq ret-vector min-vector))
|
|
1254
|
|
1255 ;; 2. The maximum table width fits within the available space. In
|
|
1256 ;; this case, set the columns to their maximum widths.
|
|
1257 ((<= max-width fill-column)
|
|
1258 (setq ret-vector max-vector))
|
|
1259
|
|
1260 ;; 3. The maximum width of the table is greater than the available
|
|
1261 ;; space, but the minimum table width is smaller. In this case,
|
|
1262 ;; find the difference between the available space and the minimum
|
|
1263 ;; table width, lets call it W. Lets also call D the difference
|
|
1264 ;; between maximum and minimum width of the table.
|
|
1265
|
|
1266 ;; For each column, let d be the difference between maximum and
|
|
1267 ;; minimum width of that column. Now set the column's width to the
|
|
1268 ;; minimum width plus d times W over D. This makes columns with
|
|
1269 ;; large differences between minimum and maximum widths wider than
|
|
1270 ;; columns with smaller differences.
|
|
1271 (t
|
|
1272 (setq ret-vector (make-vector cols 0))
|
|
1273 (let ((W (- fill-column min-width))
|
|
1274 (D (- max-width min-width))
|
|
1275 d extra)
|
|
1276 (setq col 0)
|
|
1277 (while (< col (length ret-vector))
|
|
1278 (setq d (- (aref max-vector col)
|
|
1279 (aref min-vector col)))
|
|
1280 (aset ret-vector col
|
|
1281 (+ (aref min-vector col)
|
|
1282 (/ (* d W) D)))
|
|
1283 (setq col (1+ col)))
|
|
1284 (setq extra (- fill-column
|
|
1285 (apply '+ (append ret-vector
|
|
1286 (list (length ret-vector) 1))))
|
|
1287 col 0)
|
|
1288 (while (and (< col (length ret-vector)) (> extra 0))
|
|
1289 (if (= 1 (- (aref max-vector col) (aref ret-vector col) ))
|
|
1290 (aset ret-vector col (1+ (aref ret-vector col))))
|
|
1291 (setq extra (1- extra)
|
|
1292 col (1+ col)))
|
|
1293 )))
|
|
1294 (list rows cols ret-vector))))
|
|
1295
|
|
1296 (defun w3-display-table (node)
|
|
1297 (let* ((dimensions (w3-display-table-dimensions node))
|
|
1298 (num-cols (max (cadr dimensions) 1))
|
|
1299 (num-rows (max (car dimensions) 1))
|
|
1300 (column-dimensions (caddr dimensions))
|
|
1301 (table-width (apply '+ (append column-dimensions (list num-cols 1)))))
|
|
1302 (cond
|
|
1303 ((or (<= (cadr dimensions) 0) (<= (car dimensions) 0))
|
|
1304 ;; We have an invalid table
|
|
1305 nil)
|
|
1306 ((assq '*table-autolayout w3-display-open-element-stack)
|
|
1307 ;; don't bother displaying the table if all we really need is the size
|
|
1308 (progn (insert-char ?T table-width) (insert "\n")))
|
|
1309 (t
|
|
1310 (let* ((tag (nth 0 node))
|
|
1311 (args (nth 1 node))
|
|
1312 (border-node (cdr-safe (assq 'border args)))
|
|
1313 (border (or w3-display-table-force-borders
|
|
1314 (and border-node
|
|
1315 (or (/= 0 (string-to-int border-node))
|
|
1316 (string= "border" border-node)))))
|
|
1317 (w3-table-border-chars
|
|
1318 (if border
|
|
1319 w3-table-border-chars
|
|
1320 (make-vector (length w3-table-border-chars) ? )))
|
|
1321 valign align
|
|
1322 (content (nth 2 node))
|
|
1323 (avgwidth (/ (- fill-column num-cols num-cols) num-cols))
|
|
1324 (formatted-cols (make-vector num-cols nil))
|
|
1325 (table-rowspans (make-vector num-cols 0))
|
|
1326 (table-colspans (make-vector num-cols 1))
|
|
1327 (prev-colspans (make-vector num-cols 0))
|
|
1328 (prev-rowspans (make-vector num-cols 0))
|
|
1329 (table-colwidth (make-vector num-cols 0))
|
|
1330 (fill-prefix "")
|
|
1331 (height nil)
|
|
1332 (cur-height nil)
|
|
1333 (cols nil)
|
|
1334 (rows nil)
|
|
1335 (row 0)
|
|
1336 (this-rectangle nil)
|
118
|
1337 (inhibit-read-only t)
|
14
|
1338 (i 0)
|
|
1339 )
|
|
1340
|
|
1341 (push (cons tag args) w3-display-open-element-stack)
|
|
1342
|
|
1343 (if (memq 'nowrap w3-display-whitespace-stack)
|
|
1344 (setq fill-prefix "")
|
|
1345 (case (car w3-display-alignment-stack)
|
|
1346 (center
|
|
1347 (w3-set-fill-prefix-length
|
|
1348 (max 0 (/ (- fill-column table-width) 2))))
|
|
1349 (right
|
|
1350 (w3-set-fill-prefix-length
|
|
1351 (max 0 (- fill-column table-width))))
|
|
1352 (t
|
|
1353 (setq fill-prefix ""))))
|
|
1354 (while content
|
|
1355 (case (caar content)
|
138
|
1356 ((thead tfoot col colgroup)
|
|
1357 (if (nth 2 (car content))
|
|
1358 (setq content (append (nth 2 (car content)) (cdr content)))
|
|
1359 (setq content (cdr content))))
|
14
|
1360 (tr
|
|
1361 (setq w3-display-css-properties (css-get
|
|
1362 (nth 0 (car content))
|
|
1363 (nth 1 (car content))
|
|
1364 w3-current-stylesheet
|
|
1365 w3-display-open-element-stack))
|
|
1366 (setq cols (nth 2 (car content))
|
|
1367 valign (or (cdr-safe (assq 'valign (nth 1 (car content))))
|
|
1368 (w3-get-style-info 'vertical-align node))
|
|
1369 align (or (cdr-safe (assq 'align (nth 1 (car content))))
|
|
1370 (w3-get-style-info 'text-align node))
|
|
1371 content (cdr content)
|
|
1372 row (1+ row))
|
|
1373 (if (and valign (stringp valign))
|
|
1374 (setq valign (intern (downcase valign))))
|
|
1375 ;; this is iffy
|
|
1376 ;;(if align (push (intern (downcase align)) w3-display-alignment-stack))
|
|
1377 (save-excursion
|
|
1378 (save-restriction
|
|
1379 (narrow-to-region (point) (point))
|
|
1380 (setq fill-column avgwidth
|
|
1381 w3-last-fill-pos (point-min)
|
|
1382 i 0)
|
|
1383 ;; skip over columns that have leftover content
|
|
1384 (while (and (< i num-cols)
|
|
1385 (/= 0 (aref table-rowspans i)))
|
|
1386 (setq i (+ i (max 1 (aref table-colspans i)))))
|
118
|
1387 ;; Need to push the properties for the table onto the stack
|
|
1388 (setq w3-display-css-properties (css-get
|
|
1389 tag
|
|
1390 args
|
|
1391 w3-current-stylesheet
|
|
1392 w3-display-open-element-stack))
|
|
1393 (push (w3-face-for-element (list tag args nil)) w3-active-faces)
|
|
1394 (push (w3-voice-for-element (list tag args nil)) w3-active-voices)
|
|
1395 (push (cons tag args) w3-display-open-element-stack)
|
14
|
1396 (while cols
|
118
|
1397 ;; And need to push these bogus placeholders on there
|
|
1398 ;; so that w3-display-node doesn't pop off the real face
|
|
1399 ;; or voice we just put in above.
|
|
1400 (push nil w3-active-faces)
|
|
1401 (push nil w3-active-voices)
|
14
|
1402 (let* ((node (car cols))
|
|
1403 (attributes (nth 1 node))
|
|
1404 (colspan (string-to-int
|
|
1405 (or (cdr-safe (assq 'colspan attributes))
|
|
1406 "1")))
|
|
1407 (rowspan (string-to-int
|
|
1408 (or (cdr-safe (assq 'rowspan attributes))
|
|
1409 "1")))
|
|
1410 fill-column column-width
|
|
1411 (fill-prefix "")
|
|
1412 (w3-do-incremental-display nil)
|
|
1413 (indent-tabs-mode nil)
|
|
1414 c e
|
|
1415 )
|
|
1416
|
|
1417 (aset table-colspans i colspan)
|
|
1418 (aset table-rowspans i rowspan)
|
|
1419
|
|
1420 (setq fill-column 0)
|
|
1421 (setq c i
|
|
1422 e (+ i colspan))
|
|
1423 (while (< c e)
|
|
1424 (setq fill-column (+ fill-column
|
|
1425 (aref column-dimensions c)
|
|
1426 1)
|
|
1427 c (1+ c)))
|
|
1428 (setq fill-column (1- fill-column))
|
|
1429 (aset table-colwidth i fill-column)
|
|
1430
|
|
1431 (setq w3-last-fill-pos (point-min))
|
|
1432 (push (cons (nth 0 node) (nth 1 node))
|
|
1433 w3-display-open-element-stack)
|
|
1434 (w3-display-node node)
|
|
1435 (setq fill-column (aref table-colwidth i))
|
|
1436 (if w3-display-table-cut-words-p
|
|
1437 (w3-display-table-cut))
|
|
1438 (setq cols (cdr cols))
|
|
1439 (goto-char (point-min))
|
|
1440 (skip-chars-forward "\t\n\r")
|
|
1441 (beginning-of-line)
|
|
1442 (delete-region (point-min) (point))
|
|
1443 (goto-char (point-max))
|
|
1444 (skip-chars-backward " \t\n\r")
|
|
1445 (delete-region (point) (point-max))
|
|
1446 (if (>= fill-column (current-column))
|
118
|
1447 (insert-char ? (- fill-column (current-column)) t))
|
|
1448 (goto-char (point-min))
|
|
1449 ;; This gets our text properties out to the
|
|
1450 ;; end of lines for table rows/cells with backgrounds
|
|
1451 (while (not (eobp))
|
|
1452 (re-search-forward "$" nil t)
|
|
1453 (if (>= fill-column (current-column))
|
|
1454 (insert-char ? (- fill-column (current-column)) t))
|
|
1455 (or (eobp) (forward-char 1)))
|
14
|
1456 (aset formatted-cols i (extract-rectangle (point-min) (point-max)))
|
|
1457 (delete-region (point-min) (point-max))
|
|
1458 (let ((j (1- colspan)))
|
|
1459 (while (> j 0)
|
|
1460 (aset table-colspans (+ i j) 0)
|
|
1461 (setq j (1- j))))
|
|
1462 (setq i (+ i colspan))
|
|
1463 ;; skip over columns that have leftover content
|
|
1464 (while (and (< i num-cols)
|
|
1465 (/= 0 (aref table-rowspans i)))
|
|
1466 (setq i (+ i (max 1 (aref table-colspans i)))))
|
|
1467 ))
|
118
|
1468 (pop w3-display-open-element-stack)
|
|
1469 (pop w3-active-faces)
|
|
1470 (pop w3-active-voices)
|
|
1471 (w3-pop-all-face-info)
|
14
|
1472 ;; finish off the columns
|
|
1473 (while (< i num-cols)
|
|
1474 (aset table-colwidth i (aref column-dimensions i))
|
|
1475 (aset table-colspans i 1)
|
|
1476 (setq i (1+ i))
|
|
1477 (while (and (< i num-cols)
|
|
1478 (/= 0 (aref table-rowspans i)))
|
|
1479 (setq i (+ i (max 1 (aref table-colspans i))))))
|
|
1480
|
|
1481 ;; on the last row empty any pending rowspans per the rfc
|
|
1482 (if content nil
|
|
1483 (fillarray table-rowspans 1))
|
|
1484
|
|
1485 ;; Find the tallest rectangle that isn't a rowspanning cell
|
|
1486 (setq height 0
|
|
1487 i 0)
|
|
1488 (while (< i num-cols)
|
|
1489 (if (= 1 (aref table-rowspans i))
|
|
1490 (setq height (max height (length (aref formatted-cols i)))))
|
|
1491 (setq i (+ i (max 1 (aref table-colspans i)))))
|
|
1492
|
|
1493 ;; Make all rectangles the same height
|
|
1494 (setq i 0)
|
|
1495 (while (< i num-cols)
|
|
1496 (setq this-rectangle (aref formatted-cols i))
|
|
1497 (if (> height (length this-rectangle))
|
|
1498 (let ((colspan-fill-line
|
98
|
1499 (make-string (abs (aref table-colwidth i)) ? )))
|
14
|
1500 (case valign
|
|
1501 ((center middle)
|
|
1502 (aset formatted-cols i
|
|
1503 (append (make-list (/ (- height (length this-rectangle)) 2)
|
|
1504 colspan-fill-line)
|
|
1505 this-rectangle)))
|
|
1506 (bottom
|
|
1507 (aset formatted-cols i
|
|
1508 (append (make-list (- height (length this-rectangle))
|
|
1509 colspan-fill-line)
|
|
1510 this-rectangle))))))
|
|
1511 (setq i (+ i (max 1 (aref table-colspans i)))))))
|
|
1512
|
|
1513
|
|
1514 ;; fix broken colspans (this should only matter on illegal tables)
|
|
1515 (setq i 0)
|
|
1516 (while (< i num-cols)
|
|
1517 (if (= (aref table-colspans i) 0)
|
|
1518 (aset table-colspans i 1))
|
|
1519 (setq i (+ i (aref table-colspans i))))
|
|
1520
|
|
1521 ;; Insert a separator
|
|
1522 (insert fill-prefix)
|
|
1523 (setq i 0)
|
|
1524 (let (rflag bflag tflag lflag)
|
|
1525 (while (< i num-cols)
|
|
1526
|
|
1527 (setq rflag (= (aref prev-rowspans i) 0))
|
|
1528 (setq bflag (/= (aref table-colspans i) 0))
|
|
1529 (setq tflag (/= (aref prev-colspans i) 0))
|
|
1530
|
116
|
1531 (w3-insert-terminal-char (w3-table-lookup-char lflag tflag rflag bflag))
|
14
|
1532 (setq lflag t)
|
|
1533 (cond ((= (aref prev-rowspans i) 0)
|
116
|
1534 (w3-insert-terminal-char
|
|
1535 (w3-table-lookup-char t nil t nil)
|
|
1536 (aref column-dimensions i))
|
14
|
1537 (setq i (1+ i)))
|
|
1538 ((car (aref formatted-cols i))
|
|
1539 (insert (pop (aref formatted-cols i)))
|
|
1540 (setq lflag nil)
|
|
1541 (setq i (+ i (max (aref table-colspans i)
|
|
1542 (aref prev-colspans i) 1))))
|
|
1543 (t
|
118
|
1544 (insert-char ? (aref table-colwidth i) t)
|
14
|
1545 (setq lflag nil)
|
|
1546 (setq i (+ i (max (aref table-colspans i)
|
|
1547 (aref prev-colspans i) 1))))))
|
116
|
1548 (w3-insert-terminal-char (w3-table-lookup-char lflag (/= row 1) nil t))
|
|
1549 (insert "\n"))
|
|
1550
|
14
|
1551 ;; recalculate height (in case we've shortened a rowspanning cell
|
|
1552 (setq height 0
|
|
1553 i 0)
|
|
1554 (while (< i num-cols)
|
|
1555 (if (= 1 (aref table-rowspans i))
|
|
1556 (setq height (max height (length (aref formatted-cols i)))))
|
|
1557 (setq i (+ i (max 1 (aref table-colspans i)))))
|
|
1558
|
|
1559 ;; Insert a row back in original buffer
|
|
1560 (while (> height 0)
|
116
|
1561 (insert fill-prefix)
|
|
1562 (w3-insert-terminal-char (w3-table-lookup-char nil t nil t))
|
14
|
1563 (setq i 0)
|
|
1564 (while (< i num-cols)
|
|
1565 (if (car (aref formatted-cols i))
|
|
1566 (insert (pop (aref formatted-cols i)))
|
118
|
1567 (insert-char ? (aref table-colwidth i) t))
|
116
|
1568 (w3-insert-terminal-char (w3-table-lookup-char nil t nil t))
|
14
|
1569 (setq i (+ i (max (aref table-colspans i) 1))))
|
|
1570 (insert "\n")
|
|
1571 ;;(and w3-do-incremental-display (w3-pause))
|
|
1572 (setq height (1- height)))
|
|
1573
|
|
1574 (setq i 0)
|
|
1575 (while (< i num-cols)
|
|
1576 (if (> (aref table-rowspans i) 0)
|
|
1577 (decf (aref table-rowspans i)))
|
|
1578 (incf i))
|
|
1579
|
|
1580 (setq prev-rowspans (copy-seq table-rowspans))
|
|
1581 (setq prev-colspans (copy-seq table-colspans))
|
|
1582
|
|
1583 (and w3-do-incremental-display (w3-pause))
|
|
1584 )
|
|
1585 (caption
|
|
1586 (let ((left (length fill-prefix))
|
|
1587 (fill-prefix "")
|
|
1588 (fill-column table-width)
|
|
1589 (start (point)))
|
|
1590 (w3-display-node (pop content))
|
|
1591 (indent-rigidly start (point) left)))
|
|
1592 (otherwise
|
|
1593 (delete-horizontal-space)
|
|
1594 (setq content (nth 2 (car content))))
|
|
1595 ))
|
|
1596 (if (= (length column-dimensions) 0) nil
|
|
1597 (insert fill-prefix)
|
|
1598 (setq i 0)
|
|
1599 (let (tflag lflag)
|
|
1600 (while (< i num-cols)
|
|
1601 (setq tflag (/= (aref prev-colspans i) 0))
|
116
|
1602 (w3-insert-terminal-char (w3-table-lookup-char lflag tflag t nil))
|
14
|
1603 (setq lflag t)
|
116
|
1604 (w3-insert-terminal-char
|
|
1605 (w3-table-lookup-char t nil t nil)
|
|
1606 (aref column-dimensions i))
|
14
|
1607 (setq i (1+ i)))
|
116
|
1608 (w3-insert-terminal-char
|
|
1609 (w3-table-lookup-char t t nil nil))
|
|
1610 (insert "\n")))
|
14
|
1611 )
|
|
1612 (pop w3-display-open-element-stack)))))
|
|
1613
|
|
1614
|
|
1615
|
|
1616 (defun w3-display-create-unique-id ()
|
|
1617 (let* ((date (current-time-string))
|
|
1618 (dateinfo (and date (timezone-parse-date date)))
|
|
1619 (timeinfo (and date (timezone-parse-time (aref dateinfo 3)))))
|
|
1620 (if (and dateinfo timeinfo)
|
|
1621 (concat (aref dateinfo 0) ; Year
|
|
1622 (aref dateinfo 1) ; Month
|
|
1623 (aref dateinfo 2) ; Day
|
|
1624 (aref timeinfo 0) ; Hour
|
|
1625 (aref timeinfo 1) ; Minute
|
|
1626 (aref timeinfo 2) ; Second
|
|
1627 )
|
|
1628 "HoplesSLYCoNfUSED")))
|
|
1629
|
82
|
1630 (defun w3-display-chop-into-table (node cols)
|
|
1631 ;; Chop the content of 'node' up into 'cols' columns suitable for inclusion
|
|
1632 ;; as the content of a table
|
|
1633 (let ((content (nth 2 node))
|
|
1634 (items nil)
|
|
1635 (rows nil))
|
|
1636 (setq cols (max cols 1))
|
|
1637 (while content
|
|
1638 (push (list 'td nil (list (pop content))) items)
|
|
1639 (if (= (length items) cols)
|
|
1640 (setq rows (cons (nreverse items) rows)
|
|
1641 items nil)))
|
|
1642 (if items ; Store any leftovers
|
|
1643 (setq rows (cons (nreverse items) rows)
|
|
1644 items nil))
|
|
1645 (while rows
|
|
1646 (push (list 'tr nil (pop rows)) items))
|
|
1647 items))
|
|
1648
|
118
|
1649 (defun w3-fix-color (color)
|
|
1650 (if (and color
|
|
1651 (string-match "^[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$" color))
|
|
1652 (concat "#" color)
|
|
1653 color))
|
|
1654
|
86
|
1655 (defun w3-display-normalize-form-info (args)
|
|
1656 (let* ((plist (alist-to-plist args))
|
|
1657 (type (intern (downcase
|
|
1658 (or (plist-get plist 'type) "text"))))
|
|
1659 (name (plist-get plist 'name))
|
|
1660 (value (or (plist-get plist 'value) ""))
|
|
1661 (size (if (plist-get plist 'size)
|
|
1662 (string-to-int (plist-get plist 'size))))
|
|
1663 (maxlength (if (plist-get plist 'maxlength)
|
|
1664 (string-to-int
|
|
1665 (plist-get plist 'maxlength))))
|
|
1666 (default value)
|
|
1667 (checked (assq 'checked args)))
|
|
1668 (if (memq type '(checkbox radio)) (setq default checked))
|
|
1669 (if (and (eq type 'checkbox) (string= value ""))
|
|
1670 (setq value "on"))
|
|
1671 (if (and (not (memq type '(submit reset button)))
|
|
1672 (not name))
|
|
1673 (setq name (symbol-name type)))
|
|
1674 (while (and name (string-match "[\r\n]+" name))
|
|
1675 (setq name (concat (substring name 0 (match-beginning 0))
|
|
1676 (substring name (match-end 0) nil))))
|
|
1677 (setq plist (plist-put plist 'type type)
|
|
1678 plist (plist-put plist 'name name)
|
|
1679 plist (plist-put plist 'value value)
|
|
1680 plist (plist-put plist 'size size)
|
|
1681 plist (plist-put plist 'default default)
|
|
1682 plist (plist-put plist 'internal-form-number w3-current-form-number)
|
|
1683 plist (plist-put plist 'action w3-display-form-id)
|
|
1684 plist (plist-put plist 'maxlength maxlength))
|
|
1685 plist))
|
|
1686
|
165
|
1687 (defun w3-resurrect-hyperlinks ()
|
|
1688 (let ((st (point-min))
|
|
1689 (inhibit-read-only t)
|
|
1690 info nd node face)
|
|
1691 (while st
|
|
1692 (if (setq info (get-text-property st 'w3-hyperlink-info))
|
|
1693 (progn
|
|
1694 (setq nd (or (next-single-property-change st 'w3-hyperlink-info)
|
|
1695 (point-max)))
|
|
1696 (apply 'widget-convert-text 'link st nd st nd info)))
|
|
1697 (setq st (next-single-property-change st 'w3-hyperlink-info)))))
|
|
1698
|
|
1699 (defun w3-display-convert-arglist (args)
|
|
1700 (let ((rval nil)
|
|
1701 (newsym nil)
|
|
1702 (cur nil))
|
|
1703 (while (setq cur (pop args))
|
|
1704 (setq newsym (intern (concat ":" (symbol-name (car cur))))
|
|
1705 rval (plist-put rval newsym (cdr cur))))
|
|
1706 rval))
|
|
1707
|
14
|
1708 (defun w3-display-node (node &optional nofaces)
|
|
1709 (let (
|
|
1710 (content-stack (list (list node)))
|
|
1711 (right-margin-stack (list fill-column))
|
|
1712 (left-margin-stack (list 0))
|
100
|
1713 (inhibit-read-only t)
|
102
|
1714 (widget-push-button-gui nil)
|
14
|
1715 node
|
|
1716 insert-before
|
|
1717 insert-after
|
|
1718 tag
|
|
1719 args
|
|
1720 content
|
|
1721 hyperlink-info
|
|
1722 break-style
|
|
1723 cur
|
|
1724 id
|
|
1725 class
|
108
|
1726 last-element
|
14
|
1727 )
|
|
1728 (while content-stack
|
|
1729 (setq content (pop content-stack))
|
|
1730 (pop w3-active-faces)
|
|
1731 (pop w3-active-voices)
|
100
|
1732 (w3-display-progress-meter)
|
108
|
1733 (setq last-element (pop w3-display-open-element-stack))
|
|
1734 (case (car last-element)
|
14
|
1735 ;; Any weird, post-display-of-content stuff for specific tags
|
|
1736 ;; goes here. Couldn't think of any better way to do this when we
|
|
1737 ;; are iterative. *sigh*
|
|
1738 (a
|
|
1739 (if (not hyperlink-info)
|
|
1740 nil
|
|
1741 (add-text-properties (car hyperlink-info) (point)
|
|
1742 (list
|
|
1743 'duplicable t
|
82
|
1744 'start-open t
|
|
1745 'end-open t
|
|
1746 'rear-nonsticky t
|
165
|
1747 'w3-hyperlink-info (cadr hyperlink-info))))
|
14
|
1748 (setq hyperlink-info nil))
|
|
1749 ((ol ul dl dir menu)
|
|
1750 (pop w3-display-list-stack))
|
108
|
1751 (label
|
|
1752 (if (and (markerp w3-display-label-marker)
|
|
1753 (marker-position w3-display-label-marker)
|
|
1754 (marker-buffer w3-display-label-marker))
|
|
1755 (push (cons (or (cdr-safe (assq 'for (cdr last-element)))
|
|
1756 (cdr-safe (assq 'id (cdr last-element)))
|
|
1757 "unknown")
|
|
1758 (buffer-substring w3-display-label-marker (point)))
|
|
1759 w3-form-labels)))
|
14
|
1760 (otherwise
|
|
1761 nil))
|
|
1762 (if (car insert-after)
|
|
1763 (w3-handle-string-content (car insert-after)))
|
|
1764 (pop insert-after)
|
|
1765 (w3-display-handle-end-break)
|
|
1766 (w3-pop-all-face-info)
|
|
1767 ;; Handle the element's content
|
|
1768 (while content
|
100
|
1769 (w3-display-progress-meter)
|
14
|
1770 (if (stringp (car content))
|
|
1771 (w3-handle-string-content (pop content))
|
|
1772 (setq node (pop content)
|
|
1773 tag (nth 0 node)
|
|
1774 args (nth 1 node)
|
|
1775 id (or (w3-get-attribute 'name)
|
|
1776 (w3-get-attribute 'id))
|
|
1777 )
|
|
1778 ;; This little bit of magic takes care of inline styles.
|
|
1779 ;; Evil Evil Evil, but it appears to work.
|
|
1780 (if (w3-get-attribute 'style)
|
|
1781 (let ((unique-id (or (w3-get-attribute 'id)
|
|
1782 (w3-display-create-unique-id)))
|
82
|
1783 (sheet "")
|
|
1784 (class (assq 'class args)))
|
14
|
1785 (setq sheet (format "%s.%s { %s }\n" tag unique-id
|
|
1786 (w3-get-attribute 'style)))
|
82
|
1787 (if class
|
|
1788 (setcdr class (cons unique-id (cdr class)))
|
|
1789 (setf (nth 1 node) (cons (cons 'class (list unique-id))
|
|
1790 (nth 1 node))))
|
|
1791 (setf (nth 1 node) (cons (cons 'id unique-id) (nth 1 node)))
|
|
1792 (w3-handle-style (list 'data sheet
|
118
|
1793 'notation "text/css"))))
|
14
|
1794 (setq w3-display-css-properties (css-get
|
82
|
1795 (nth 0 node)
|
|
1796 (nth 1 node)
|
14
|
1797 w3-current-stylesheet
|
|
1798 w3-display-open-element-stack))
|
|
1799 (push (w3-get-style-info 'display node) break-style)
|
|
1800 (push (w3-get-style-info 'insert-after node) insert-after)
|
|
1801 (setq insert-before (w3-get-style-info 'insert-before node))
|
|
1802 (w3-display-handle-break)
|
|
1803 (if (w3-node-visible-p)
|
|
1804 nil
|
|
1805 (setq insert-before nil
|
|
1806 tag '*invisible)
|
|
1807 (setcar insert-after nil))
|
|
1808 (if insert-before
|
|
1809 (w3-handle-string-content insert-before))
|
165
|
1810 (if nofaces
|
|
1811 nil
|
|
1812 (push (w3-face-for-element node) w3-active-faces)
|
|
1813 (push (w3-voice-for-element node) w3-active-voices))
|
14
|
1814 (setq insert-before nil)
|
|
1815 (if id
|
|
1816 (setq w3-id-positions (cons
|
|
1817 (cons (intern id)
|
|
1818 (set-marker (make-marker)
|
|
1819 (point-max)))
|
|
1820 w3-id-positions)))
|
|
1821 (case tag
|
|
1822 (a ; Hyperlinks
|
|
1823 (let* (
|
|
1824 (title (w3-get-attribute 'title))
|
|
1825 (name (or (w3-get-attribute 'id)
|
|
1826 (w3-get-attribute 'name)))
|
|
1827 (btdt nil)
|
|
1828 class
|
|
1829 (before nil)
|
|
1830 (after nil)
|
|
1831 (face nil)
|
|
1832 (voice nil)
|
165
|
1833 (st nil)
|
|
1834 (old-props w3-display-css-properties)
|
|
1835 (active-face nil)
|
|
1836 (munged (copy-list args)))
|
|
1837 (if (assq 'class munged)
|
|
1838 (push ":active" (cdr (assq 'class munged)))
|
|
1839 (setq munged (cons (cons 'class '(":active")) munged)))
|
|
1840 (setq w3-display-css-properties (css-get
|
|
1841 tag
|
|
1842 munged
|
|
1843 w3-current-stylesheet
|
|
1844 w3-display-open-element-stack))
|
|
1845 (setq active-face (w3-face-for-element (list tag munged nil)))
|
|
1846 (w3-pop-all-face-info)
|
|
1847 (setq w3-display-css-properties old-props)
|
108
|
1848 (if (w3-get-attribute 'href)
|
|
1849 (setq st (point)
|
|
1850 hyperlink-info (list
|
|
1851 st
|
165
|
1852 (append
|
|
1853 (list :args nil
|
108
|
1854 :value "" :tag ""
|
|
1855 :action 'w3-follow-hyperlink
|
165
|
1856 :button-face '(nil)
|
|
1857 :active-face active-face
|
108
|
1858 :from (set-marker
|
|
1859 (make-marker) st)
|
|
1860 :help-echo 'w3-widget-echo
|
|
1861 :emacspeak-help 'w3-widget-echo
|
|
1862 )
|
165
|
1863 (w3-display-convert-arglist args)))))
|
14
|
1864 (w3-handle-content node)
|
|
1865 )
|
|
1866 )
|
82
|
1867 ((ol ul dl menu)
|
108
|
1868 (push (if (w3-get-attribute 'seqnum)
|
|
1869 (1- (string-to-int (w3-get-attribute 'seqnum)))
|
|
1870 0) w3-display-list-stack)
|
82
|
1871 (w3-handle-content node))
|
|
1872 (dir
|
14
|
1873 (push 0 w3-display-list-stack)
|
82
|
1874 (setq node
|
|
1875 (list tag args
|
|
1876 (list
|
|
1877 (list 'table nil
|
|
1878 (w3-display-chop-into-table node 3)))))
|
|
1879 (w3-handle-content node))
|
|
1880 (multicol
|
|
1881 (setq node (list tag args
|
|
1882 (list
|
|
1883 (list 'table nil
|
|
1884 (w3-display-chop-into-table node 2)))))
|
14
|
1885 (w3-handle-content node))
|
|
1886 (img ; inlined image
|
|
1887 (w3-handle-image)
|
|
1888 (w3-handle-empty-tag))
|
100
|
1889 (frameset
|
|
1890 (if w3-display-frames
|
102
|
1891 (progn
|
114
|
1892 (push (list 'frameset
|
|
1893 (or (assq 'cols args) (assq 'rows args)))
|
|
1894 w3-frameset-structure)
|
102
|
1895 (w3-handle-content node))
|
110
|
1896 (w3-handle-content node)))
|
100
|
1897 (frame
|
102
|
1898 (if w3-display-frames
|
|
1899 (let* ((href (or (w3-get-attribute 'src)
|
|
1900 (w3-get-attribute 'href)))
|
|
1901 (name (or (w3-get-attribute 'name)
|
|
1902 (w3-get-attribute 'title)
|
|
1903 (w3-get-attribute 'alt)
|
|
1904 "Unknown frame name")))
|
114
|
1905 (push (list 'frame name href) w3-frameset-structure)
|
102
|
1906 (w3-handle-content
|
|
1907 (list tag args
|
|
1908 (list
|
|
1909 (list 'p nil
|
|
1910 (list
|
|
1911 (list 'a
|
|
1912 (cons (cons 'href href)
|
|
1913 args)
|
114
|
1914 (list "Fetch frame: " name))))))))
|
110
|
1915 (w3-handle-empty-tag)))
|
100
|
1916 (noframes
|
|
1917 (if w3-display-frames
|
|
1918 (w3-handle-empty-tag)
|
|
1919 (w3-handle-content node)))
|
108
|
1920 (applet ; Wow, Java
|
|
1921 (w3-handle-content node)
|
|
1922 )
|
14
|
1923 (script ; Scripts
|
|
1924 (w3-handle-empty-tag))
|
|
1925 ((embed object) ; Embedded images/content
|
|
1926 (w3-handle-content node)
|
|
1927 )
|
|
1928 (hr ; Cause line break & insert rule
|
|
1929 (let* ((perc (or (w3-get-attribute 'width)
|
|
1930 (w3-get-style-info 'width node)
|
|
1931 "100%"))
|
|
1932 (width nil))
|
165
|
1933 (if (stringp perc)
|
|
1934 (setq perc (/ (min (string-to-int perc) 100) 100.0)
|
|
1935 width (truncate (* fill-column perc)))
|
|
1936 (setq width perc))
|
116
|
1937 (w3-insert-terminal-char (w3-horizontal-rule-char) width)
|
|
1938 (w3-handle-empty-tag)))
|
14
|
1939 (map ; Client side imagemaps
|
|
1940 (let ((name (or (w3-get-attribute 'name)
|
|
1941 (w3-get-attribute 'id)
|
|
1942 "unnamed"))
|
|
1943 (areas
|
|
1944 (mapcar
|
|
1945 (function
|
|
1946 (lambda (node)
|
|
1947 (let* ((args (nth 1 node))
|
|
1948 (type (downcase (or
|
|
1949 (w3-get-attribute 'shape)
|
|
1950 "rect")))
|
|
1951 (coords (w3-decode-area-coords
|
|
1952 (or (cdr-safe
|
|
1953 (assq 'coords args)) "")))
|
|
1954 (alt (w3-get-attribute 'alt))
|
|
1955 (href (if (assq 'nohref args)
|
|
1956 t
|
|
1957 (or (w3-get-attribute 'src)
|
|
1958 (w3-get-attribute 'href))))
|
|
1959 )
|
|
1960 (vector type coords href alt))
|
|
1961 )
|
|
1962 )
|
|
1963 (nth 2 node))))
|
|
1964 (setq w3-imagemaps (cons (cons name areas) w3-imagemaps)))
|
|
1965 (w3-handle-empty-tag)
|
|
1966 )
|
82
|
1967 (note
|
|
1968 ;; Ewwwwhhh. Looks gross, but it works. This converts a
|
|
1969 ;; <note> into a two-cell table, so that things look all
|
|
1970 ;; pretty.
|
|
1971 (setq node
|
|
1972 (list 'note nil
|
|
1973 (list
|
|
1974 (list 'table nil
|
|
1975 (list
|
|
1976 (list 'tr nil
|
|
1977 (list
|
|
1978 (list 'td (list 'align 'right)
|
|
1979 (list
|
|
1980 (concat
|
|
1981 (or (w3-get-attribute 'role)
|
|
1982 "CAUTION") ":")))
|
|
1983 (list 'td nil
|
|
1984 (nth 2 node)))))))))
|
|
1985 (w3-handle-content node)
|
|
1986 )
|
|
1987 (table
|
14
|
1988 (w3-display-table node)
|
|
1989 (setq w3-last-fill-pos (point))
|
|
1990 (w3-handle-empty-tag)
|
|
1991 )
|
|
1992 (isindex
|
|
1993 (let ((prompt (or (w3-get-attribute 'prompt)
|
|
1994 "Search on (+ separates keywords): "))
|
|
1995 action node)
|
|
1996 (setq action (or (w3-get-attribute 'src)
|
|
1997 (w3-get-attribute 'href)
|
|
1998 (url-view-url t)))
|
|
1999 (if (and prompt (string-match "[^: \t-]+$" prompt))
|
|
2000 (setq prompt (concat prompt ": ")))
|
|
2001 (setq node
|
|
2002 (list 'isindex nil
|
|
2003 (list
|
|
2004 (list 'hr nil nil)
|
|
2005 (list 'form
|
|
2006 (list (cons 'action action)
|
|
2007 (cons 'enctype
|
|
2008 "application/x-w3-isindex")
|
|
2009 (cons 'method "get"))
|
|
2010 (list
|
|
2011 prompt
|
|
2012 (list 'input
|
|
2013 (list (cons 'type "text")
|
|
2014 (cons 'name "isindex"))))))))
|
|
2015 (w3-handle-content node)
|
|
2016 (setq w3-current-isindex (cons action prompt)))
|
|
2017 )
|
116
|
2018 ((html body)
|
|
2019 (let ((fore (car (delq nil (copy-list w3-face-color))))
|
|
2020 (back (car (delq nil (copy-list w3-face-background-color))))
|
165
|
2021 (pixm (car (delq nil (copy-list w3-face-background-image))))
|
118
|
2022 (alink (w3-get-attribute 'alink))
|
|
2023 (vlink (w3-get-attribute 'vlink))
|
|
2024 (link (w3-get-attribute 'link))
|
|
2025 (sheet "")
|
116
|
2026 )
|
118
|
2027 (if link
|
|
2028 (setq sheet (format "%sa:link { color: %s }\n" sheet
|
|
2029 (w3-fix-color link))))
|
|
2030 (if vlink
|
|
2031 (setq sheet (format "%sa:visited { color: %s }\n" sheet
|
|
2032 (w3-fix-color vlink))))
|
|
2033 (if alink
|
|
2034 (setq sheet (format "%sa:active { color: %s }\n" sheet
|
|
2035 (w3-fix-color alink))))
|
165
|
2036 (if w3-user-colors-take-precedence
|
|
2037 nil
|
|
2038 (if (/= (length sheet) 0)
|
|
2039 (w3-handle-style (list 'data sheet
|
|
2040 'notation "text/css")))
|
|
2041 (if (and (w3-get-attribute 'background)
|
|
2042 (not pixm))
|
|
2043 (progn
|
|
2044 (setq pixm (w3-get-attribute 'background))
|
|
2045 (setf (car w3-face-background-image) pixm)))
|
|
2046 (if (and (w3-get-attribute 'text) (not fore))
|
|
2047 (progn
|
|
2048 (setq fore (w3-fix-color (w3-get-attribute 'text)))
|
|
2049 (setf (car w3-face-color) fore)))
|
|
2050 (if (not font-running-xemacs)
|
|
2051 (setq w3-display-background-properties (cons fore back))
|
|
2052 (if pixm
|
|
2053 (w3-maybe-start-background-image-download pixm 'default))
|
|
2054 (if fore
|
|
2055 (font-set-face-foreground 'default fore (current-buffer)))
|
|
2056 (if back
|
|
2057 (font-set-face-background 'default back (current-buffer)))))
|
116
|
2058 (w3-handle-content node)))
|
14
|
2059 (*document
|
|
2060 (let ((info (mapcar (lambda (x) (cons x (symbol-value x)))
|
|
2061 w3-persistent-variables)))
|
82
|
2062 (if (not w3-display-same-buffer)
|
|
2063 (set-buffer (generate-new-buffer "Untitled")))
|
14
|
2064 (setq w3-current-form-number 0
|
|
2065 w3-display-open-element-stack nil
|
102
|
2066 w3-last-fill-pos (point-min))
|
|
2067 (setcar right-margin-stack
|
|
2068 (min (- (or w3-strict-width (window-width))
|
|
2069 w3-right-margin)
|
|
2070 (or w3-maximum-line-length
|
|
2071 (window-width))))
|
116
|
2072 (condition-case nil
|
|
2073 (switch-to-buffer (current-buffer))
|
|
2074 (error (message "W3 buffer %s is being drawn." (buffer-name (current-buffer)))))
|
|
2075
|
14
|
2076 (buffer-disable-undo (current-buffer))
|
|
2077 (mapcar (function (lambda (x) (set (car x) (cdr x)))) info)
|
|
2078 ;; ACK! We don't like filladapt mode!
|
|
2079 (set (make-local-variable 'filladapt-mode) nil)
|
|
2080 (set (make-local-variable 'adaptive-fill-mode) nil)
|
82
|
2081 (set (make-local-variable 'voice-lock-mode) t)
|
165
|
2082 (set (make-local-variable 'cur-viewing-pos) (point-min))
|
14
|
2083 (setq w3-current-stylesheet (css-copy-stylesheet
|
|
2084 w3-user-stylesheet)
|
|
2085 w3-last-fill-pos (point)
|
|
2086 fill-prefix "")
|
118
|
2087 )
|
14
|
2088 (w3-handle-content node)
|
|
2089 )
|
|
2090 (*invisible
|
|
2091 (w3-handle-empty-tag))
|
|
2092 (meta
|
|
2093 (let* ((equiv (cdr-safe (assq 'http-equiv args)))
|
|
2094 (value (w3-get-attribute 'content))
|
|
2095 (name (w3-get-attribute 'name))
|
|
2096 (node (and equiv (assoc (setq equiv (downcase equiv))
|
|
2097 url-current-mime-headers))))
|
|
2098 (if equiv
|
|
2099 (setq url-current-mime-headers (cons
|
|
2100 (cons equiv value)
|
|
2101 url-current-mime-headers)))
|
|
2102 (if name
|
|
2103 (setq w3-current-metainfo (cons
|
|
2104 (cons name value)
|
|
2105 w3-current-metainfo)))
|
|
2106
|
|
2107 ;; Special-case the Set-Cookie header
|
|
2108 (if (and equiv (string= (downcase equiv) "set-cookie"))
|
|
2109 (url-cookie-handle-set-cookie value))
|
|
2110 ;; Special-case the refresh header
|
|
2111 (if (and equiv (string= (downcase equiv) "refresh"))
|
|
2112 (url-handle-refresh-header value)))
|
|
2113 (w3-handle-empty-tag)
|
|
2114 )
|
|
2115 (link
|
|
2116 ;; This doesn't handle blank-separated values per the RFC.
|
|
2117 (w3-parse-link args)
|
|
2118 (w3-handle-empty-tag))
|
|
2119 (title
|
|
2120 (let ((potential-title "")
|
|
2121 (content (nth 2 node)))
|
|
2122 (while content
|
|
2123 (setq potential-title (concat potential-title (car content))
|
|
2124 content (cdr content)))
|
|
2125 (setq potential-title (w3-normalize-spaces potential-title))
|
82
|
2126 (if (or w3-display-same-buffer
|
|
2127 (string-match "^[ \t]*$" potential-title))
|
14
|
2128 nil
|
|
2129 (rename-buffer (generate-new-buffer-name
|
|
2130 (w3-fix-spaces potential-title)))))
|
|
2131 (w3-handle-empty-tag))
|
102
|
2132 (base
|
|
2133 (setq w3-base-target (cdr-safe (assq 'target args)))
|
|
2134 (w3-handle-content node))
|
14
|
2135 (form
|
|
2136 (setq w3-current-form-number (1+ w3-current-form-number))
|
|
2137 (let* (
|
|
2138 (action (w3-get-attribute 'action))
|
|
2139 (url nil))
|
|
2140 (if (not action)
|
|
2141 (setq args (cons (cons 'action (url-view-url t)) args)))
|
82
|
2142 (setq w3-display-form-id (cons
|
|
2143 (cons 'form-number
|
|
2144 w3-current-form-number)
|
|
2145 args))
|
14
|
2146 (w3-handle-content node)))
|
116
|
2147 (keygen
|
|
2148 (w3-form-add-element
|
|
2149 (w3-display-normalize-form-info
|
|
2150 (cons '(type . "keygen")
|
|
2151 args))
|
|
2152 w3-active-faces)
|
|
2153 (w3-handle-empty-tag))
|
14
|
2154 (input
|
86
|
2155 (w3-form-add-element
|
|
2156 (w3-display-normalize-form-info args)
|
98
|
2157 w3-active-faces)
|
14
|
2158 (w3-handle-empty-tag)
|
|
2159 )
|
|
2160 (select
|
86
|
2161 (let* ((plist (w3-display-normalize-form-info args))
|
82
|
2162 (tmp nil)
|
|
2163 (multiple (assq 'multiple args))
|
86
|
2164 (value nil)
|
|
2165 (name (plist-get plist 'name))
|
|
2166 (options (mapcar
|
|
2167 (function
|
|
2168 (lambda (n)
|
|
2169 (setq tmp (w3-normalize-spaces
|
|
2170 (apply 'concat (nth 2 n)))
|
114
|
2171 tmp (vector tmp
|
|
2172 (or
|
|
2173 (cdr-safe
|
|
2174 (assq 'value (nth 1 n)))
|
|
2175 tmp)
|
|
2176 (assq 'selected (nth 1 n))))
|
86
|
2177 (if (assq 'selected (nth 1 n))
|
114
|
2178 (setq value (aref tmp 0)))
|
86
|
2179 tmp))
|
|
2180 (nth 2 node))))
|
82
|
2181 (if (not value)
|
165
|
2182 (setq value (and options (aref (car options) 0))))
|
86
|
2183 (setq plist (plist-put plist 'value value))
|
82
|
2184 (if multiple
|
|
2185 (progn
|
|
2186 (setq options
|
|
2187 (mapcar
|
|
2188 (function
|
|
2189 (lambda (opt)
|
|
2190 (list 'div nil
|
|
2191 (list
|
|
2192 (list 'input
|
|
2193 (list (cons 'name name)
|
|
2194 (cons 'type "checkbox")
|
114
|
2195 (cons (if (aref opt 2)
|
|
2196 'checked
|
|
2197 '__bogus__) "yes")
|
|
2198 (cons 'value (aref opt 1))))
|
|
2199 " " (aref opt 0) (list 'br nil nil)))))
|
82
|
2200 options))
|
|
2201 (setq node (list 'p nil options))
|
|
2202 (w3-handle-content node))
|
114
|
2203 (setq options (mapcar (function
|
|
2204 (lambda (x)
|
|
2205 (cons (aref x 0) (aref x 1))))
|
|
2206 options))
|
86
|
2207 (setq plist (plist-put plist 'type 'option)
|
|
2208 plist (plist-put plist 'options options))
|
98
|
2209 (w3-form-add-element plist w3-active-faces)
|
14
|
2210 ;; This should really not be necessary, but some versions
|
|
2211 ;; of the widget library leave point _BEFORE_ the menu
|
|
2212 ;; widget instead of after.
|
|
2213 (goto-char (point-max))
|
82
|
2214 (w3-handle-empty-tag))))
|
14
|
2215 (textarea
|
86
|
2216 (let* ((plist (w3-display-normalize-form-info args))
|
116
|
2217 (value (apply 'concat (nth 2 node))))
|
86
|
2218 (setq plist (plist-put plist 'type 'multiline)
|
|
2219 plist (plist-put plist 'value value))
|
98
|
2220 (w3-form-add-element plist w3-active-faces))
|
14
|
2221 (w3-handle-empty-tag)
|
|
2222 )
|
|
2223 (style
|
82
|
2224 (w3-handle-style (alist-to-plist
|
|
2225 (cons (cons 'data (apply 'concat (nth 2 node)))
|
|
2226 (nth 1 node))))
|
14
|
2227 (w3-handle-empty-tag))
|
108
|
2228 (label
|
|
2229 (if (not (markerp w3-display-label-marker))
|
|
2230 (setq w3-display-label-marker (make-marker)))
|
|
2231 (set-marker w3-display-label-marker (point))
|
|
2232 (w3-handle-content node))
|
88
|
2233 ;; Emacs-W3 stuff that cannot be expressed in a stylesheet
|
|
2234 (pinhead
|
|
2235 ;; This check is so that we don't screw up table auto-layout
|
|
2236 ;; by changing our text midway through the parse/layout/display
|
|
2237 ;; steps.
|
|
2238 (if (nth 2 node)
|
|
2239 nil
|
|
2240 (setcar (cddr node)
|
|
2241 (list
|
|
2242 (if (fboundp 'yow)
|
|
2243 (yow)
|
|
2244 "AIEEEEE! I am having an UNDULATING EXPERIENCE!"))))
|
|
2245 (w3-handle-content node))
|
|
2246 (flame
|
|
2247 (if (nth 2 node)
|
|
2248 nil
|
|
2249 (setcar
|
|
2250 (cddr node)
|
|
2251 (list
|
|
2252 (condition-case ()
|
|
2253 (concat
|
|
2254 (sentence-ify
|
|
2255 (string-ify
|
|
2256 (append-suffixes-hack (flatten (*flame))))))
|
|
2257 (error
|
|
2258 "You know, everything is really a graphics editor.")))))
|
|
2259 (w3-handle-content node))
|
|
2260 (cookie
|
|
2261 (if (nth 2 node)
|
|
2262 nil
|
|
2263 (setcar
|
|
2264 (cddr node)
|
|
2265 (list
|
|
2266 (w3-display-get-cookie args))))
|
|
2267 (w3-handle-content node))
|
|
2268 ;; Generic formatting - all things that can be fully specified
|
|
2269 ;; by a CSS stylesheet.
|
14
|
2270 (otherwise
|
|
2271 (w3-handle-content node))
|
|
2272 ) ; case tag
|
|
2273 ) ; stringp content
|
|
2274 ) ; while content
|
|
2275 ) ; while content-stack
|
|
2276 )
|
|
2277 )
|
|
2278
|
|
2279 (defun w3-draw-tree (tree)
|
|
2280 ;; The main entry point - wow complicated
|
|
2281 (setq w3-current-stylesheet w3-user-stylesheet)
|
|
2282 (while tree
|
|
2283 (w3-display-node (car tree))
|
|
2284 (setq tree (cdr tree)))
|
|
2285 (w3-display-fix-widgets)
|
165
|
2286 (w3-resurrect-hyperlinks)
|
14
|
2287 (w3-form-resurrect-widgets))
|
|
2288
|
|
2289 (defun time-display (&optional tree)
|
|
2290 ;; Return the # of seconds it took to draw 'tree'
|
|
2291 (let ((st (nth 1 (current-time)))
|
|
2292 (nd nil))
|
|
2293 (w3-draw-tree (or tree w3-last-parse-tree))
|
|
2294 (setq nd (nth 1 (current-time)))
|
|
2295 (- nd st)))
|
|
2296
|
|
2297
|
98
|
2298 (defun w3-fixup-eol-faces ()
|
|
2299 ;; Remove 'face property at end of lines - underlining screws up stuff
|
116
|
2300 ;; also remove 'mouse-face property at the beginning and end of lines
|
98
|
2301 (let ((inhibit-read-only t))
|
|
2302 (save-excursion
|
|
2303 (goto-char (point-min))
|
118
|
2304 (while (re-search-forward "[ \t]*\n[ \t]*" nil t)
|
116
|
2305 (remove-text-properties (match-beginning 0) (match-end 0)
|
|
2306 '(face nil mouse-face nil) nil)))))
|
98
|
2307
|
82
|
2308 (defsubst w3-finish-drawing ()
|
98
|
2309 (let (url glyph widget)
|
|
2310 (while w3-image-widgets-waiting
|
|
2311 (setq widget (car w3-image-widgets-waiting)
|
|
2312 w3-image-widgets-waiting (cdr w3-image-widgets-waiting)
|
165
|
2313 url (widget-get widget :src)
|
98
|
2314 glyph (cdr-safe (assoc url w3-graphics-list)))
|
|
2315 (condition-case nil
|
|
2316 (widget-value-set widget glyph)
|
|
2317 (error nil))))
|
102
|
2318 (if (and url-current-object (url-target url-current-object))
|
|
2319 (progn
|
|
2320 (push-mark (point) t)
|
|
2321 (w3-find-specific-link (url-target url-current-object)))
|
|
2322 (goto-char (point-min)))
|
98
|
2323 (and (not w3-running-xemacs)
|
|
2324 (not (eq (device-type) 'tty))
|
|
2325 (w3-fixup-eol-faces))
|
110
|
2326 (message "Drawing... done"))
|
82
|
2327
|
|
2328 (defun w3-region (st nd)
|
|
2329 (if (not w3-setup-done) (w3-do-setup))
|
|
2330 (let* ((source (buffer-substring st nd))
|
108
|
2331 (w3-display-same-buffer t)
|
82
|
2332 (parse nil))
|
98
|
2333 (save-window-excursion
|
|
2334 (save-excursion
|
|
2335 (set-buffer (get-buffer-create " *w3-region*"))
|
|
2336 (erase-buffer)
|
|
2337 (insert source)
|
|
2338 (setq parse (w3-parse-buffer (current-buffer))))
|
|
2339 (narrow-to-region st nd)
|
|
2340 (delete-region (point-min) (point-max))
|
|
2341 (w3-draw-tree parse)
|
|
2342 (w3-finish-drawing)
|
|
2343 (widen))))
|
82
|
2344
|
|
2345 (defun w3-refresh-buffer ()
|
|
2346 (interactive)
|
|
2347 (let ((parse w3-current-parse)
|
|
2348 (inhibit-read-only t)
|
|
2349 (w3-display-same-buffer t))
|
|
2350 (if (not parse)
|
|
2351 (error "Could not find the parse tree for this buffer. EEEEK!"))
|
|
2352 (erase-buffer)
|
|
2353 (w3-draw-tree parse)
|
|
2354 (w3-finish-drawing)
|
|
2355 (w3-mode)
|
|
2356 (set-buffer-modified-p nil)))
|
|
2357
|
14
|
2358 (defun w3-prepare-buffer (&rest args)
|
|
2359 ;; The text/html viewer - does all the drawing and displaying of the buffer
|
|
2360 ;; that is necessary to go from raw HTML to a good presentation.
|
|
2361 (let* ((source (buffer-string))
|
|
2362 (source-buf (current-buffer))
|
|
2363 (parse (w3-parse-buffer source-buf)))
|
|
2364 (set-buffer-modified-p nil)
|
|
2365 (w3-draw-tree parse)
|
|
2366 (kill-buffer source-buf)
|
|
2367 (set-buffer-modified-p nil)
|
|
2368 (setq w3-current-source source
|
|
2369 w3-current-parse parse)
|
82
|
2370 (w3-finish-drawing)
|
14
|
2371 (w3-mode)
|
|
2372 (set-buffer-modified-p nil)
|
|
2373 (if url-keep-history
|
|
2374 (let ((url (url-view-url t)))
|
|
2375 (if (not url-history-list)
|
|
2376 (setq url-history-list (make-hash-table :size 131 :test 'equal)))
|
|
2377 (cl-puthash url (buffer-name) url-history-list)
|
|
2378 (if (fboundp 'w3-shuffle-history-menu)
|
|
2379 (w3-shuffle-history-menu)))))
|
114
|
2380 (w3-maybe-fetch-frames))
|
|
2381
|
|
2382 (defun w3-maybe-fetch-frames ()
|
|
2383 (if w3-frameset-structure
|
|
2384 (cond ((or (eq w3-display-frames t)
|
|
2385 (and (eq w3-display-frames 'ask)
|
|
2386 (y-or-n-p "Fetch frames? ")))
|
|
2387 (w3-frames)
|
|
2388 t))))
|
14
|
2389
|
102
|
2390 (defun w3-frames (&optional new-frame)
|
|
2391 "Set up and fetch W3 frames. With optional prefix, do so in a new frame."
|
|
2392 (interactive "P")
|
114
|
2393 (if (not w3-display-frames)
|
|
2394 (let ((w3-display-frames t))
|
|
2395 (w3-refresh-buffer)))
|
102
|
2396 (let* ((old-asynch url-be-asynchronous)
|
114
|
2397 (structure (reverse w3-frameset-structure)))
|
102
|
2398 (if new-frame
|
118
|
2399 (select-frame (make-frame)))
|
102
|
2400 (setq-default url-be-asynchronous nil)
|
|
2401 ;; set up frames
|
114
|
2402 (while structure
|
|
2403 (if (eq (car (car structure)) 'frameset)
|
|
2404 (let* ((current-dims (cdr (car structure)))
|
|
2405 (cols (cdr-safe (assq 'cols current-dims)))
|
|
2406 (rows (cdr-safe (assq 'rows current-dims))))
|
|
2407 (pop structure)
|
|
2408 ;; columns ?
|
|
2409 (if cols
|
|
2410 (setq cols (w3-decode-frameset-dimensions cols (window-width) window-min-width))
|
|
2411 ;; rows ?
|
|
2412 (if rows
|
|
2413 (setq rows (w3-decode-frameset-dimensions rows (window-height) window-min-height))
|
|
2414 ;; default: columns of equal width
|
|
2415 (let ((nb-windows 0)
|
|
2416 (frames structure))
|
|
2417 (while (and frames (eq (car (car frames)) 'frame))
|
|
2418 (setq nb-windows (1+ nb-windows)))
|
|
2419 (let ((fwidth (/ (window-width) nb-windows)))
|
|
2420 (while (> nb-windows 0)
|
|
2421 (push fwidth cols)
|
|
2422 (setq nb-windows (1- nb-windows)))))))
|
|
2423 (while (eq (car (car structure)) 'frame)
|
|
2424 (cond ((cdr cols)
|
|
2425 (split-window-horizontally (car cols))
|
|
2426 (pop cols))
|
|
2427 ((cdr rows)
|
|
2428 (split-window-vertically (car rows))
|
|
2429 (pop rows)))
|
|
2430 (let ((href (nth 2 (car structure)))
|
|
2431 (name (nth 1 (car structure)))
|
|
2432 (url-working-buffer url-default-working-buffer) ; in case url-multiple-p is t
|
|
2433 (w3-notify 'semibully))
|
|
2434 (w3-fetch href)
|
|
2435 (setq w3-frame-name name
|
|
2436 w3-target-window-distances nil))
|
|
2437 (other-window 1)
|
|
2438 (pop structure)))
|
|
2439 (pop structure)))
|
102
|
2440 ;; compute target window distances
|
|
2441 (let ((origin-buffer (current-buffer))
|
|
2442 (stop nil))
|
|
2443 (while (not stop)
|
|
2444 (or w3-target-window-distances
|
|
2445 (setq w3-target-window-distances
|
|
2446 (w3-compute-target-window-distances)))
|
|
2447 (other-window 1)
|
|
2448 (if (eq (current-buffer) origin-buffer)
|
|
2449 (setq stop t))))
|
|
2450 (setq-default url-be-asynchronous old-asynch)))
|
|
2451
|
|
2452 (defun w3-compute-target-window-distances ()
|
|
2453 "Compute an alist of target names and window distances"
|
|
2454 (let ((origin-buffer (current-buffer))
|
|
2455 (distance 0)
|
|
2456 (stop nil)
|
|
2457 (window-distances nil))
|
|
2458 (while (not stop)
|
|
2459 (if w3-frame-name
|
|
2460 (push (cons (intern (downcase w3-frame-name)) distance)
|
|
2461 window-distances))
|
|
2462 (other-window 1)
|
|
2463 (setq distance (1+ distance))
|
|
2464 (if (eq (current-buffer) origin-buffer)
|
|
2465 (setq stop t)))
|
|
2466 window-distances))
|
|
2467
|
114
|
2468 (if (not (fboundp 'frame-char-height))
|
|
2469 (defun frame-char-height (&optional frame)
|
|
2470 "Height in pixels of a line in the font in frame FRAME.
|
|
2471 If FRAME is omitted, the selected frame is used.
|
|
2472 For a terminal frame, the value is always 1."
|
|
2473 (font-height (face-font 'default frame))))
|
|
2474
|
|
2475 (if (not (fboundp 'frame-char-width))
|
|
2476 (defun frame-char-width (&optional frame)
|
|
2477 "Width in pixels of characters in the font in frame FRAME.
|
|
2478 If FRAME is omitted, the selected frame is used.
|
|
2479 For a terminal screen, the value is always 1."
|
|
2480 (font-width (face-font 'default frame))))
|
|
2481
|
|
2482 (defun w3-decode-frameset-dimensions (dims available-dimension min-dim)
|
102
|
2483 "Returns numbers of lines or columns in Emacs, computed from specified frameset dimensions"
|
|
2484 (let ((dimensions nil))
|
|
2485 (if dims
|
|
2486 (let ((nb-stars 0)
|
|
2487 (remaining-available-dimension available-dimension))
|
|
2488 (while (string-match "\\(\\*\\|[0-9]+%?\\)" dims)
|
|
2489 (let ((match (substring dims (match-beginning 1) (match-end 1))))
|
|
2490 (setq dims (substring dims (match-end 1)))
|
|
2491 (cond ((string-match "\\*" match)
|
|
2492 ;; * : divide rest equally
|
|
2493 (push '* dimensions)
|
|
2494 (setq nb-stars (1+ nb-stars)))
|
|
2495 (t
|
|
2496 (cond ((string-match "\\([0-9]+\\)%" match)
|
|
2497 ;; percentage of available height
|
|
2498 (push (/ (* (car (read-from-string (substring match 0 -1)))
|
|
2499 available-dimension)
|
|
2500 100)
|
|
2501 dimensions))
|
|
2502 (t
|
|
2503 ;; absolute number: pixel height
|
|
2504 (push (max (1+ (/ (car (read-from-string match))
|
|
2505 (frame-char-height)))
|
114
|
2506 min-dim)
|
102
|
2507 dimensions)))
|
|
2508 (setq remaining-available-dimension
|
|
2509 (- remaining-available-dimension (car dimensions)))))))
|
|
2510 (if (zerop nb-stars)
|
|
2511 ;; push => reverse order
|
|
2512 (reverse dimensions)
|
|
2513 ;; substitute numbers for *
|
|
2514 (let ((star-replacement (/ remaining-available-dimension nb-stars))
|
108
|
2515 (star-dimensions dimensions))
|
|
2516 (setq dimensions nil)
|
|
2517 (while star-dimensions
|
|
2518 (push (if (eq '* (car star-dimensions))
|
|
2519 star-replacement
|
|
2520 (car star-dimensions))
|
|
2521 dimensions)
|
|
2522 (pop star-dimensions))
|
|
2523 ;; push + push => in order
|
|
2524 dimensions))))))
|
102
|
2525
|
14
|
2526 (provide 'w3-display)
|