annotate lisp/w3/w3-display.el @ 136:b980b6286996 r20-2b2

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