annotate lisp/w3/w3-display.el @ 88:821dec489c24 r20-0

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