If you create a widget with:
(widget-create 'editable-field
:secret ?*
"testing")
I would expect to get a widget like:
*******
instead of what you do get:
testing
The problem is that :secret is only ever dealt with in widget-after-change
or widget-value-get. But should be checked in widget-value-create, etc. I
don't have time to dig further than this since my mother just died this
morning. I'll be out of commission for a few days to say the least.
-Bill P.
Show replies by date
Here is a patch:
1998-06-09 Per Abrahamsen <abraham(a)dina.kvl.dk>
* wid-edit.el (widget-specify-secret): New function.
(widget-after-change): Use it.
(widget-specify-field): Use it.
Index: wid-edit.el
===================================================================
RCS file: /home/user_32/abraham/cvs/custom/wid-edit.el,v
retrieving revision 1.112
diff -c -r1.112 wid-edit.el
*** 1.112 1998/03/04 10:52:32
--- wid-edit.el 1998/06/09 12:52:43
***************
*** 409,415 ****
(overlay-put overlay 'keymap map)
(overlay-put overlay 'face face)
(overlay-put overlay 'balloon-help help-echo)
! (overlay-put overlay 'help-echo help-echo)))
(defun widget-specify-button (widget from to)
"Specify button for WIDGET between FROM and TO."
--- 409,434 ----
(overlay-put overlay 'keymap map)
(overlay-put overlay 'face face)
(overlay-put overlay 'balloon-help help-echo)
! (overlay-put overlay 'help-echo help-echo))
! (widget-specify-secret widget))
!
! (defun widget-specify-secret (field)
! "Replace text in FIELD with value of `:secret', if non-nil."
! (let ((secret (widget-get field :secret))
! (size (widget-get field :size)))
! (when secret
! (let ((begin (widget-field-start field))
! (end (widget-field-end field)))
! (when size
! (while (and (> end begin)
! (eq (char-after (1- end)) ?\ ))
! (setq end (1- end))))
! (while (< begin end)
! (let ((old (char-after begin)))
! (unless (eq old secret)
! (subst-char-in-region begin (1+ begin) old secret)
! (put-text-property begin (1+ begin) 'secret old))
! (setq begin (1+ begin))))))))
(defun widget-specify-button (widget from to)
"Specify button for WIDGET between FROM and TO."
***************
*** 1329,1336 ****
(when field
(unless (eq field other)
(debug "Change in different fields"))
! (let ((size (widget-get field :size))
! (secret (widget-get field :secret)))
(when size
(let ((begin (widget-field-start field))
(end (widget-field-end field)))
--- 1353,1359 ----
(when field
(unless (eq field other)
(debug "Change in different fields"))
! (let ((size (widget-get field :size)))
(when size
(let ((begin (widget-field-start field))
(end (widget-field-end field)))
***************
*** 1352,1370 ****
(while (and (eq (preceding-char) ?\ )
(> (point) begin))
(delete-backward-char 1)))))))
! (when secret
! (let ((begin (widget-field-start field))
! (end (widget-field-end field)))
! (when size
! (while (and (> end begin)
! (eq (char-after (1- end)) ?\ ))
! (setq end (1- end))))
! (while (< begin end)
! (let ((old (char-after begin)))
! (unless (eq old secret)
! (subst-char-in-region begin (1+ begin) old secret)
! (put-text-property begin (1+ begin) 'secret old))
! (setq begin (1+ begin)))))))
(widget-apply field :notify field)))
(error (debug "After Change"))))
--- 1375,1381 ----
(while (and (eq (preceding-char) ?\ )
(> (point) begin))
(delete-backward-char 1)))))))
! (widget-specify-secret field))
(widget-apply field :notify field)))
(error (debug "After Change"))))