CLIM mail archive
Re: editing a string default
Date: Fri, 14 Feb 1992 11:55-0500
From: Scott McKay <SWM@sapsucker.scrc.symbolics.com>
Subject: editing a string default
To: firstname.lastname@example.org, clim@BBN.COM
Date: Fri, 14 Feb 1992 10:06 EST
When in an (accept 'string . . ., I know it is possible for a user
to type ctrl-meta-y to edit a default. However, I would like the
default to automatically appear for editing with the cursor at the
end (before the user does anything). Also, I don't want to show a
prompt or display-default, only an editable default.
Is that possible?
CLIM 1.1 (and hence CLIM 2.0) will include a :INSERT-DEFAULT keyword
that does what you want.
Here is a presentation type that we defined for CLIM 0.9 which does what
you want, though it might be worth waiting.
;;; KRA 14:35 15NOV91:
An editable-string presentation type that takes a :DEFAULT value you can
edit (Originally from MDean, with kludge from Gerard, Dan and Ken).
When you accept something, ACCEPT-2 alls the appropriate presentation type
:PARSER method inside a WITH-INPUT-EDITING environment which is basically a
do-over loop that calls the :PARSER again if you type a :RUBOUT, or
something, to cause a rescan. The rescan calls the :PARSER again. The
following global variable is used to show the default to the user only the
(defvar editable-string-rubout-default-kludge "")
(define-presentation-type editable-string ()
;; hopefully temporary presentation type, until accepting-values allows editing of the default value as well as replacement
:parser ((stream &key default)
(when (not (eq editable-string-rubout-default-kludge default))
(setf editable-string-rubout-default-kludge default)
(let ((input-buffer (clim-internals::input-editor-buffer stream)))
(when (zerop (fill-pointer input-buffer))
;;I added the reverse, unread is pushing the characters so they
;;must go on in reverse order. Gerard 21mar91.
(dolist (c (reverse (coerce default 'list)))
(stream-unread-char stream c)))))
;; stream-read-line only stops on #\newline
(let ((buf (make-array 20
(let ((ch (stream-read-char stream)))
(setf editable-string-rubout-default-kludge "")
(vector-push-extend ch buf)))))))
:printer ((string stream &key &allow-other-keys)
(write-string string stream)))
Main Index |