Function: eww-process-text-input
eww-process-text-input is a byte-compiled function defined in
eww.el.gz.
Signature
(eww-process-text-input BEG END REPLACE-LENGTH)
Source Code
;; Defined in /usr/src/emacs/lisp/net/eww.el.gz
(defun eww-process-text-input (beg end replace-length)
(when-let* ((pos (and (< (1+ end) (point-max))
(> (1- end) (point-min))
(cond
((get-text-property (1+ end) 'eww-form)
(1+ end))
((get-text-property (1- end) 'eww-form)
(1- end))))))
(let* ((form (get-text-property pos 'eww-form))
(properties (text-properties-at pos))
(buffer-undo-list t)
(inhibit-read-only t)
(length (- end beg replace-length))
(type (plist-get form :type)))
(when (and form
(member type eww-text-input-types))
(cond
((> length 0)
;; Delete some space at the end.
(save-excursion
(goto-char
(if (equal type "textarea")
(1- (line-end-position))
(eww-end-of-field)))
(while (and (> length 0)
(eql (char-after (1- (point))) ? ))
(delete-region (1- (point)) (point))
(cl-decf length))))
((< length 0)
;; Add padding.
(save-excursion
(goto-char end)
(goto-char
(if (equal type "textarea")
(1- (line-end-position))
(1+ (eww-end-of-field))))
(let ((start (point)))
(insert (make-string (abs length) ? ))
(set-text-properties start (point) properties))
(goto-char (1- end)))))
(set-text-properties (cdr (assq :start form))
(cdr (assq :end form))
properties)
(let ((value (buffer-substring-no-properties
(eww-beginning-of-field)
(eww-end-of-field))))
(when (string-match " +\\'" value)
(setq value (substring value 0 (match-beginning 0))))
(plist-put form :value value)
(when (equal type "password")
;; Display passwords as asterisks.
(let ((start (eww-beginning-of-field)))
(put-text-property
start (+ start (length value))
'display (make-string (length value) ?*)))))))))