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

Color Text on CAD Buffer II



    Date: Sat, 29 Sep 90 10:12 EDT
    From: pan@Athena.Pangaro.Dialnet.Symbolics.Com (Paul Pangaro)

    It seems like a simple request: I want to output lines of text in different colors,
    depending on their importance to the user: red for critical, yellow for important, etc.

    However the color documentation is a maze of non-indexed, elliptical stuff about ALUs,
    char-alus, sc-fill-alus and so forth. I have played around for half an hour but without
    seeming to get anywhere, and certainly not with colored text. If I had time, I too could 
    become expert at it, but instead I ask the experts: anyone have a simple way to do
    multi- or vary-colored text, without blowing away the usual background/foreground colors?
    Thanks.

A macro to wrap around you code, so that the printer produces the color
of your choice:

(defmacro MAYBE-WITH-COLOR-CHAR-ALUF (&optional alu (stream *standard-output*) &body body)
  `(if (and ,alu
	    (eq (send (send ,stream :screen) :video) :color))
       (let ((old-alu (send ,stream :char-aluf)))
	 (unwind-protect
	     (progn
	       (send ,stream :set-char-aluf ,alu)
	       ,@body)
	   (send ,stream :set-char-aluf old-alu)))
       ,@body))

(let ((active T) ;; your choice
      (screen (send *standard-output* :screen)))
  (maybe-with-color-char-aluf
    (if active ;; save the color alus for reuse
       (send screen :compute-color-alu tv:alu-seta 0 0 1) ;; blue
       (send screen :compute-color-alu tv:alu-seta 1 0 0)) ;; red
    window
    (format *standard-output* "~&Test text in ~Aactive color" (if active "" "in"))))

It is probably a good idea to store ready-made color alus as properties
associated with your code. To make alus, it is probably easiest to use
the :compute-color-alu message; it is easy enough to get you colors by
blending red green and blue to taste.

Alternatively try using the graphics:draw-string function with an alu
argument or (for simple colors) the :color argument. Eg.
(graphics:draw-string "Test" x y :color :yellow)

<= p2