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

Christophe Rhodes csr21 at cam.ac.uk
Mon Mar 7 17:26:52 UTC 2005


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.

Cheers,

Christophe



More information about the climacs-devel mailing list