annotate lisp/w3/w3-display.el @ 20:859a2309aef8 r19-15b93

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