home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / lisp / mcl / 1845 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  2.2 KB

  1. Path: sparky!uunet!stanford.edu!apple!cambridge.apple.com!bill@cambridge.apple.com
  2. From: bill@cambridge.apple.com (Bill St. Clair)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: view-cursor
  5. Message-ID: <9212161504.AA03390@cambridge.apple.com>
  6. Date: 16 Dec 92 16:08:35 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 43
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11. At 19:11 12/15/92 -0500, Dale J. Skrien wrote:
  12. >I've created a special subclass of view for which I want to continually
  13. >display the mouse position when it is over the view.  I want the mouse
  14. >position to be displayed in the view-window of the view but outside
  15. >of the view.  So I wrote a method of view-cursor for my view as follows:
  16. >
  17. >(defmethod view-cursor ((self my-special-view-class) where)
  18. >  (with-focused-view (view-window self)
  19. >    (#_textmode #$patCopy)
  20. >    (with-pstrs ((horizontal (format nil "~3d" (point-h where)))
  21. >                 (vertical (format nil "~3d" (point-v where))))
  22. >        (#_moveto 10 10)
  23. >        (#_drawstring horizontal)
  24. >        (#_moveto 10 40)
  25. >        (#_drawstring vertical)))
  26. >  *arrow-cursor*   ;return the arrow cursor
  27. >  )
  28. >
  29. >My Question:  Is this the best way to do it (time-wise and
  30. >memory-wise)?  In particular, does this do some cons-ing that
  31. >will rapidly eat up memory while the mouse is over the view?
  32.  
  33. You're consing two 3-character strings each time your view-cursor
  34. method runs. (format nil ...) conses a string. You'd do better to
  35. FORMAT directly to the window:
  36.  
  37. (defmethod view-cursor ((self my-special-view-class) where)
  38.   (let ((window (view-window self)))
  39.     (with-focused-view window
  40.       (#_textmode #$patCopy)
  41.       (#_moveto 10 10)
  42.       (format window "~3d" (point-h where))
  43.       (#_moveto 10 40)
  44.       (format window "~3d" (point-v where))))
  45.   *arrow-cursor*   ;return the arrow cursor
  46.   )
  47.  
  48. Unfortunately, this still conses because MCL's FORMAT ~D code conses if
  49. you specify a MINCOL argument. Two choices: do the numeric conversion
  50. yourself or ask for my patch that eliminates the consing from MCL's
  51. FORMAT ~D code. The patch is called "less-format-consing-patch.lisp".
  52. (This has bothered me for a while. Thanx for giving me the impetus to
  53. spend an hour fixing it) 
  54.