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

Robert Strandh strandh at labri.fr
Thu Mar 10 05:13:43 UTC 2005


Robert Strandh writes:
 > 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. 

Hold on a sec...

Having select-and-paste implemented over output records seems
backward.  Only the application-specific code knows how to represent a
selection, what objects are to be transmitted to another application,
and how these objects should be structured.

I am willing to admit that there could be some reasonable default
based on output records, but that default may not be adapted to
Climacs.

-- 
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