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