Mercurial > hg > xemacs-beta
comparison src/objects-tty.c @ 5118:e0db3c197671 ben-lisp-object
merge up to latest default branch, doesn't compile yet
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 21:18:49 -0600 |
parents | 3a87551bfeb5 |
children | d1247f3cc363 |
comparison
equal
deleted
inserted
replaced
5117:3742ea8250b5 | 5118:e0db3c197671 |
---|---|
28 #include "insdel.h" | 28 #include "insdel.h" |
29 #include "objects-tty-impl.h" | 29 #include "objects-tty-impl.h" |
30 #include "device.h" | 30 #include "device.h" |
31 #include "charset.h" | 31 #include "charset.h" |
32 | 32 |
33 #ifdef NEW_GC | |
34 # define UNUSED_IF_NEW_GC(decl) UNUSED (decl) | |
35 #else | |
36 # define UNUSED_IF_NEW_GC(decl) decl | |
37 #endif | |
38 | |
33 /* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ | 39 /* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ |
34 Lisp_Object Vtty_color_alist; | 40 Lisp_Object Vtty_color_alist; |
35 #if 0 /* This stuff doesn't quite work yet */ | 41 #if 0 /* This stuff doesn't quite work yet */ |
36 Lisp_Object Vtty_dynamic_color_fg; | 42 Lisp_Object Vtty_dynamic_color_fg; |
37 Lisp_Object Vtty_dynamic_color_bg; | 43 Lisp_Object Vtty_dynamic_color_bg; |
40 static const struct memory_description tty_color_instance_data_description_1 [] = { | 46 static const struct memory_description tty_color_instance_data_description_1 [] = { |
41 { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) }, | 47 { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) }, |
42 { XD_END } | 48 { XD_END } |
43 }; | 49 }; |
44 | 50 |
51 #ifdef NEW_GC | |
52 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-color-instance-data", | |
53 tty_color_instance_data, | |
54 0, tty_color_instance_data_description_1, | |
55 struct tty_color_instance_data); | |
56 #else /* not NEW_GC */ | |
45 const struct sized_memory_description tty_color_instance_data_description = { | 57 const struct sized_memory_description tty_color_instance_data_description = { |
46 sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 | 58 sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 |
47 }; | 59 }; |
60 #endif /* not NEW_GC */ | |
48 | 61 |
49 static const struct memory_description tty_font_instance_data_description_1 [] = { | 62 static const struct memory_description tty_font_instance_data_description_1 [] = { |
50 { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, | 63 { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, |
51 { XD_END } | 64 { XD_END } |
52 }; | 65 }; |
53 | 66 |
67 #ifdef NEW_GC | |
68 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-font-instance-data", | |
69 tty_font_instance_data, 0, | |
70 tty_font_instance_data_description_1, | |
71 struct tty_font_instance_data); | |
72 #else /* not NEW_GC */ | |
54 const struct sized_memory_description tty_font_instance_data_description = { | 73 const struct sized_memory_description tty_font_instance_data_description = { |
55 sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 | 74 sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 |
56 }; | 75 }; |
76 #endif /* not NEW_GC */ | |
57 | 77 |
58 DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* | 78 DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* |
59 Register COLOR as a recognized TTY color. | 79 Register COLOR as a recognized TTY color. |
60 COLOR should be a string. | 80 COLOR should be a string. |
61 Strings FG-STRING and BG-STRING should specify the escape sequences to | 81 Strings FG-STRING and BG-STRING should specify the escape sequences to |
174 #endif | 194 #endif |
175 return 0; | 195 return 0; |
176 } | 196 } |
177 | 197 |
178 /* Don't allocate the data until we're sure that we will succeed. */ | 198 /* Don't allocate the data until we're sure that we will succeed. */ |
199 #ifdef NEW_GC | |
200 c->data = alloc_lrecord_type (struct tty_color_instance_data, | |
201 &lrecord_tty_color_instance_data); | |
202 #else /* not NEW_GC */ | |
179 c->data = xnew (struct tty_color_instance_data); | 203 c->data = xnew (struct tty_color_instance_data); |
204 #endif /* not NEW_GC */ | |
180 COLOR_INSTANCE_TTY_SYMBOL (c) = name; | 205 COLOR_INSTANCE_TTY_SYMBOL (c) = name; |
181 | 206 |
182 return 1; | 207 return 1; |
183 } | 208 } |
184 | 209 |
194 int UNUSED (escapeflag)) | 219 int UNUSED (escapeflag)) |
195 { | 220 { |
196 } | 221 } |
197 | 222 |
198 static void | 223 static void |
199 tty_finalize_color_instance (Lisp_Color_Instance *c) | 224 tty_finalize_color_instance (Lisp_Color_Instance *UNUSED_IF_NEW_GC (c)) |
200 { | 225 { |
226 #ifndef NEW_GC | |
201 if (c->data) | 227 if (c->data) |
202 xfree (c->data, void *); | 228 xfree (c->data, void *); |
229 #endif /* not NEW_GC */ | |
203 } | 230 } |
204 | 231 |
205 static int | 232 static int |
206 tty_color_instance_equal (Lisp_Color_Instance *c1, | 233 tty_color_instance_equal (Lisp_Color_Instance *c1, |
207 Lisp_Color_Instance *c2, | 234 Lisp_Color_Instance *c2, |
252 return 0; | 279 return 0; |
253 #endif | 280 #endif |
254 } | 281 } |
255 | 282 |
256 /* Don't allocate the data until we're sure that we will succeed. */ | 283 /* Don't allocate the data until we're sure that we will succeed. */ |
284 #ifdef NEW_GC | |
285 f->data = alloc_lrecord_type (struct tty_font_instance_data, | |
286 &lrecord_tty_font_instance_data); | |
287 #else /* not NEW_GC */ | |
257 f->data = xnew (struct tty_font_instance_data); | 288 f->data = xnew (struct tty_font_instance_data); |
289 #endif /* not NEW_GC */ | |
258 FONT_INSTANCE_TTY_CHARSET (f) = charset; | 290 FONT_INSTANCE_TTY_CHARSET (f) = charset; |
259 #ifdef MULE | 291 #ifdef MULE |
260 if (CHARSETP (charset)) | 292 if (CHARSETP (charset)) |
261 f->width = XCHARSET_COLUMNS (charset); | 293 f->width = XCHARSET_COLUMNS (charset); |
262 else | 294 else |
282 int UNUSED (escapeflag)) | 314 int UNUSED (escapeflag)) |
283 { | 315 { |
284 } | 316 } |
285 | 317 |
286 static void | 318 static void |
287 tty_finalize_font_instance (Lisp_Font_Instance *f) | 319 tty_finalize_font_instance (Lisp_Font_Instance *UNUSED_IF_NEW_GC (f)) |
288 { | 320 { |
321 #ifndef NEW_GC | |
289 if (f->data) | 322 if (f->data) |
290 xfree (f->data, void *); | 323 xfree (f->data, void *); |
324 #endif /* not NEW_GC */ | |
291 } | 325 } |
292 | 326 |
293 static Lisp_Object | 327 static Lisp_Object |
294 tty_font_list (Lisp_Object UNUSED (pattern), Lisp_Object UNUSED (device), | 328 tty_font_list (Lisp_Object UNUSED (pattern), Lisp_Object UNUSED (device), |
295 Lisp_Object UNUSED (maxnumber)) | 329 Lisp_Object UNUSED (maxnumber)) |
301 | 335 |
302 static int | 336 static int |
303 tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, | 337 tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, |
304 const Ibyte *nonreloc, Lisp_Object reloc, | 338 const Ibyte *nonreloc, Lisp_Object reloc, |
305 Bytecount offset, Bytecount length, | 339 Bytecount offset, Bytecount length, |
306 int stage) | 340 enum font_specifier_matchspec_stages stage) |
307 { | 341 { |
308 const Ibyte *the_nonreloc = nonreloc; | 342 const Ibyte *the_nonreloc = nonreloc; |
309 | 343 |
310 if (stage) | 344 if (stage) |
311 return 0; | 345 return 0; |
313 if (!the_nonreloc) | 347 if (!the_nonreloc) |
314 the_nonreloc = XSTRING_DATA (reloc); | 348 the_nonreloc = XSTRING_DATA (reloc); |
315 fixup_internal_substring (nonreloc, reloc, offset, &length); | 349 fixup_internal_substring (nonreloc, reloc, offset, &length); |
316 the_nonreloc += offset; | 350 the_nonreloc += offset; |
317 | 351 |
318 if (UNBOUNDP (charset)) | 352 if (NILP (charset)) |
319 return !memchr (the_nonreloc, '/', length); | 353 return !memchr (the_nonreloc, '/', length); |
320 the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); | 354 the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); |
321 if (!the_nonreloc) | 355 if (!the_nonreloc) |
322 return 0; | 356 return 0; |
323 the_nonreloc++; | 357 the_nonreloc++; |
329 | 363 |
330 /* find a font spec that matches font spec FONT and also matches | 364 /* find a font spec that matches font spec FONT and also matches |
331 (the registry of) CHARSET. */ | 365 (the registry of) CHARSET. */ |
332 static Lisp_Object | 366 static Lisp_Object |
333 tty_find_charset_font (Lisp_Object device, Lisp_Object font, | 367 tty_find_charset_font (Lisp_Object device, Lisp_Object font, |
334 Lisp_Object charset, int stage) | 368 Lisp_Object charset, |
369 enum font_specifier_matchspec_stages stage) | |
335 { | 370 { |
336 Ibyte *fontname = XSTRING_DATA (font); | 371 Ibyte *fontname = XSTRING_DATA (font); |
337 | 372 |
338 if (stage) | 373 if (stage) |
339 return Qnil; | 374 return Qnil; |
340 | 375 |
341 if (strchr ((const char *) fontname, '/')) | 376 if (strchr ((const char *) fontname, '/')) |
342 { | 377 { |
343 if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, | 378 if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, |
344 font, 0, -1, 0)) | 379 font, 0, -1, initial)) |
345 return font; | 380 return font; |
346 return Qnil; | 381 return Qnil; |
347 } | 382 } |
348 | 383 |
349 if (UNBOUNDP (charset)) | 384 if (NILP (charset)) |
350 return font; | 385 return font; |
351 | 386 |
352 return concat3 (font, build_string ("/"), | 387 return concat3 (font, build_string ("/"), |
353 Fsymbol_name (XCHARSET_NAME (charset))); | 388 Fsymbol_name (XCHARSET_NAME (charset))); |
354 } | 389 } |
361 /************************************************************************/ | 396 /************************************************************************/ |
362 | 397 |
363 void | 398 void |
364 syms_of_objects_tty (void) | 399 syms_of_objects_tty (void) |
365 { | 400 { |
401 #ifdef NEW_GC | |
402 INIT_LISP_OBJECT (tty_color_instance_data); | |
403 INIT_LISP_OBJECT (tty_font_instance_data); | |
404 #endif /* NEW_GC */ | |
405 | |
366 DEFSUBR (Fregister_tty_color); | 406 DEFSUBR (Fregister_tty_color); |
367 DEFSUBR (Funregister_tty_color); | 407 DEFSUBR (Funregister_tty_color); |
368 DEFSUBR (Ffind_tty_color); | 408 DEFSUBR (Ffind_tty_color); |
369 #if 0 | 409 #if 0 |
370 DEFSUBR (Fset_tty_dynamic_color_specs); | 410 DEFSUBR (Fset_tty_dynamic_color_specs); |