Mercurial > hg > xemacs-beta
comparison lisp/w3/w3-speak.el @ 82:6a378aca36af r20-0b91
Import from CVS: tag r20-0b91
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:07:36 +0200 |
parents | 1ce6082ce73f |
children | 0d2f883870bc |
comparison
equal
deleted
inserted
replaced
81:ebca3d831cea | 82:6a378aca36af |
---|---|
6 ;; Version: 1.14 | 6 ;; Version: 1.14 |
7 ;; Keywords: hypermedia, speech | 7 ;; Keywords: hypermedia, speech |
8 | 8 |
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
10 ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com) | 10 ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com) |
11 ;;; Copyright (c) 1996 by William M. Perry (wmperry@spry.com) | 11 ;;; Copyright (c) 1996, 1997 by William M. Perry (wmperry@spry.com) |
12 ;;; Copyright (c) 1997 Free Software Foundation, Inc. | |
12 ;;; | 13 ;;; |
13 ;;; This file is not part of GNU Emacs, but the same permissions apply. | 14 ;;; This file is not part of GNU Emacs, but the same permissions apply. |
14 ;;; | 15 ;;; |
15 ;;; GNU Emacs is free software; you can redistribute it and/or modify | 16 ;;; GNU Emacs is free software; you can redistribute it and/or modify |
16 ;;; it under the terms of the GNU General Public License as published by | 17 ;;; it under the terms of the GNU General Public License as published by |
54 (eval-when (compile) | 55 (eval-when (compile) |
55 (require 'emacspeak-fix-interactive))) | 56 (require 'emacspeak-fix-interactive))) |
56 (error (message "Emacspeak not found - speech will not work."))) | 57 (error (message "Emacspeak not found - speech will not work."))) |
57 | 58 |
58 | 59 |
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 60 ;;{{{ speaking form fields |
60 ;;; How to get information summarizing a form field, so it can be spoken in | 61 |
61 ;;; a sane manner. | 62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 63 ;;; Now for the guts |
63 ;;{{{ putting and getting form field summarizer | 64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
64 | 65 (defun w3-speak-summarize-form-field () |
65 (defsubst w3-speak-define-field-summarizer (type &optional function-name) | 66 "Summarizes field under point if any." |
66 "Associate the name of a function that describes this type of form field." | 67 (let ((widget (widget-at (point)))) |
67 (put type 'w3-speak-summarizer | 68 (and widget (w3-form-summarize-field widget)))) |
68 (or function-name (intern | |
69 (format "w3-speak-summarize-%s-field" type))))) | |
70 | |
71 (defsubst w3-speak-get-field-summarizer (type) | |
72 "Retrieve function-name string for this voice" | |
73 (get type 'w3-speak-summarizer)) | |
74 | |
75 ;;}}} | |
76 ;;{{{ Associate summarizer functions for form fields | |
77 | |
78 (w3-speak-define-field-summarizer 'text) | |
79 (w3-speak-define-field-summarizer 'option) | |
80 (w3-speak-define-field-summarizer 'checkbox) | |
81 (w3-speak-define-field-summarizer 'reset) | |
82 (w3-speak-define-field-summarizer 'submit) | |
83 (w3-speak-define-field-summarizer 'button) | |
84 (w3-speak-define-field-summarizer 'radio) | |
85 (w3-speak-define-field-summarizer 'multiline) | |
86 (w3-speak-define-field-summarizer 'image) | |
87 | |
88 ;;}}} | |
89 | |
90 | |
91 ;;{{{ define the form field summarizer functions | |
92 | |
93 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
94 ;;; Now actually define the summarizers | |
95 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
96 | |
97 (defsubst w3-speak-extract-form-field-label (data) | |
98 ;;; FIXXX!!! Need to reimplement using the new forms implementation! | |
99 (declare (special w3-form-labels)) | |
100 nil) | |
101 | |
102 (defun w3-speak-summarize-text-field (data) | |
103 "Summarize a text field given the field data." | |
104 (let ( | |
105 (label (w3-speak-extract-form-field-label data)) | |
106 (name (w3-form-element-name data)) | |
107 (value (widget-get (w3-form-element-widget data) :value))) | |
108 (dtk-speak | |
109 (format "Text field %s %s " (or label (concat "called " name)) | |
110 (concat "set to " value))))) | |
111 | |
112 (defun w3-speak-summarize-multiline-field (data) | |
113 "Summarize a text field given the field data." | |
114 (let ( | |
115 (name (w3-form-element-name data)) | |
116 (label (w3-speak-extract-form-field-label data)) | |
117 (value (w3-form-element-value data))) | |
118 (dtk-speak | |
119 (format "Multiline text input %s %s" (or label (concat "called " name)) | |
120 (concat "set to " value))))) | |
121 | |
122 (defun w3-speak-summarize-checkbox-field (data) | |
123 "Summarize a checkbox field given the field data." | |
124 (let ( | |
125 (name (w3-form-element-name data)) | |
126 (label (w3-speak-extract-form-field-label data)) | |
127 (checked (widget-value (w3-form-element-widget data)))) | |
128 (dtk-speak | |
129 (format "Checkbox %s is %s" (or label name) (if checked "on" "off"))))) | |
130 | |
131 (defun w3-speak-summarize-option-field (data) | |
132 "Summarize a options field given the field data." | |
133 (let ( | |
134 (name (w3-form-element-name data)) | |
135 (label (w3-speak-extract-form-field-label data)) | |
136 (default (w3-form-element-default-value data))) | |
137 (dtk-speak | |
138 (format "Choose an option %s %s" (or label name) | |
139 (if (string= "" default) | |
140 "" | |
141 (format "default is %s" default)))))) | |
142 | |
143 ;;; to handle brain dead nynex forms | |
144 (defun w3-speak-summarize-image-field (data) | |
145 "Summarize a image field given the field data. | |
146 Currently, only the NYNEX server uses this." | |
147 (let ( | |
148 (name (w3-form-element-name data)) | |
149 (label (w3-speak-extract-form-field-label data))) | |
150 (dtk-speak | |
151 (substring name 1)))) | |
152 | |
153 (defun w3-speak-summarize-submit-field (data) | |
154 "Summarize a submit field given the field data." | |
155 (let ( | |
156 (type (w3-form-element-type data)) | |
157 (label (w3-speak-extract-form-field-label data)) | |
158 (button-text (widget-value (w3-form-element-widget data)))) | |
159 (message "%s" (or label button-text | |
160 (case type | |
161 (submit "Submit Form") | |
162 (reset "Reset Form") | |
163 (button "A Button")))))) | |
164 | |
165 (defalias 'w3-speak-summarize-reset-field 'w3-speak-summarize-submit-field) | |
166 (defalias 'w3-speak-summarize-button-field 'w3-speak-summarize-submit-field) | |
167 | |
168 (defun w3-speak-summarize-radio-field (data) | |
169 "Summarize a radio field given the field data." | |
170 (let ( | |
171 (name (w3-form-element-name data)) | |
172 (label (w3-speak-extract-form-field-label data)) | |
173 (checked (widget-value (w3-form-element-widget data)))) | |
174 (dtk-speak | |
175 (format "Radio button %s is %s" (or label name) (if checked | |
176 "pressed" | |
177 "not pressed"))))) | |
178 | 69 |
179 ;;}}} | 70 ;;}}} |
180 | 71 |
181 ;;{{{ speaking form fields | |
182 | |
183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
184 ;;; Now for the guts | |
185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
186 (defun w3-speak-extract-form-field-information () | |
187 (let* ((widget (widget-at (point))) | |
188 (data (and widget (widget-get widget 'w3-form-data)))) | |
189 data)) | |
190 | |
191 (defun w3-speak-summarize-form-field () | |
192 "Summarizes field under point if any." | |
193 (let* ((data (w3-speak-extract-form-field-information)) | |
194 (type (and data (w3-form-element-type data))) | |
195 (summarizer (and type (w3-speak-get-field-summarizer type)))) | |
196 (cond | |
197 ((and data | |
198 summarizer | |
199 (fboundp summarizer)) | |
200 (funcall summarizer data)) | |
201 (data | |
202 (message "Please define a summarizer function for %s" type)) | |
203 (t nil)))) | |
204 | |
205 ;;}}} | |
206 | |
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 72 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
208 ;;; Movement notification | 73 ;;; Movement notification |
209 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 74 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
75 (defadvice w3-widget-forward (after emacspeak pre act comp) | |
76 (when (interactive-p) | |
77 (emacspeak-auditory-icon 'large-movement) | |
78 (emacspeak-widget-summarize (emacspeak-widget-at (point ))))) | |
79 | |
80 | |
81 (defadvice w3-widget-backward (after emacspeak pre act comp) | |
82 (when (interactive-p) | |
83 (emacspeak-auditory-icon 'large-movement) | |
84 (emacspeak-widget-summarize (emacspeak-widget-at (point ))))) | |
85 | |
210 (defadvice w3-scroll-up (after emacspeak pre act comp) | 86 (defadvice w3-scroll-up (after emacspeak pre act comp) |
211 "Provide auditory feedback" | 87 "Provide auditory feedback" |
212 (when (interactive-p) | 88 (when (interactive-p) |
213 (let ((start (point ))) | 89 (let ((start (point ))) |
214 (emacspeak-auditory-icon 'scroll) | 90 (emacspeak-auditory-icon 'scroll) |