[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
carethook, and uploaded my code from MCL CD to cambridge archive.
- To: email@example.com
- Subject: carethook, and uploaded my code from MCL CD to cambridge archive.
- From: firstname.lastname@example.org (Alan Ruttenberg)
- Date: Sat, 11 Feb 1995 02:36:19 GMT
- Organization: MIT Media Laboratory Learning an Common Sense Group
- Sender: email@example.com
In article <firstname.lastname@example.org> email@example.com (Michael Korcuska) writes:
From: firstname.lastname@example.org (Michael Korcuska)
In article <email@example.com>, firstname.lastname@example.org
(David S. April) wrote:
> How can I change the shape of the insertion point (not the cursor...) to,
> say, a horizontal bar instead of a vertical bar?
More complicated than you think. In mac lingo the insertion bar is called
a "caret". There's a "carethook" field in all textedit records which can
contain a pointer to a user supplied procedure for drawing the caret. I
tried to use this the other day and crashed my mac badly. And it isn't
entirely clear to me that you can change the bounding rectangle of the
caret easily without clobbering adjacent text.
Maybe this can help you get started. It is some code I used to prevent
the cursor from showing. The bottom line is that you have to write the
cursor code in lap. The te-basic class has a slot called
textedit-handle, which contains the terec. The code is taken from
textedit.lisp (a largish lisp interface to textedit), which is on the
MCL 2.0 CD under "alanr's contributions". I've just uploaded my CD
code to cambridge.apple.com in mcl2/contrib/alanr-mcl2.0cd-contribs.sit.hqx.
About that code: Some of it has been updated/fixed since the CD
release, but I haven't taken the time to submit a new version of my
tools. If you are interested in actually using some of it, drop me a
note and I'll send you more current versions, if they exist.
Here's the excerpt showing an alternative carethook.
(def-load-pointers *null-caret-hook* ()
(let ((words (%lap-words '((add ($ 4) sp) (rts)))))
(let ((r (#_newptr (* 2 (length words)))))
(loop for w in words
for offset from 0 by 2
do (%put-word r w offset))
;; always lock the sucker down when using. It *will* move out from
;; under you.
(defmacro with-terec (p &body body)
`(let ((terec (textedit-handle ,p)))
(unwind-protect (progn ,@body)
(defmethod cursor-on ((p te-basic))
(with-terec p ; (%null-ptr) means use the default carethook.
(setf (href terec terec.carethook) (%null-ptr))))
(defmethod cursor-off ((p te-basic))
(setf (href terec terec.carethook) *null-caret-hook*)))