diff options
| author | Eli Zaretskii | 2010-07-03 17:36:18 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-07-03 17:36:18 +0300 |
| commit | 76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08 (patch) | |
| tree | b7f8eae2b189a6335f0b0c0b6b307d9d8b65c112 /src/msdos.c | |
| parent | 1e6255ae888ffbee3a713c7d7fb41b8d6480ddb4 (diff) | |
| download | emacs-76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08.tar.gz emacs-76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08.zip | |
Fix setting colors on MS-DOS frames.
msdos.c (IT_set_frame_parameters): Fix setting of colors in
frames other than the initial one. Fix reversal of colors when
`reverse' is specified in the frame parameters. Call
update_face_from_frame_parameter instead of
internal-set-lisp-face-attribute. Initialize screen colors from
initial_screen_colors[] when f->default_face_done_p is zero,
instead of depending on being called with default-frame-alist as
the alist argument.
xfaces.c (update_face_from_frame_parameter): Move out of
HAVE_WINDOW_SYSTEM portion. Condition window-system only parts
with HAVE_WINDOW_SYSTEM.
Diffstat (limited to 'src/msdos.c')
| -rw-r--r-- | src/msdos.c | 97 |
1 files changed, 51 insertions, 46 deletions
diff --git a/src/msdos.c b/src/msdos.c index cca0b2e68b9..3e95978d58e 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -2092,11 +2092,9 @@ IT_set_frame_parameters (f, alist) | |||
| 2092 | = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); | 2092 | = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); |
| 2093 | /* Do we have to reverse the foreground and background colors? */ | 2093 | /* Do we have to reverse the foreground and background colors? */ |
| 2094 | int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); | 2094 | int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); |
| 2095 | int need_to_reverse, was_reverse = reverse; | ||
| 2096 | int redraw = 0, fg_set = 0, bg_set = 0; | 2095 | int redraw = 0, fg_set = 0, bg_set = 0; |
| 2097 | unsigned long orig_fg, orig_bg; | 2096 | unsigned long orig_fg, orig_bg; |
| 2098 | Lisp_Object frame_bg, frame_fg; | 2097 | Lisp_Object frame_bg, frame_fg; |
| 2099 | extern Lisp_Object Qdefault, QCforeground, QCbackground; | ||
| 2100 | struct tty_display_info *tty = FRAME_TTY (f); | 2098 | struct tty_display_info *tty = FRAME_TTY (f); |
| 2101 | extern Lisp_Object Qmenu_bar_lines; | 2099 | extern Lisp_Object Qmenu_bar_lines; |
| 2102 | extern Lisp_Object Vmenu_bar_mode; | 2100 | extern Lisp_Object Vmenu_bar_mode; |
| @@ -2105,24 +2103,16 @@ IT_set_frame_parameters (f, alist) | |||
| 2105 | 2103 | ||
| 2106 | /* If we are creating a new frame, begin with the original screen colors | 2104 | /* If we are creating a new frame, begin with the original screen colors |
| 2107 | used for the initial frame. */ | 2105 | used for the initial frame. */ |
| 2108 | if (EQ (alist, Vdefault_frame_alist) | 2106 | if (!f->default_face_done_p |
| 2109 | && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) | 2107 | && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) |
| 2110 | { | 2108 | { |
| 2111 | FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; | 2109 | FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; |
| 2112 | FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; | 2110 | FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; |
| 2113 | init_frame_faces (f); | 2111 | init_frame_faces (f); |
| 2112 | f->default_face_done_p = 1; | ||
| 2114 | } | 2113 | } |
| 2115 | orig_fg = FRAME_FOREGROUND_PIXEL (f); | 2114 | orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); |
| 2116 | orig_bg = FRAME_BACKGROUND_PIXEL (f); | 2115 | orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f); |
| 2117 | frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist)); | ||
| 2118 | frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist)); | ||
| 2119 | /* frame_fg and frame_bg could be nil if, for example, | ||
| 2120 | f->param_alist is nil, e.g. if we are called from | ||
| 2121 | Fmake_terminal_frame. */ | ||
| 2122 | if (NILP (frame_fg)) | ||
| 2123 | frame_fg = build_string (unspecified_fg); | ||
| 2124 | if (NILP (frame_bg)) | ||
| 2125 | frame_bg = build_string (unspecified_bg); | ||
| 2126 | 2116 | ||
| 2127 | /* Extract parm names and values into those vectors. */ | 2117 | /* Extract parm names and values into those vectors. */ |
| 2128 | i = 0; | 2118 | i = 0; |
| @@ -2152,58 +2142,75 @@ IT_set_frame_parameters (f, alist) | |||
| 2152 | menu_bar_lines_defined = 1; | 2142 | menu_bar_lines_defined = 1; |
| 2153 | } | 2143 | } |
| 2154 | 2144 | ||
| 2155 | need_to_reverse = reverse && !was_reverse; | 2145 | if (tty->termscript && reverse) |
| 2156 | if (tty->termscript && need_to_reverse) | ||
| 2157 | fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); | 2146 | fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); |
| 2158 | 2147 | ||
| 2159 | /* Now process the alist elements in reverse of specified order. */ | 2148 | /* Now process the alist elements in reverse of specified order. */ |
| 2160 | for (i--; i >= 0; i--) | 2149 | for (i--; i >= 0; i--) |
| 2161 | { | 2150 | { |
| 2162 | Lisp_Object prop, val, frame; | 2151 | Lisp_Object prop, val; |
| 2163 | 2152 | ||
| 2164 | prop = parms[i]; | 2153 | prop = parms[i]; |
| 2165 | val = values[i]; | 2154 | val = values[i]; |
| 2166 | 2155 | ||
| 2167 | if (EQ (prop, Qforeground_color)) | 2156 | if (EQ (prop, Qforeground_color)) |
| 2168 | { | 2157 | { |
| 2169 | unsigned long new_color = load_color (f, NULL, val, need_to_reverse | 2158 | unsigned long new_color = load_color (f, NULL, val, reverse |
| 2170 | ? LFACE_BACKGROUND_INDEX | 2159 | ? LFACE_BACKGROUND_INDEX |
| 2171 | : LFACE_FOREGROUND_INDEX); | 2160 | : LFACE_FOREGROUND_INDEX); |
| 2172 | if (new_color != FACE_TTY_DEFAULT_COLOR | 2161 | if (new_color != FACE_TTY_DEFAULT_COLOR |
| 2173 | && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2162 | && new_color != FACE_TTY_DEFAULT_FG_COLOR |
| 2174 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2163 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
| 2175 | { | 2164 | { |
| 2176 | FRAME_FOREGROUND_PIXEL (f) = new_color; | 2165 | if (!reverse) |
| 2177 | /* Make sure the foreground of the default face for this | 2166 | { |
| 2178 | frame is changed as well. */ | 2167 | FRAME_FOREGROUND_PIXEL (f) = new_color; |
| 2179 | XSETFRAME (frame, f); | 2168 | /* Make sure the foreground of the default face for |
| 2180 | Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2169 | this frame is changed as well. */ |
| 2181 | val, frame); | 2170 | update_face_from_frame_parameter (f, Qforeground_color, val); |
| 2182 | fg_set = 1; | 2171 | fg_set = 1; |
| 2172 | if (tty->termscript) | ||
| 2173 | fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); | ||
| 2174 | } | ||
| 2175 | else | ||
| 2176 | { | ||
| 2177 | FRAME_BACKGROUND_PIXEL (f) = new_color; | ||
| 2178 | update_face_from_frame_parameter (f, Qbackground_color, val); | ||
| 2179 | bg_set = 1; | ||
| 2180 | if (tty->termscript) | ||
| 2181 | fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); | ||
| 2182 | } | ||
| 2183 | redraw = 1; | 2183 | redraw = 1; |
| 2184 | if (tty->termscript) | ||
| 2185 | fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); | ||
| 2186 | } | 2184 | } |
| 2187 | } | 2185 | } |
| 2188 | else if (EQ (prop, Qbackground_color)) | 2186 | else if (EQ (prop, Qbackground_color)) |
| 2189 | { | 2187 | { |
| 2190 | unsigned long new_color = load_color (f, NULL, val, need_to_reverse | 2188 | unsigned long new_color = load_color (f, NULL, val, reverse |
| 2191 | ? LFACE_FOREGROUND_INDEX | 2189 | ? LFACE_FOREGROUND_INDEX |
| 2192 | : LFACE_BACKGROUND_INDEX); | 2190 | : LFACE_BACKGROUND_INDEX); |
| 2193 | if (new_color != FACE_TTY_DEFAULT_COLOR | 2191 | if (new_color != FACE_TTY_DEFAULT_COLOR |
| 2194 | && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2192 | && new_color != FACE_TTY_DEFAULT_FG_COLOR |
| 2195 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2193 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
| 2196 | { | 2194 | { |
| 2197 | FRAME_BACKGROUND_PIXEL (f) = new_color; | 2195 | if (!reverse) |
| 2198 | /* Make sure the background of the default face for this | 2196 | { |
| 2199 | frame is changed as well. */ | 2197 | FRAME_BACKGROUND_PIXEL (f) = new_color; |
| 2200 | XSETFRAME (frame, f); | 2198 | /* Make sure the background of the default face for |
| 2201 | Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2199 | this frame is changed as well. */ |
| 2202 | val, frame); | 2200 | bg_set = 1; |
| 2203 | bg_set = 1; | 2201 | update_face_from_frame_parameter (f, Qbackground_color, val); |
| 2202 | if (tty->termscript) | ||
| 2203 | fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); | ||
| 2204 | } | ||
| 2205 | else | ||
| 2206 | { | ||
| 2207 | FRAME_FOREGROUND_PIXEL (f) = new_color; | ||
| 2208 | fg_set = 1; | ||
| 2209 | update_face_from_frame_parameter (f, Qforeground_color, val); | ||
| 2210 | if (tty->termscript) | ||
| 2211 | fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); | ||
| 2212 | } | ||
| 2204 | redraw = 1; | 2213 | redraw = 1; |
| 2205 | if (tty->termscript) | ||
| 2206 | fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); | ||
| 2207 | } | 2214 | } |
| 2208 | } | 2215 | } |
| 2209 | else if (EQ (prop, Qtitle)) | 2216 | else if (EQ (prop, Qtitle)) |
| @@ -2246,24 +2253,22 @@ IT_set_frame_parameters (f, alist) | |||
| 2246 | 2253 | ||
| 2247 | /* If they specified "reverse", but not the colors, we need to swap | 2254 | /* If they specified "reverse", but not the colors, we need to swap |
| 2248 | the current frame colors. */ | 2255 | the current frame colors. */ |
| 2249 | if (need_to_reverse) | 2256 | if (reverse) |
| 2250 | { | 2257 | { |
| 2251 | Lisp_Object frame; | 2258 | Lisp_Object frame; |
| 2252 | 2259 | ||
| 2253 | if (!fg_set) | 2260 | if (!fg_set) |
| 2254 | { | 2261 | { |
| 2255 | XSETFRAME (frame, f); | 2262 | FRAME_FOREGROUND_PIXEL (f) = orig_bg; |
| 2256 | Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2263 | update_face_from_frame_parameter (f, Qforeground_color, |
| 2257 | tty_color_name (f, orig_bg), | 2264 | tty_color_name (f, orig_bg)); |
| 2258 | frame); | ||
| 2259 | redraw = 1; | 2265 | redraw = 1; |
| 2260 | } | 2266 | } |
| 2261 | if (!bg_set) | 2267 | if (!bg_set) |
| 2262 | { | 2268 | { |
| 2263 | XSETFRAME (frame, f); | 2269 | FRAME_BACKGROUND_PIXEL (f) = orig_fg; |
| 2264 | Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2270 | update_face_from_frame_parameter (f, Qbackground_color, |
| 2265 | tty_color_name (f, orig_fg), | 2271 | tty_color_name (f, orig_fg)); |
| 2266 | frame); | ||
| 2267 | redraw = 1; | 2272 | redraw = 1; |
| 2268 | } | 2273 | } |
| 2269 | } | 2274 | } |