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

Re: string with style



This will get you started. Currently the style parts of the following
code are unused, but converting them to use styles should be easy.
I suggest reading Chapter 12 and the section on using Multiple Fonts
within a fred-mixin.

  -- Luke


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; display prints string using style starting with col.  If the optional
;; parameter add-newline is t, a newline is added to the printed output.
;;
;; It returns a list of two numbers - the range of the printed text within the 
;; buffer of the calling window.
;;
;; need five styles  
;;   1 - normal output  (normal)
;;   2 - keywords       (bold)
;;   3 - variables      (normal)
;;   4 - constants      (normal)
;;   5 - goals          (outline)
;;
;; style currently unused?  italic, or number 3
;;
(defparameter *normal-style*   1)
(defparameter *keyword-style*  1)
(defparameter *variable-style* 1)
(defparameter *constant-style* 1)   
(defparameter *goal-style*     4)


(defmethod display ((self fred-mixin) 
                        col style string 
                        &key (add-newline nil))
  (declare (ignore style))
  (when col
    ;tab over to the number of spaces specified by col
    (format self "~v,0T" col))
  
  ;; need to change the font information here
  ;;
  (let ((start-pos (buffer-position (fred-buffer self))))
    (princ string self)
    (when add-newline
      (terpri self))
    (fred-update self)
    (values
     (if (string-equal string "")
       (list (buffer-position (fred-buffer self))
             (buffer-position (fred-buffer self)))
       (list start-pos
             (if (char= #\newline
                        (buffer-char (fred-buffer self)
                                     (1- (buffer-position
                                          (fred-buffer self)))))
               (1- (buffer-position (fred-buffer self)))
               (buffer-position (fred-buffer self))))))))