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

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 8fc7fe29b841
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-forms.el --- Emacs-w3 forms parsing code for new display engine
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3 ;; Created: 1997/02/09 06:39:43
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
4 ;; Version: 1.65
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, comm, data, languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
11 ;;; This file is part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; FORMS processing for html 2.0/3.0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
32 (eval-when-compile
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
33 (require 'cl))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
34
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (eval-and-compile
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
36 (require 'w3-display)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
37 (require 'widget)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
38 (require 'widget-edit))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
40 (require 'w3-vars)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
41 (require 'mule-sysdp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
43 (defvar w3-form-use-old-style nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
44 "*Non-nil means use the old way of interacting for form fields.")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
45
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
46 (define-widget-keywords :emacspeak-help :w3-form-data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
47
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
48 (defvar w3-form-keymap (copy-keymap global-map))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
49 (if (and w3-form-keymap widget-keymap)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
50 (cl-map-keymap (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
51 (lambda (key binding)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
52 (define-key w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
53 (if (vectorp key) key (vector key))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
54 (case binding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
55 (widget-backward 'w3-widget-backward)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
56 (widget-forward 'w3-widget-forward)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
57 (otherwise binding)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
58 widget-keymap))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
59 (define-key w3-form-keymap [return] 'w3-form-maybe-submit-by-keypress)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
60 (define-key w3-form-keymap "\r" 'w3-form-maybe-submit-by-keypress)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
61 (define-key w3-form-keymap "\n" 'w3-form-maybe-submit-by-keypress)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
62 (define-key w3-form-keymap "\t" 'w3-widget-forward)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
63 (define-key w3-form-keymap "\C-k" 'widget-kill-line)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
64 (define-key w3-form-keymap "\C-a" 'widget-beginning-of-line)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
65 (define-key w3-form-keymap "\C-e" 'widget-end-of-line)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
66
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; A form entry area is a vector
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
68 ;; [ type name default-value value maxlength options widget plist]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Where:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; type = symbol defining what type of form entry area it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; (ie: file, radio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; name = the name of the form element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; default-value = the value this started out with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defsubst w3-form-element-type (obj) (aref obj 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defsubst w3-form-element-name (obj) (aref obj 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defsubst w3-form-element-default-value (obj) (aref obj 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defsubst w3-form-element-value (obj) (aref obj 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defsubst w3-form-element-size (obj) (aref obj 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defsubst w3-form-element-maxlength (obj) (aref obj 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defsubst w3-form-element-options (obj) (aref obj 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defsubst w3-form-element-action (obj) (aref obj 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defsubst w3-form-element-widget (obj) (aref obj 8))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
84 (defsubst w3-form-element-plist (obj) (aref obj 9))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defsubst w3-form-element-set-type (obj val) (aset obj 0 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defsubst w3-form-element-set-name (obj val) (aset obj 1 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defsubst w3-form-element-set-default-value (obj val) (aset obj 2 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defsubst w3-form-element-set-value (obj val) (aset obj 3 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defsubst w3-form-element-set-size (obj val) (aset obj 4 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defsubst w3-form-element-set-maxlength (obj val) (aset obj 5 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defsubst w3-form-element-set-options (obj val) (aset obj 6 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defsubst w3-form-element-set-action (obj val) (aset obj 7 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defsubst w3-form-element-set-widget (obj val) (aset obj 8 val))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
95 (defsubst w3-form-element-set-plist (obj val) (aset obj 9 val))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
97 (defun w3-form-determine-size (el size)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
98 (case (w3-form-element-type el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
99 (checkbox 3)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
100 (radio 4)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
101 ((reset submit) (+ 2 (length (or (w3-form-element-value el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
102 (symbol-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
103 (w3-form-element-type el))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
104 (multiline 21)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
105 (hidden nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
106 (file (or size 26))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
107 ((float password text int)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
108 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
109 (or size 22)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
110 (or size 20)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
111 (image (+ 2 (length (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
112 (plist-get (w3-form-element-plist el) 'alt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
113 "Form-Image"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
114 (option
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
115 (let ((options (copy-sequence (w3-form-element-options el))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
116 (or size
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
117 (length (caar (sort options
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
118 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
119 (lambda (x y)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
120 (>= (length (car x))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
121 (length (car y)))))))))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
122 (otherwise (or size 22))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
123
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
124 ;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
125 (defun w3-form-add-element (plist face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
126 (let* ((action (plist-get plist 'action))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
127 (el (vector (plist-get plist 'type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
128 (plist-get plist 'name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
129 (plist-get plist 'default)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
130 (plist-get plist 'value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
131 (plist-get plist 'size)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
132 (plist-get plist 'maxlength)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
133 (plist-get plist 'options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
134 action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
135 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
136 plist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
137 (size (w3-form-determine-size el (plist-get plist 'size)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
138 (node (assoc action w3-form-elements)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
139 (if (and (eq (plist-get plist 'type) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
140 (not (assq '*table-autolayout w3-display-open-element-stack)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
141 (if node
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
142 (setcdr node (cons el (cdr node)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
143 (setq w3-form-elements (cons (cons action (list el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
144 w3-form-elements))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
145 (if size
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
146 (set-text-properties (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
147 (progn (insert-char ?T size) (point))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
148 (list 'w3-form-info (cons el face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
149 'start-open t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
150 'end-open t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
151 'rear-nonsticky t)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
152
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
153 (defun w3-form-resurrect-widgets ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
154 (let ((st (point-min))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
155 info nd node action face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
156 (while st
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
157 (if (setq info (get-text-property st 'w3-form-info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
158 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
159 (setq nd (or (next-single-property-change st 'w3-form-info)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
160 (point-max))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
161 face (cdr info)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
162 info (car info)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
163 action (w3-form-element-action info)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
164 node (assoc action w3-form-elements))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
165 (goto-char st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
166 (delete-region st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
167 (if (not (w3-form-element-size info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
168 (w3-form-element-set-size info 20))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
169 (if node
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
170 (setcdr node (cons info (cdr node)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
171 (setq w3-form-elements (cons (cons action (list info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
172 w3-form-elements)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
173 (w3-form-add-element-internal info face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
174 (setq st (next-single-property-change st 'w3-form-info)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
175 (setq st (next-single-property-change st 'w3-form-info))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
176
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
177 (defsubst w3-form-mark-widget (widget el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
178 (let ((widgets (list widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
179 (children (widget-get widget :children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
180 (parent (widget-get widget :parent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
181 (w3-form-element-set-widget el widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
182 ;; Get _all_ the children associated with this widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
183 (while children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
184 (setq widgets (cons (car children) widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
185 (if (widget-get (car children) :children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
186 (setq children (append children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
187 (widget-get (car children) :children))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
188 (setq children (cdr children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
189 (while (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
190 (setq widget (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
191 widgets (cons widget widgets)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
192 (setq children (widget-get widget :buttons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
193 ;; Special case for radio buttons
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
194 (while children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
195 (setq widgets (cons (car children) widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
196 (if (widget-get (car children) :children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
197 (setq children (append children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
198 (widget-get (car children) :children))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
199 (setq children (cdr children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
200 (while widgets
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
201 (setq widget (pop widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
202 (widget-put widget :emacspeak-help 'w3-form-summarize-field)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
203 (widget-put widget :help-echo 'w3-form-summarize-field)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
204 (widget-put widget :w3-form-data el))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
205
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
206 (defun w3-form-add-element-internal (el face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let* ((widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (inhibit-read-only t)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
210 (widget-creation-function nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
211 (setq widget-creation-function (or (get (w3-form-element-type el)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 'w3-widget-creation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 'w3-form-default-widget-creator)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
214 widget (and (fboundp widget-creation-function)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
215 (funcall widget-creation-function el face)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (if (not widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 nil
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
218 (w3-form-mark-widget widget el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; These properties tell the add-element function how to actually create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; each type of widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (put 'checkbox 'w3-widget-creation-function 'w3-form-create-checkbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (put 'multiline 'w3-widget-creation-function 'w3-form-create-multiline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (put 'radio 'w3-widget-creation-function 'w3-form-create-radio-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (put 'reset 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (put 'submit 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (put 'hidden 'w3-widget-creation-function 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (put 'file 'w3-widget-creation-function 'w3-form-create-file-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (put 'option 'w3-widget-creation-function 'w3-form-create-option-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (put 'keygen 'w3-widget-creation-function 'w3-form-create-keygen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (put 'button 'w3-widget-creation-function 'w3-form-create-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (put 'image 'w3-widget-creation-function 'w3-form-create-image)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
233 (put 'int 'w3-widget-creation-function 'w3-form-create-integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
234 (put 'float 'w3-widget-creation-function 'w3-form-create-float)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
235 (put 'custom 'w3-widget-creation-function 'w3-form-create-custom)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
236 (put 'text 'w3-widget-creation-function 'w3-form-create-text)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
237 (put 'password 'w3-widget-creation-function 'w3-form-create-password)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
238
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
239 ;; Custom support.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
240 (defvar w3-custom-options nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
241 (make-variable-buffer-local 'w3-custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
242
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
243 (defun w3-form-create-custom (el face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
244 (require 'custom-edit)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
245 (let* ((name (w3-form-element-name el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
246 (var-name (w3-form-element-value el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
247 (type (plist-get (w3-form-element-plist el) 'custom-type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
248 (widget (widget-create (cond ((string-equal type "variable")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
249 'custom-variable)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
250 ((string-equal type "face")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
251 'custom-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
252 ((string-equal type "group")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
253 'custom-group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
254 (t 'item)) (intern var-name))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
255 (custom-magic-reset widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
256 (push widget w3-custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
257 widget))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun w3-form-create-checkbox (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
260 (widget-create 'checkbox
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
261 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (and (w3-form-element-default-value el) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
264 (defun w3-form-radio-button-update (widget child event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
265 (widget-radio-action widget child event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
266 (w3-form-mark-widget widget (widget-get widget :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
267
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun w3-form-create-radio-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (let* ((name (w3-form-element-name el))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
270 (action (w3-form-element-action el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
271 (uniqid (cons name action))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
272 (formobj (cdr (assoc uniqid w3-form-radio-elements)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if formobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq widget (w3-form-element-widget formobj))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
278 (widget-radio-add-item widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
279 (list 'item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
280 :format "%t"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
281 :tag ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
282 :value (w3-form-element-value el)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
283 (w3-form-mark-widget widget el)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
284 (if (w3-form-element-default-value el)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
285 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
286 (widget-put widget 'w3-form-default-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
287 (w3-form-element-value el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
288 (widget-value-set widget (w3-form-element-value el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
290 (setq widget (widget-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
291 'radio-button-choice
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
292 :value (w3-form-element-value el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
293 :action 'w3-form-radio-button-update
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
294 (list 'item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
295 :format "%t"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
296 :tag ""
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
297 :value (w3-form-element-value el)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
298 w3-form-radio-elements (cons (cons uniqid el)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 w3-form-radio-elements))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
300 (widget-put widget 'w3-form-default-value (w3-form-element-value el))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defun w3-form-create-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; This handles dealing with the bogus Netscape 'button' input type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; that lots of places have been using to slap javascript shit onto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq val "Push Me"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
309 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
310 :notify 'ignore
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
311 :button-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
312 :value-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
313 val)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defun w3-form-create-image (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
316 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
317 :notify 'w3-form-submit/reset-callback
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
318 :value (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
319 (plist-get (w3-form-element-plist el) 'alt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
320 "Form-Image")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun w3-form-create-submit-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq val (if (eq (w3-form-element-type el) 'submit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "Submit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Reset")))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
328 (widget-create 'push-button
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
329 :notify 'w3-form-submit/reset-callback
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 :button-face face val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (defun w3-form-create-file-browser (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
333 (widget-create 'file
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
334 :button-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
335 :value-face face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
336 :size (w3-form-element-size el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
337 :must-match t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
338 :value (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defvar w3-form-valid-key-sizes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ("1024 (Premium)" . 1024)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ("896 (Regular)" . 896)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ("768 (Unleaded)" . 768)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ("512 (Low Grade)" . 512)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ("508 (Woos)" . 508)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ("256 (Test Grade)" . 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "An assoc list of available key sizes and meaningful descriptions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defun w3-form-create-keygen-list (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (let ((tmp w3-form-valid-key-sizes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (longest 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (options nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (> (length (caar tmp)) longest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq longest (length (caar tmp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq options (cons (list 'choice-item :tag (caar tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 :value (cdar tmp)) options)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 tmp (cdr tmp)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
361 (apply 'widget-create 'menu-choice
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
362 :value 1024
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
363 :ignore-case t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 :tag "Key Length"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 :size (1+ longest)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
366 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 options)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun w3-form-create-option-list (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
371 (let* ((size (w3-form-determine-size el nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
372 (widget (apply 'widget-create 'menu-choice
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
373 :value (w3-form-element-value el)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
374 :ignore-case t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 :tag "Choose"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
376 :format "%v"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
377 :size size
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 :value-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
379 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (list 'choice-item :format "%[%t%]"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
384 :emacspeak-help 'w3-form-summarize-field
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
385 :tag (mule-truncate-string (car x) size ? )
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
386 :button-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
387 :value-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
388 :value (car x))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
389 (w3-form-element-options el)))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
390 (widget-value-set widget (w3-form-element-value el))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;(defun w3-form-create-multiline (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
394 ; (widget-create 'text :value-face face (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (defun w3-form-create-multiline (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
397 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
398 :notify 'w3-do-text-entry
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
399 "Multiline text area"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
400
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
401 (defun w3-form-create-integer (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
402 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
403 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
404 (widget-create 'integer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
405 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
406 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
407 :tag ""
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
408 :format "%v"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
409 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
410 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
411 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
412
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
413 (defun w3-form-create-float (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
414 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
415 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
416 (widget-create 'number
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
417 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
418 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
419 :format "%v"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
420 :tag ""
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
421 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
422 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
423 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
424
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
425 (defun w3-form-create-text (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
426 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
427 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
428 (widget-create 'editable-field
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
429 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
430 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
431 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
432 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
433 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
434
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
435 (defun w3-form-create-password (el face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
436 ;; *sigh* This will fail under XEmacs, but I can yell at them about
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
437 ;; upgrading separately for the release of 19.15 and 20.0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
438 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
439 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
440 (widget-create 'editable-field
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
441 :secret ?*
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
442 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
443 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
444 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
445 :button-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
446 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
447 (w3-form-element-value el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun w3-form-default-widget-creator (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (widget-create 'link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 :notify 'w3-form-default-button-callback
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
452 :value-to-internal 'w3-form-default-button-update
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 :size (w3-form-element-size el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 :value-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
455 :button-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
456 :w3-form-data el
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
459 (defun w3-form-default-button-update (w v)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
460 (let ((info (widget-get w :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
461 (widget-put w :tag
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
462 (if info
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
463 (mule-truncate-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
464 (if (eq 'password (w3-form-element-type info))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
465 (make-string (length v) ?*)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
466 v)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
467 (w3-form-element-size info) ? )))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
468 v))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
469
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defun w3-form-default-button-callback (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
471 (let* ((obj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (typ (w3-form-element-type obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (def (widget-value widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (val nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (case typ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (password
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
478 (setq val (funcall url-passwd-entry-func "Password: " def)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq val (read-string
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
481 (concat (capitalize (symbol-name typ)) ": ") def))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (widget-value-set widget val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (apply 'w3-form-possibly-submit widget ignore))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
484
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
485 ;; These properties tell the help-echo function how to summarize each
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
486 ;; type of widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
487 (put 'checkbox 'w3-summarize-function 'w3-form-summarize-checkbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
488 (put 'multiline 'w3-summarize-function 'w3-form-summarize-multiline)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
489 (put 'radio 'w3-summarize-function 'w3-form-summarize-radio-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
490 (put 'reset 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
491 (put 'submit 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
492 (put 'button 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
493 (put 'file 'w3-summarize-function 'w3-form-summarize-file-browser)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
494 (put 'option 'w3-summarize-function 'w3-form-summarize-option-list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
495 (put 'keygen 'w3-summarize-function 'w3-form-summarize-keygen-list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
496 (put 'image 'w3-summarize-function 'w3-form-summarize-image)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
497 (put 'hidden 'w3-summarize-function 'ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
498
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
499 (defun w3-form-summarize-field (widget &rest ignore)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
500 "Sumarize a widget that should be a W3 form entry area.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
501 This can be used as the :help-echo property of all w3 form entry widgets."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
502 (let ((info nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
503 (func nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
504 (msg nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
505 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
506 (setq info (widget-get widget :w3-form-data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
507 (if info
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
508 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
509 (while (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
510 (setq widget (widget-get widget :parent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
511 (setq info (widget-get widget :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
512 (if (not info)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
513 (signal 'wrong-type-argument (list 'w3-form-widget widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
514 (setq func (or (get (w3-form-element-type info) 'w3-summarize-function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
515 'w3-form-summarize-default)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
516 msg (and (fboundp func) (funcall func info widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
517 ;; FIXME! This should be removed once emacspeak is updated to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
518 ;; more closely follow the widget-y way of just returning the string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
519 ;; instead of having the underlying :help-echo or :emacspeak-help
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
520 ;; implementation do it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
521 (message "%s" msg)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
522
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
523 (defsubst w3-form-field-label (data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
524 ;;; FIXXX!!! Need to reimplement using the new forms implementation!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
525 (declare (special w3-form-labels))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
526 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
527
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
528 (defun w3-form-summarize-default (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
529 (let ((label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
530 (name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
531 (value (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
532 (format "Text field %s set to: %s" (or label (concat "called " name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
533 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
534
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
535 (defun w3-form-summarize-multiline (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
536 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
537 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
538 (value (w3-form-element-value data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
539 (format "Multiline text input %s set to: %s"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
540 (or label (concat "called " name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
541 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
542
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
543 (defun w3-form-summarize-checkbox (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
544 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
545 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
546 (checked (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
547 (format "Checkbox %s is %s" (or label name) (if checked "on" "off"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
548
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
549 (defun w3-form-summarize-option-list (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
550 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
551 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
552 (default (w3-form-element-default-value data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
553 (format "Option list (%s) set to: %s" (or label name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
554 (widget-value (w3-form-element-widget data)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
555
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
556 (defun w3-form-summarize-image (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
557 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
558 (label (w3-form-field-label data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
559 (concat "Image entry " (or label (concat "called " name)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
560
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
561 (defun w3-form-summarize-submit-button (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
562 (let* ((type (w3-form-element-type data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
563 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
564 (button-text (widget-value (w3-form-element-widget data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
565 (type-desc (case type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
566 (submit "Submit Form")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
567 (reset "Reset Form")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
568 (button "A Button"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
569 (format "%s: %s" type-desc (or label button-text ""))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
570
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
571 (defun w3-form-summarize-radio-button (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
572 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
573 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
574 (cur-value (widget-value (w3-form-element-widget data)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
575 (this-value (widget-value (widget-get-sibling widget))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
576 (format "Radio button %s is %s, could be %s" (or label name) cur-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
577 this-value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
578
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
579 (defun w3-form-summarize-file-browser (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
580 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
581 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
582 (file (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
583 (format "File entry %s pointing to: %s" (or label name) (or file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
584 "[nothing]"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
585
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
586 (defun w3-form-summarize-keygen-list (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
587 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
588
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
589
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
590 (defun w3-form-maybe-submit-by-keypress ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
591 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
592 (let ((widget (widget-at (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
593 (if widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
594 (w3-form-possibly-submit widget))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (defun w3-form-possibly-submit (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
597 (let* ((formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (ident (w3-form-element-action formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (widgets (w3-all-widgets ident))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (text-fields 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (text-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;; Gack. Netscape auto-submits forms of one text field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; here we go through the list of widgets in this form and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; determine which are not submit/reset/button inputs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; If the # == 1, then submit the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (while widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (setq text-fields (+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 text-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (case (w3-form-element-type (car widgets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ((submit reset image button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (setq text-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 widgets (cdr widgets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (if (and (= text-fields 1) text-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (w3-submit-form ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun w3-form-submit/reset-callback (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
624 (let* ((formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (w3-submit-button formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (case (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (submit (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (reset (w3-revert-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (image (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 "Impossible widget type %s triggered w3-form-submit/reset-callback"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (w3-form-element-type formobj))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (defun w3-do-text-entry (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (let* ((data (list widget (current-buffer)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
637 (formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (buff (get-buffer-create (format "Form Entry: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (w3-form-element-name formobj)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (switch-to-buffer-other-window buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (indented-text-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (if (w3-form-element-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (insert (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq w3-current-last-buffer data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (message "Press C-c C-c when finished with text entry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (local-set-key "\C-c\C-c" 'w3-finish-text-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defun w3-finish-text-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if w3-current-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (let* ((widget (nth 0 w3-current-last-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
653 (formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (buff (nth 1 w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (valu (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (local-set-key "\C-c\C-c" 'undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (if (not (and buff (bufferp buff) (buffer-name buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (message "Could not find the form buffer for this text!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (switch-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (w3-form-element-set-value formobj valu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (defsubst w3-all-widgets (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; Return a list of data entry widgets in form number ACTN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (cdr-safe (assoc actn w3-form-elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (defun w3-revert-form (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (let* ((formobjs (w3-all-widgets actn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 deft type widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 deft (w3-form-element-default-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 type (w3-form-element-type formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (case type
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
684 ((submit reset image hidden) nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (radio
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
686 (setq deft (widget-get widget 'w3-form-default-value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
687 (if (and widget deft)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
688 (widget-value-set widget deft)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (if deft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (widget-value-set widget t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (widget-value-set widget nil)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
693 (multiline
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
694 (w3-form-element-set-value formobj (w3-form-element-default-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
695 formobj)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (widget-value-set widget deft))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (otherwise
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
699 (widget-value-set widget deft))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
700 (widget-setup))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (defun w3-form-encode-helper (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (submit-button-data w3-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 formobj result widget temp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 type (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 temp (case type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (reset nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
713 (button nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (image
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq result (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ".x") "0")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ".y") "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (submit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (radio
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
733 (let* ((radio-name (w3-form-element-name formobj))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
734 (radio-object (cdr-safe
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
735 (assoc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
736 (cons
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
737 radio-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
738 (w3-form-element-action formobj))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
739 w3-form-radio-elements)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
740 (chosen-widget (and radio-object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
741 (widget-radio-chosen
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
742 (w3-form-element-widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
743 radio-object)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
744 (if (assoc radio-name result)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
746 (cons radio-name (widget-value chosen-widget)))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
747 ((int float)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
748 (cons (w3-form-element-name formobj)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
749 (number-to-string (or (condition-case ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
750 (widget-value widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
751 (error nil)) 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (if (widget-value widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (let ((dat nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (fname (widget-value widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (set-buffer (get-buffer-create " *w3-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (setq dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (insert-file-contents-literally fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (error (concat "Error accessing " fname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (cons (w3-form-element-name formobj) dat))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (cons (w3-form-element-name formobj)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
769 (cdr-safe
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
770 (assoc (widget-value widget)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
771 (w3-form-element-options formobj)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (keygen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (format "Should create a %d bit RSA key"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (widget-value widget))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ((multiline hidden)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (widget-value widget)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (setq result (cons temp result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (defun w3-form-encode-make-mime-part (id data separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (concat separator "\nContent-id: " id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 "\nContent-length: " (length data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 "\n\n" data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (defun w3-form-encode-multipart/x-www-form-data (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; Create a multipart form submission.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; Returns a cons of two strings. Car is the separator used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ;; cdr is the body of the MIME message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (let ((separator "---some-separator-for-www-form-data"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (cons separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (lambda (formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (w3-form-encode-make-mime-part (car formobj) (cdr formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (w3-form-encode-helper formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (fset 'w3-form-encode-multipart/form-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 'w3-form-encode-multipart/x-www-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (fset 'w3-form-encode- 'w3-form-encode-application/x-www-form-urlencoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (defun w3-next-widget (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (let* ((next (cond ((get-text-property pos 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (next-single-property-change pos 'button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ((get-text-property pos 'field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (next-single-property-change pos 'field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (t pos)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
815 (button (and next (next-single-property-change next 'button)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
816 (field (and next (next-single-property-change next 'field))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (setq next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ((and button field) (min button field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (button button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (and next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (or (get-text-property next 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (get-text-property next 'field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (defun w3-form-encode (result &optional enctype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 "Create a string suitably encoded for a URL request."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (let ((func (intern (concat "w3-form-encode-" enctype))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
830 (if (fboundp func)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
831 (funcall func result)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
832 (w3-warn 'html (format "Bad encoding type for form data: %s" enctype))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
833 (w3-form-encode-application/x-www-form-urlencoded result))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (defun w3-form-encode-text/plain (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (lambda (widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (let ((nam (car widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (val (cdr widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if (string-match "\n" nam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (setq nam (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if (= x ?\n) "," (char-to-string x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 nam "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (concat nam " " val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (w3-form-encode-helper result) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
853 (defun w3-form-encode-application/x-w3-wais (result)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
854 (cdr (car (w3-form-encode-helper result))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
855
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (defun w3-form-encode-application/x-gopher-query (result)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
857 (concat "\t" (cdr (car (w3-form-encode-helper result)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (defun w3-form-encode-xwfu (chunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 "Escape characters in a string for application/x-www-form-urlencoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 Blasphemous crap because someone didn't think %20 was good enough for encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 spaces. Die Die Die."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (lambda (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ((= char ? ) "+")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
868 ((memq char '(?: ?/)) (char-to-string char))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
869 ((memq char url-unreserved-chars) (char-to-string char))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
870 (t (upcase (format "%%%02x" char))))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
871 (mule-encode-string chunk) ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (defun w3-form-encode-application/x-www-form-urlencoded (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (lambda (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (concat (w3-form-encode-xwfu (car data)) "="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (w3-form-encode-xwfu (cdr data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (w3-form-encode-helper result) "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (defun w3-form-encode-application/x-w3-isindex (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (let* ((info (w3-form-encode-helper result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (query (cdr-safe (assoc "isindex" info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (if query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (url-hexify-string query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (defun w3-form-encode-application/gopher-ask-block (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;;; gopher+ will expect all the checkboxes/etc, even if they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;;; not turned on. Should still ignore RADIO boxes that are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;;; active though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (while result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (if (and (not (and (string= (nth 2 (car result)) "RADIO")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (not (nth 6 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (not (member (nth 2 (car result)) '("SUBMIT" "RESET"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq query (format "%s\r\n%s" query (nth 5 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (setq result (cdr result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (concat query "\r\n.\r\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (defun w3-submit-form (ident)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;; Submit form entry fields matching ACTN as their action identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (let* ((result (w3-all-widgets ident))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
904 (enctype (or (cdr (assq 'enctype ident))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
905 "application/x-www-form-urlencoded"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (query (w3-form-encode result enctype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (themeth (upcase (or (cdr (assq 'method ident)) "get")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (theurl (cdr (assq 'action ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (if (and (string= "GET" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (string-match "\\([^\\?]*\\)\\?" theurl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (setq theurl (url-match theurl 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ((or (string= "POST" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (string= "PUT" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (if (consp query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (setq enctype (concat enctype "; separator=\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (substring (car query) 3 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 query (cdr query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (let ((url-request-method themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (url-request-data query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (url-request-extra-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (cons (cons "Content-type" enctype) url-request-extra-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ((string= "GET" themeth)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
926 (let ((theurl (concat theurl (if (string-match "gopher" enctype)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
927 "" "?") query)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (w3-warn 'html (format "Unknown submit method: %s" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (let ((theurl (concat theurl "?" query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (w3-fetch theurl))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (provide 'w3-forms)