* src/termhooks.h (defined_color_hook): New terminal hook.
* src/xterm.c:
* src/nsterm.m:
* src/term.c:
* src/w32term.c: Set defined_color_hook.
* src/xfaces.c: Use defined_color_hook.
(defined_color): Remove.
* src/image.c: Remove redefinitions of x_defined_color, and use
defined_color_hook.
void update_face_from_frame_parameter (struct frame *, Lisp_Object,
Lisp_Object);
+extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool,
+ bool);
+
Lisp_Object tty_color_name (struct frame *, int);
void clear_face_cache (bool);
unsigned long load_color (struct frame *, struct face *, Lisp_Object,
#define PIX_MASK_RETAIN 0
#define PIX_MASK_DRAW 1
-#define x_defined_color w32_defined_color
-
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
#define PIX_MASK_RETAIN 0
-#define x_defined_color(f, name, color_def, alloc) \
- ns_defined_color (f, name, color_def, alloc, 0)
#endif /* HAVE_NS */
#if (defined HAVE_X_WINDOWS \
eassert (STRINGP (color_name));
- if (x_defined_color (f, SSDATA (color_name), &color, 1)
+ if (FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (color_name),
+ &color,
+ true,
+ false)
&& img->ncolors < min (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *img->colors,
INT_MAX))
{
{
if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
color_val = Qt;
- else if (x_defined_color (f, SSDATA (XCDR (specified_color)),
- &cdef, 0))
+ else if (FRAME_TERMINAL (f)->defined_color_hook
+ (f, SSDATA (XCDR (specified_color)), &cdef, false, false))
color_val = make_fixnum (cdef.pixel);
}
}
{
if (xstrcasecmp (max_color, "None") == 0)
color_val = Qt;
- else if (x_defined_color (f, max_color, &cdef, 0))
+ else if (FRAME_TERMINAL (f)->defined_color_hook
+ (f, max_color, &cdef, false, false))
color_val = make_fixnum (cdef.pixel);
}
if (!NILP (color_val))
#ifdef USE_CAIRO
if (! fmt[PBM_FOREGROUND].count
|| ! STRINGP (fmt[PBM_FOREGROUND].value)
- || ! x_defined_color (f, SSDATA (fmt[PBM_FOREGROUND].value), &xfg, 0))
+ || ! FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (fmt[PBM_FOREGROUND].value),
+ &xfg,
+ false,
+ false))
{
xfg.pixel = fg;
x_query_colors (f, &xfg, 1);
if (! fmt[PBM_BACKGROUND].count
|| ! STRINGP (fmt[PBM_BACKGROUND].value)
- || ! x_defined_color (f, SSDATA (fmt[PBM_BACKGROUND].value), &xbg, 0))
+ || ! FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (fmt[PBM_BACKGROUND].value),
+ &xbg,
+ false,
+ false))
{
xbg.pixel = bg;
x_query_colors (f, &xbg, 1);
current frame background, ignoring any default background
color set by the image. */
if (STRINGP (specified_bg)
- ? x_defined_color (f, SSDATA (specified_bg), &color, false)
+ ? FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (specified_bg),
+ &color,
+ false,
+ false)
: (image_query_frame_background_color (f, &color), true))
/* The user specified `:background', use that. */
{
if (STRINGP (specified_bg))
{
XColor color;
- if (x_defined_color (f, SSDATA (specified_bg), &color, 0))
+ if (FRAME_TERMINAL (f)->defined_color_hook
+ (f, SSDATA (specified_bg), &color, false, false))
{
uint32_t *dataptr = data32;
int r = color.red/256;
specified_bg = image_spec_value (img->spec, QCbackground, NULL);
if (!STRINGP (specified_bg)
- || !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0))
+ || !FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (specified_bg),
+ &bgcolor,
+ false,
+ false))
image_query_frame_background_color (f, &bgcolor);
bg_wand = NewPixelWand ();
XColor background;
Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
if (!STRINGP (specified_bg)
- || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
+ || !FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (specified_bg),
+ &background,
+ false,
+ false))
image_query_frame_background_color (f, &background);
/* SVG pixmaps specify transparency in the last byte, so right
terminal->update_end_hook = ns_update_end;
terminal->read_socket_hook = ns_read_socket;
terminal->frame_up_to_date_hook = ns_frame_up_to_date;
+ terminal->defined_color_hook = ns_defined_color;
terminal->mouse_position_hook = ns_mouse_position;
terminal->get_focus_frame = ns_get_focus_frame;
terminal->focus_frame_hook = ns_focus_frame;
terminal->update_begin_hook = 0;
terminal->update_end_hook = 0;
terminal->set_terminal_window_hook = 0;
+ terminal->defined_color_hook = 0;
terminal->mouse_position_hook = 0;
terminal->frame_rehighlight_hook = 0;
terminal->frame_raise_lower_hook = 0;
terminal->menu_show_hook = &tty_menu_show;
#endif
terminal->set_terminal_window_hook = &tty_set_terminal_window;
+ terminal->defined_color_hook = &tty_defined_color; /* xfaces.c */
terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
terminal->delete_frame_hook = &tty_free_frame_resources;
terminal->delete_terminal_hook = &delete_tty;
/* Miscellanea. */
#include "lisp.h"
+#include "dispextern.h"
#include "systime.h" /* for Time */
struct glyph;
void (*update_end_hook) (struct frame *);
void (*set_terminal_window_hook) (struct frame *, int);
+ /* Decide if color named COLOR_NAME is valid for the display
+ associated with the frame F; if so, return the RGB values in
+ COLOR_DEF. If ALLOC (and MAKEINDEX for NS), allocate a new
+ colormap cell.
+
+ If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */
+ bool (*defined_color_hook) (struct frame *f, const char *color_name,
+ XColor *color_def,
+ bool alloc,
+ bool makeIndex);
+
/* Multi-frame and mouse support hooks. */
/* Graphical window systems are expected to define all of the
the selected frame; if so, return the rgb values in COLOR_DEF.
If ALLOC is nonzero, allocate a new colormap cell. */
-int
+bool
w32_defined_color (struct frame *f, const char *color, XColor *color_def,
- bool alloc_p)
+ bool alloc_p, bool _makeIndex)
{
register Lisp_Object tem;
COLORREF w32_color_ref;
/* w32_defined_color is responsible for coping with failures
by looking for a near-miss. */
- if (w32_defined_color (f, SSDATA (arg), &cdef, true))
+ if (w32_defined_color (f, SSDATA (arg), &cdef, true, false))
return cdef.pixel;
/* defined_color failed; return an ultimate default. */
CHECK_STRING (color);
- if (w32_defined_color (f, SSDATA (color), &foo, false))
+ if (w32_defined_color (f, SSDATA (color), &foo, false, false))
return Qt;
else
return Qnil;
CHECK_STRING (color);
- if (w32_defined_color (f, SSDATA (color), &foo, false))
+ if (w32_defined_color (f, SSDATA (color), &foo, false, false))
return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel),
(GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel),
(GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel));
terminal->update_end_hook = w32_update_end;
terminal->read_socket_hook = w32_read_socket;
terminal->frame_up_to_date_hook = w32_frame_up_to_date;
+ terminal->defined_color_hook = w32_defined_color;
terminal->query_colors = w32_query_colors;
terminal->mouse_position_hook = w32_mouse_position;
terminal->get_focus_frame = w32_get_focus_frame;
/* initialize palette with white and black */
{
XColor color;
- w32_defined_color (0, "white", &color, 1);
- w32_defined_color (0, "black", &color, 1);
+ w32_defined_color (0, "white", &color, true, false);
+ w32_defined_color (0, "black", &color, true, false);
}
#ifdef WINDOWSNT
extern struct w32_display_info *w32_term_init (Lisp_Object,
char *, char *);
-extern int w32_defined_color (struct frame *f, const char *color,
- XColor *color_def, bool alloc_p);
+extern bool w32_defined_color (struct frame *, const char *, XColor *,
+ bool, bool);
extern int w32_display_pixel_height (struct w32_display_info *);
extern int w32_display_pixel_width (struct w32_display_info *);
extern void initialize_frame_menubar (struct frame *);
return false;
}
-/* A version of defined_color for non-X frames. */
+/* An implementation of defined_color_hook for tty frames. */
-static bool
+bool
tty_defined_color (struct frame *f, const char *color_name,
- XColor *color_def, bool alloc)
+ XColor *color_def, bool alloc, bool _makeIndex)
{
bool status = true;
return status;
}
-
-/* Decide if color named COLOR_NAME is valid for the display
- associated with the frame F; if so, return the rgb values in
- COLOR_DEF. If ALLOC, allocate a new colormap cell.
-
- This does the right thing for any type of frame. */
-
-static bool
-defined_color (struct frame *f, const char *color_name, XColor *color_def,
- bool alloc)
-{
- if (!FRAME_WINDOW_P (f))
- return tty_defined_color (f, color_name, color_def, alloc);
-#ifdef HAVE_X_WINDOWS
- else if (FRAME_X_P (f))
- return x_defined_color (f, color_name, color_def, alloc);
-#endif
-#ifdef HAVE_NTGUI
- else if (FRAME_W32_P (f))
- return w32_defined_color (f, color_name, color_def, alloc);
-#endif
-#ifdef HAVE_NS
- else if (FRAME_NS_P (f))
- return ns_defined_color (f, color_name, color_def, alloc, true);
-#endif
- else
- emacs_abort ();
-}
-
-
/* Given the index IDX of a tty color on frame F, return its name, a
Lisp string. */
XColor color;
bool gray_p;
- if (defined_color (f, color_name, &color, false))
+ if (FRAME_TERMINAL (f)->defined_color_hook
+ (f, color_name, &color, false, true))
gray_p = (/* Any color sufficiently close to black counts as gray. */
(color.red < 5000 && color.green < 5000 && color.blue < 5000)
||
&& face_color_gray_p (f, color_name)))
:
#endif
- tty_defined_color (f, color_name, ¬_used, false);
+ tty_defined_color (f, color_name, ¬_used, false, false);
}
|| target_index == LFACE_STRIKE_THROUGH_INDEX
|| target_index == LFACE_BOX_INDEX);
- /* if the color map is full, defined_color will return a best match
+ /* if the color map is full, defined_color_hook will return a best match
to the values in an existing cell. */
- if (!defined_color (f, SSDATA (name), color, true))
+ if (!FRAME_TERMINAL (f)->defined_color_hook
+ (f, SSDATA (name), color, true, true))
{
add_to_log ("Unable to load color \"%s\"", name);
if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
&& !(STRINGP (color1)
- && defined_color (f, SSDATA (color1), &cdef1, false)))
+ && FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (color1),
+ &cdef1,
+ false,
+ true)))
signal_error ("Invalid color", color1);
if (!(CONSP (color2) && parse_rgb_list (color2, &cdef2))
&& !(STRINGP (color2)
- && defined_color (f, SSDATA (color2), &cdef2, false)))
+ && FRAME_TERMINAL (f)->defined_color_hook (f,
+ SSDATA (color2),
+ &cdef2,
+ false,
+ true)))
signal_error ("Invalid color", color2);
if (NILP (metric))
bool
x_defined_color (struct frame *f, const char *color_name,
- XColor *color, bool alloc_p)
+ XColor *color, bool alloc_p, bool _makeIndex)
{
bool success_p = false;
Colormap cmap = FRAME_X_COLORMAP (f);
/* x_defined_color is responsible for coping with failures
by looking for a near-miss. */
- if (x_defined_color (f, SSDATA (color_name), &cdef, true))
+ if (x_defined_color (f, SSDATA (color_name), &cdef, true, false))
return cdef.pixel;
signal_error ("Undefined color", color_name);
CHECK_STRING (color);
- if (x_defined_color (f, SSDATA (color), &foo, false))
+ if (x_defined_color (f, SSDATA (color), &foo, false, false))
return Qt;
else
return Qnil;
CHECK_STRING (color);
- if (x_defined_color (f, SSDATA (color), &foo, false))
+ if (x_defined_color (f, SSDATA (color), &foo, false, false))
return list3i (foo.red, foo.green, foo.blue);
else
return Qnil;
terminal->read_socket_hook = XTread_socket;
terminal->frame_up_to_date_hook = XTframe_up_to_date;
terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook;
+ terminal->defined_color_hook = x_defined_color;
terminal->query_colors = x_query_colors;
terminal->mouse_position_hook = XTmouse_position;
terminal->get_focus_frame = x_get_focus_frame;
extern void xic_set_preeditarea (struct window *, int, int);
extern void xic_set_statusarea (struct frame *);
extern void xic_set_xfontset (struct frame *, const char *);
-extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
+extern bool x_defined_color (struct frame *, const char *, XColor *, bool, bool);
#ifdef HAVE_X_I18N
extern void free_frame_xic (struct frame *);
# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT