[climacs-devel] #\Space and #\Tab

Robert Strandh strandh at labri.fr
Tue Mar 8 05:45:15 UTC 2005


Christophe Rhodes writes:
 > Hi,
 > 
 > The act of not writing #\Space and #\Tab characters to climacs pane,
 > but instead adjusting the cursor position, has the side-effect of
 > breaking select-and-paste.  Would it be reasonable instead to
 > specialize stream-write-char and stream-write-string for climacs panes
 > to produce the right graphical output (by adjusting the cursor
 > position, as currently)?  I think that if it were done this way,
 > selection would "just work", as it's implemented over output records,
 > and there are :around methods for output-recording-streams which call
 > stream-add-character-output in the expected way.
 > 
 > In summary, something like [untested]
 > 
 >   (defmethod stream-write-char ((pane climacs-pane) char)
 >     (with-slots (space-width tab-width) pane
 >       (case char
 >         ((#\Space) (stream-increment-cursor-position pane space-width 0))
 >         ((#\Tab) (let ((x (stream-cursor-position pane)))
 >                    (stream-increment-cursor-position
 >                     pane (- tab-width (mod x tab-width)) 0)))
 >         (t (call-next-method)))))
 >   (defmethod stream-write-string ((pane climacs-pane) string)
 >     (let ((pos (position-if (lambda (c) (member c '(#\Space #\Tab))) string)))
 >       (cond
 >         (pos
 >          (stream-write-char pane (subseq string 0 pos))
 >          (stream-write-char pane (char string pos))
 >          (stream-write-string pane (subseq string (1+ pos))))
 >         (t (call-next-method)))))
 >         
 > and using write-char in climacs' DISPLAY-LINE and friends, should make
 > text selections work as expected.

Sure, if such an easy fix makes text selection work, I am in favor. 

However, the idea of not using write-char on whitespace was to avoid
having the output record there, which slows down incremental
redisplay.  If it is essential that the output record be present, we
must probably urgently find someone to speed up McCLIM incremental
redisplay.

-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------



More information about the climacs-devel mailing list