diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 43 | ||||
-rw-r--r-- | src/dispextern.h | 8 | ||||
-rw-r--r-- | src/dispnew.c | 4 | ||||
-rw-r--r-- | src/dosfns.c | 18 | ||||
-rw-r--r-- | src/msdos.c | 8 | ||||
-rw-r--r-- | src/term.c | 14 | ||||
-rw-r--r-- | src/xfaces.c | 82 |
7 files changed, 148 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index df9ad9937c5..97ffe12775e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,46 @@ +1999-12-15 Eli Zaretskii <eliz@is.elta.co.il> + + * dispextern.h (FACE_TTY_DEFAULT_FG_COLOR) + (FACE_TTY_DEFAULT_BG_COLOR): New macros. + + * xfaces.c (Qunspecified_fg, Qunspecified_bg): New variables. + (syms_of_xfaces): Initialize and staticpro them. + (tty_defined_color): If the color name is unspecified-fg or + unspecified-bg, return FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR, respectively, as the pixel value. + (tty_color_name): If the color pixel value is either + FACE_TTY_DEFAULT_FG_COLOR or FACE_TTY_DEFAULT_BG_COLOR, return + Qunspecified_fg or Qunspecified_bg, respectively. + (Finternal_set_lisp_face_attribute): Allow values Qunspecified_fg + and Qunspecified_bg for foreground and background colors. + (realize_default_face): If the foreground and background colors + are not specified, default to Qunspecified_fg and Qunspecified_bg. + (realize_tty_face): By default, set the face colors to + FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR. + [MSDOS]: Handle FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR when face colors are not defined. + Reverse the colors if the default colors were reversed. + + * dispnew.c (init_display): Initialize the frame pixels of the + initial frame to FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR. + + * term.c (turn_on_face): If the default fore- and background + colors are reversed, enter inverse video mode. Don't send color + escape sequences for unspecified foreground and background colors. + (turn_off_face): Handle unspecified-fg and unspecified-bg colors. + + * dosfns.c (unspecified_colors): New variable. + (msdos_stdcolor_idx): Handle unspecified-fg and unspecified-bg + color names, return FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR, respectively. + (msdos_stdcolor_name): Handle FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR, return Qunspecified_fg and + Qunspecified_bg, respectively. + + * msdos.c (IT_set_face): Support FACE_TTY_DEFAULT_FG_COLOR and + FACE_TTY_DEFAULT_BG_COLOR as pixel values. + 1999-12-15 Kenichi Handa <handa@etl.go.jp> * coding.c (code_convert_region): Fix the secoding arg to diff --git a/src/dispextern.h b/src/dispextern.h index edd9a7c97be..eadf745d400 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1268,6 +1268,14 @@ struct face #define FACE_TTY_DEFAULT_COLOR ((unsigned long) -1) +/* Color index indicating that face uses an unknown foreground color. */ + +#define FACE_TTY_DEFAULT_FG_COLOR ((unsigned long) -2) + +/* Color index indicating that face uses an unsigned background color. */ + +#define FACE_TTY_DEFAULT_BG_COLOR ((unsigned long) -3) + /* Non-zero if FACE was realized for unibyte use. */ #define FACE_UNIBYTE_P(FACE) ((FACE)->charset < 0) diff --git a/src/dispnew.c b/src/dispnew.c index 8ce4e419565..930e7a793d4 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5925,8 +5925,8 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ are the foreground and background colors of the terminal. */ struct frame *sf = SELECTED_FRAME(); - FRAME_FOREGROUND_PIXEL (sf) = -1; - FRAME_BACKGROUND_PIXEL (sf) = -1; + FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR; + FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR; call0 (intern ("tty-set-up-initial-frame-faces")); } } diff --git a/src/dosfns.c b/src/dosfns.c index 857d16bd9b2..feb9080b7c7 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -409,6 +409,10 @@ static char *vga_colors[16] = { "lightred", "lightmagenta", "yellow", "white" }; +static char *unspecified_colors[] = { + "unspecified-fg", "unspecified-bg", "unspecified" +}; + /* Given a color name, return its index, or -1 if not found. Note that this only performs case-insensitive comparison against the standard names. For anything more sophisticated, like matching @@ -424,17 +428,25 @@ msdos_stdcolor_idx (const char *name) if (strcasecmp (name, vga_colors[i]) == 0) return i; - return FACE_TTY_DEFAULT_COLOR; + return + strcmp (name, unspecified_colors[0]) == 0 ? FACE_TTY_DEFAULT_FG_COLOR + : strcmp (name, unspecified_colors[1]) == 0 ? FACE_TTY_DEFAULT_BG_COLOR + : FACE_TTY_DEFAULT_COLOR; } /* Given a color index, return its standard name. */ Lisp_Object msdos_stdcolor_name (int idx) { - extern Lisp_Object Qunspecified; + extern Lisp_Object Qunspecified, Qunspecified_fg, Qunspecified_bg; if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0])) - return Qunspecified; /* meaning the default */ + { + return + idx == FACE_TTY_DEFAULT_FG_COLOR ? Qunspecified_fg + : idx == FACE_TTY_DEFAULT_BG_COLOR ? Qunspecified_bg + : Qunspecified; /* meaning the default */ + } return build_string (vga_colors[idx]); } diff --git a/src/msdos.c b/src/msdos.c index 450d1273c02..1856b6ed656 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -685,12 +685,16 @@ IT_set_face (int face) all 16 colors to be available for the background, since Emacs switches on this mode (and loses the blinking attribute) at startup. */ - if (fg == (unsigned long)-1) + if (fg == FACE_TTY_DEFAULT_COLOR || fg == FACE_TTY_DEFAULT_FG_COLOR) fg = highlight || fp->tty_reverse_p ? FRAME_BACKGROUND_PIXEL (sf) : FRAME_FOREGROUND_PIXEL (sf); - if (bg == (unsigned long)-1) + else if (fg == FACE_TTY_DEFAULT_BG_COLOR) + fg = highlight ? FRAME_FOREGROUND_PIXEL (sf) : FRAME_BACKGROUND_PIXEL (sf); + if (bg == FACE_TTY_DEFAULT_COLOR || fg == FACE_TTY_DEFAULT_BG_COLOR) bg = highlight || fp->tty_reverse_p ? FRAME_FOREGROUND_PIXEL (sf) : FRAME_BACKGROUND_PIXEL (sf); + else if (bg == FACE_TTY_DEFAULT_FG_COLOR) + fg = highlight ? FRAME_BACKGROUND_PIXEL (sf) : FRAME_FOREGROUND_PIXEL (sf); if (termscript) fprintf (termscript, "<FACE %d%s: %d/%d>", face, highlight ? "H" : "", fp->foreground, fp->background); diff --git a/src/term.c b/src/term.c index 7900643dfdc..04f7a64866d 100644 --- a/src/term.c +++ b/src/term.c @@ -1959,7 +1959,9 @@ turn_on_face (f, face_id) && TN_magic_cookie_glitch_ul <= 0) OUTPUT1_IF (TS_enter_underline_mode); - if (face->tty_reverse_p) + if (face->tty_reverse_p + || face->foreground == FACE_TTY_DEFAULT_BG_COLOR + || face->background == FACE_TTY_DEFAULT_FG_COLOR) OUTPUT1_IF (TS_enter_reverse_mode); if (TN_max_colors > 0) @@ -1967,6 +1969,8 @@ turn_on_face (f, face_id) char *p; if (face->foreground != FACE_TTY_DEFAULT_COLOR + && face->foreground != FACE_TTY_DEFAULT_FG_COLOR + && face->foreground != FACE_TTY_DEFAULT_BG_COLOR && TS_set_foreground) { p = tparam (TS_set_foreground, NULL, 0, (int) face->foreground); @@ -1975,6 +1979,8 @@ turn_on_face (f, face_id) } if (face->background != FACE_TTY_DEFAULT_COLOR + && face->background != FACE_TTY_DEFAULT_BG_COLOR + && face->background != FACE_TTY_DEFAULT_FG_COLOR && TS_set_background) { p = tparam (TS_set_background, NULL, 0, (int) face->background); @@ -2027,8 +2033,10 @@ turn_off_face (f, face_id) /* Switch back to default colors. */ if (TN_max_colors > 0 - && (face->foreground != FACE_TTY_DEFAULT_COLOR - || face->background != FACE_TTY_DEFAULT_COLOR)) + && ((face->foreground != FACE_TTY_DEFAULT_COLOR + && face->foreground != FACE_TTY_DEFAULT_FG_COLOR) + || (face->background != FACE_TTY_DEFAULT_COLOR + && face->background != FACE_TTY_DEFAULT_BG_COLOR))) OUTPUT1_IF (TS_orig_pair); } diff --git a/src/xfaces.c b/src/xfaces.c index 5fdb881bfc0..dd51df034ac 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -282,7 +282,7 @@ Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded; Lisp_Object Qultra_expanded; Lisp_Object Qreleased_button, Qpressed_button; Lisp_Object QCstyle, QCcolor, QCline_width; -Lisp_Object Qunspecified; +Lisp_Object Qunspecified, Qunspecified_fg, Qunspecified_bg; /* The symbol `x-charset-registry'. This property of charsets defines the X registry and encoding that fonts should have that are used to @@ -1108,6 +1108,14 @@ tty_defined_color (f, color_name, color_def, alloc) load color" messages in the *Messages* buffer. */ status = 1; } + if (color_idx == FACE_TTY_DEFAULT_COLOR && *color_name) + { + if (strcmp (color_name, "unspecified-fg") == 0) + color_idx = FACE_TTY_DEFAULT_FG_COLOR; + else if (strcmp (color_name, "unspecified-bg") == 0) + color_idx = FACE_TTY_DEFAULT_BG_COLOR; + } + color_def->pixel = (unsigned long) color_idx; color_def->red = red; color_def->green = green; @@ -1179,7 +1187,10 @@ tty_color_name (f, idx) by index using the default color mapping on a Windows console. */ #endif - return Qunspecified; + return + idx == FACE_TTY_DEFAULT_FG_COLOR ? Qunspecified_fg + : idx == FACE_TTY_DEFAULT_BG_COLOR ? Qunspecified_bg + : Qunspecified; } /* Return non-zero if COLOR_NAME is a shade of gray (or white or @@ -3427,7 +3438,8 @@ frame.") } else if (EQ (attr, QCforeground)) { - if (!UNSPECIFIEDP (value)) + if (!UNSPECIFIEDP (value) + && !EQ (value, Qunspecified_fg) && !EQ (value, Qunspecified_bg)) { /* Don't check for valid color names here because it depends on the frame (display) whether the color will be valid @@ -3441,7 +3453,8 @@ frame.") } else if (EQ (attr, QCbackground)) { - if (!UNSPECIFIEDP (value)) + if (!UNSPECIFIEDP (value) + && !EQ (value, Qunspecified_bg) && !EQ (value, Qunspecified_fg)) { /* Don't check for valid color names here because it depends on the frame (display) whether the color will be valid @@ -5686,7 +5699,9 @@ realize_default_face (f) LFACE_FOREGROUND (lface) = XCDR (color); else if (FRAME_X_P (f)) return 0; - else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) + else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) + LFACE_FOREGROUND (lface) = Qunspecified_fg; + else abort (); } @@ -5699,7 +5714,9 @@ realize_default_face (f) LFACE_BACKGROUND (lface) = XCDR (color); else if (FRAME_X_P (f)) return 0; - else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) + else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) + LFACE_BACKGROUND (lface) = Qunspecified_bg; + else abort (); } @@ -6072,7 +6089,8 @@ realize_tty_face (c, attrs, charset) face->tty_reverse_p = 1; /* Map color names to color indices. */ - face->foreground = face->background = FACE_TTY_DEFAULT_COLOR; + face->foreground = FACE_TTY_DEFAULT_FG_COLOR; + face->background = FACE_TTY_DEFAULT_BG_COLOR; color = attrs[LFACE_FOREGROUND_INDEX]; if (STRINGP (color) @@ -6084,7 +6102,7 @@ realize_tty_face (c, attrs, charset) (NAME INDEX R G B). We need the INDEX part. */ face->foreground = XINT (XCAR (XCDR (color))); - if (face->foreground == FACE_TTY_DEFAULT_COLOR + if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR && STRINGP (attrs[LFACE_FOREGROUND_INDEX])) { face->foreground = load_color (c->f, face, @@ -6093,12 +6111,23 @@ realize_tty_face (c, attrs, charset) #ifdef MSDOS /* If the foreground of the default face is the default color, use the foreground color defined by the frame. */ - if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR) + if (FRAME_MSDOS_P (c->f)) { - face->foreground = FRAME_FOREGROUND_PIXEL (f); - attrs[LFACE_FOREGROUND_INDEX] = - msdos_stdcolor_name (face->foreground); - face_colors_defaulted = 1; + if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR + || face->foreground == FACE_TTY_DEFAULT_COLOR) + { + face->foreground = FRAME_FOREGROUND_PIXEL (f); + attrs[LFACE_FOREGROUND_INDEX] = + msdos_stdcolor_name (face->foreground); + face_colors_defaulted = 1; + } + else if (face->foreground == FACE_TTY_DEFAULT_BG_COLOR) + { + face->foreground = FRAME_BACKGROUND_PIXEL (f); + attrs[LFACE_FOREGROUND_INDEX] = + msdos_stdcolor_name (face->foreground); + face_colors_defaulted = 1; + } } #endif } @@ -6113,7 +6142,7 @@ realize_tty_face (c, attrs, charset) (NAME INDEX R G B). We need the INDEX part. */ face->background = XINT (XCAR (XCDR (color))); - if (face->background == FACE_TTY_DEFAULT_COLOR + if (face->background == FACE_TTY_DEFAULT_BG_COLOR && STRINGP (attrs[LFACE_BACKGROUND_INDEX])) { face->background = load_color (c->f, face, @@ -6122,12 +6151,23 @@ realize_tty_face (c, attrs, charset) #ifdef MSDOS /* If the background of the default face is the default color, use the background color defined by the frame. */ - if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR) + if (FRAME_MSDOS_P (c->f)) { - face->background = FRAME_BACKGROUND_PIXEL (f); - attrs[LFACE_BACKGROUND_INDEX] = - msdos_stdcolor_name (face->background); - face_colors_defaulted = 1; + if (face->background == FACE_TTY_DEFAULT_BG_COLOR + || face->background == FACE_TTY_DEFAULT_COLOR) + { + face->background = FRAME_BACKGROUND_PIXEL (f); + attrs[LFACE_BACKGROUND_INDEX] = + msdos_stdcolor_name (face->background); + face_colors_defaulted = 1; + } + else if (face->background == FACE_TTY_DEFAULT_FG_COLOR) + { + face->background = FRAME_FOREGROUND_PIXEL (f); + attrs[LFACE_BACKGROUND_INDEX] = + msdos_stdcolor_name (face->background); + face_colors_defaulted = 1; + } } #endif } @@ -6611,6 +6651,10 @@ syms_of_xfaces () staticpro (&Qforeground_color); Qunspecified = intern ("unspecified"); staticpro (&Qunspecified); + Qunspecified_fg = intern ("unspecified-fg"); + staticpro (&Qunspecified_fg); + Qunspecified_bg = intern ("unspecified-bg"); + staticpro (&Qunspecified_bg); Qx_charset_registry = intern ("x-charset-registry"); staticpro (&Qx_charset_registry); |