[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text wrap in scrolling f

        Reply to:   RE>text wrap in scrolling fred
> Does anyone know how to get a scrolling fred dialog item to wrap properly
> that it doesn't break in the middle of a word. 

Here is a small hack i did for a project I worked on some time ago. The
behaviour is a bit buggy (sometimes a space is scrolled to the beginning of the
next line) and there is no possibility to "reformat" a paragraph within the
boundaries. I have no time to improve the code at this moment. If you do,
please let me know.

> Thanks in advance.
You're welcome,


;               WORDSCROLL-FRED-ITEM
; author: Andre Koehorst
;         Research Instutute for Knowledge Systems
;         andre@riks.nl
; status: hack 
; bugs:   Sometimes a #\space character is srolled
          to the next line.
;         Words are only scrolled when you type a
;         character beyond the boundary. If you insert
;         chars before that, words are happy to move beyond
;         the boundary.

(defclass wordscroll-fred-item (fred-dialog-item)
   (scroll-position :initarg :scroll-position :initform 36 :accessor
scroll-position :documentation 
"Scrolls to the next line when a character is typed that is
beyond scroll-position. If the character is tped within a word, the word is
to the next line and the cursor is positioned after that word.")

(defmethod view-key-event-handler :around ((item  wordscroll-fred-item) char)
;;;   (format t "~a ~a" (char-code char) (char-name char))
  (if (> (buffer-column (fred-buffer item))(scroll-position item))
     ((< (char-code char) 32)  ; All control characters
     ((= (char-code char) 32)  ; #\Space
      ; Scroll to the next line
      (ed-open-line item)
      (ed-next-line item)
     ((> (char-code char) 32)  ; All printable characters?
      ;Scroll the word to the next line
      (ed-backward-word item)
      (ed-open-line item)
      (ed-next-line item)
      (ed-end-of-line item)