🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87837

getting RGB values from the X server for ps-print.el

#87837
From: Kevin Rodgers
Date: Fri, 26 Aug 1994 19:45
75 lines
3208 bytes
I am working with Jim Thompson <thompson@wg2.waii.com>, the author of
ps-print.el, to add support for printing buffers that have text in
varying foreground and background colors.  Since PostScript and X both
use the RGB color model, it should be simple to generate PostScript that
uses the foreground and background colors from overlay and text property
faces; unfortunately, there's no way to get the RGB values for a color
name in Emacs Lisp currently.

The simplest scheme I've come up with is to modify the predicate
`x-color-defined-p' to return the RGB values (as a vector) instead of
the symbol `t' to indicate success.  Here's a patch to illustrate:

WARNING: I've never written a line of X code in my life, I'm not
familiar with garbage collection issues in Emacs C, and the following
patch is completely untested -- I haven't even tried to compile it.

Fri Aug 26 1994 16:35:06  Kevin Rodgers <kevinr@ihs.com>

	* xfns.c (Fx_color_defined_p): Return the vector of RGB values,
	instead of the symbol t.

===================================================================
RCS file: RCS/xfns.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** 1.1	1994/06/09 16:09:43
--- 1.2	1994/08/26 16:35:06
***************
*** 2871,2877 ****
  
  
  DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0,
!   "Return t if the current X display supports the color named COLOR.")
    (color)
       Lisp_Object color;
  {
--- 2871,2877 ----
  
  
  DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0,
!   "Return a vector of RGB values if the X display supports the color named COLOR.")
    (color)
       Lisp_Object color;
  {
***************
*** 2881,2887 ****
    CHECK_STRING (color, 0);
  
    if (defined_color (XSTRING (color)->data, &foo))
!     return Qt;
    else
      return Qnil;
  }
--- 2881,2894 ----
    CHECK_STRING (color, 0);
  
    if (defined_color (XSTRING (color)->data, &foo))
!     {
!       Lisp_Object rgb[3];
! 
!       rgb[0] = make_number(foo.red);
!       rgb[1] = make_number(foo.green);
!       rgb[2] = make_number(foo.blue);
!       return Fvector(3, rgb);
!     }
    else
      return Qnil;
  }
-- 
Kevin Rodgers <kevinr@ihs.com>		Project Engineer
Information Handling Services		Electronic Systems Development
15 Inverness Way East, M/S A203		
Englewood CO 80112 USA			(303) 397-2807[voice]/-2620[fax]
Technical Details
Message-ID: <9408261935.AA18615@airedale.ihsyp>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!cs.utexas.edu!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!airedale.ai.mit.EDU!kevinr

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,9b8ea3307cd86d87,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-08-26 20:49:38 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!cs.utexas.edu!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!airedale.ai.mit.EDU!kevinr
From: kevinr@airedale.ai.mit.EDU (Kevin Rodgers)
Newsgroups: gnu.emacs.bug
Subject: getting RGB values from the X server for ps-print.el
Date: 26 Aug 1994 15:45:53 -0400
Organization: GNUs Not Usenet
Lines: 75
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9408261935.AA18615@airedale.ihsyp>
Reply-To: Kevin Rodgers <kevinr@ihs.com>