comparison src/objects.c @ 5080:5502045ec510

The background-placement face property. -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * cl-macs.el (face-background-placement): New defsetf. * cus-face.el (custom-face-attributes): * faces.el (face-interactive): * faces.el (set-face-property): * faces.el (face-equal): * faces.el (init-other-random-faces): Update. * faces.el (face-background-placement): * faces.el (set-face-background-placement): * faces.el (face-background-placement-instance): * faces.el (face-background-placement-instance-p): * frame.el (set-frame-background-placement): * frame.el (frame-background-placement): * frame.el (frame-background-placement-instance): * objects.el (make-face-background-placement-specifier): New. man/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * xemacs/custom.texi (Faces): Document it. src/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * console-x-impl.h (struct x_frame): Add new slots x and y. * console-x-impl.h (FRAME_X_X, FRAME_X_Y): New slot accessors. * console-gtk-impl.h: Fake something similar for potential port. * frame-x.c (x_get_frame_text_position): New function. * frame-x.c (x_init_frame_3): Use it. * event-Xt.c (emacs_Xt_handle_magic_event): Eat spurious ConfigureNotify events, get the frame position and mark frame faces changed. * objects-impl.h: The face_background_placement_specifier structure and its accessors. * objects.c: New symbols Qabsolute and Qrelative. * objects.c (face_background_placement_create): * objects.c (face_background_placement_mark): * objects.c (face_background_placement_instantiate): * objects.c (face_background_placement_validate): * objects.c (face_background_placement_after_change): * objects.c (set_face_background_placement_attached_to): New. * objects.h (set_face_background_palcement_attached_to): Declare the one above. * objects.c (syms_of_objects): * objects.c (specifier_type_create_objects): * objects.c (reinit_specifier_type_create_objects): * objects.c (reinit_vars_of_objects): Update for the modifications above. * console-xlike-inc.h (XLIKE_GC_TS_X_ORIGIN, XLIKE_GC_TS_X_ORIGIN): New X11/Gtk compatibility macros. * redisplay-xlike-inc.c (XLIKE_get_gc): Add a background placement argument and handle it. * gtk-glue.c (face_to_gc): * redisplay-xlike-inc.c (XLIKE_output_string): * redisplay-xlike-inc.c (XLIKE_output_pixmap): * redisplay-xlike-inc.c (XLIKE_output_blank): * redisplay-xlike-inc.c (XLIKE_output_horizontal_line): * redisplay-xlike-inc.c (XLIKE_output_eol_cursor): Update accordingly. * console-impl.h (struct console_methods): Add a background placement (Lisp_Object) argument to the clear_region method. * console-stream.c (stream_clear_region): * redisplay-tty.c (tty_clear_region): * redisplay-msw.c (mswindows_clear_region): * redisplay-xlike-inc.c (XLIKE_clear_region): Update accordingly. * redisplay-output.c (redisplay_clear_region): Handle the background placement property and update the call to the clear_region method. * faces.h (struct Lisp_Face): * faces.h (struct face_cachel): Add a background placement slot. * faces.h (WINDOW_FACE_CACHEL_BACKGROUND_PLACEMENT): New accessor. * faces.c (mark_face): * faces.c (face_equal): * faces.c (face_getprop): * faces.c (face_putprop): * faces.c (face_remprop): * faces.c (face_plist): * faces.c (reset_face): * faces.c (mark_face_cachels): * faces.c (update_face_cachel_data): * faces.c (merge_face_cachel_data): * faces.c (reset_face_cachel): * faces.c (Fmake_face): * faces.c (Fcopy_face): Handle the background placement property. * faces.c (syms_of_faces): * faces.c (vars_of_faces): * faces.c (complex_vars_of_faces): Update accordingly.
author Didier Verna <didier@lrde.epita.fr>
date Thu, 25 Feb 2010 16:19:01 +0100
parents d95c102a96d3
children 7be849cb8828
comparison
equal deleted inserted replaced
5079:aa4cae427255 5080:5502045ec510
1 /* Generic Objects and Functions. 1 /* Generic Objects and Functions.
2 Copyright (C) 1995 Free Software Foundation, Inc. 2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Copyright (C) 1995 Board of Trustees, University of Illinois. 3 Copyright (C) 1995 Board of Trustees, University of Illinois.
4 Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing. 4 Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing.
5 Copyright (C) 2010 Didier Verna
5 6
6 This file is part of XEmacs. 7 This file is part of XEmacs.
7 8
8 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
1210 { 1211 {
1211 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; 1212 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil;
1212 } 1213 }
1213 1214
1214 1215
1216 /*****************************************************************************
1217 Face Background Placement Object
1218 ****************************************************************************/
1219 Lisp_Object Qabsolute, Qrelative;
1220
1221 static const struct memory_description
1222 face_background_placement_specifier_description[] = {
1223 { XD_LISP_OBJECT, offsetof (struct face_background_placement_specifier,
1224 face) },
1225 { XD_END }
1226 };
1227
1228 DEFINE_SPECIFIER_TYPE_WITH_DATA (face_background_placement);
1229 Lisp_Object Qface_background_placement;
1230
1231 static void
1232 face_background_placement_create (Lisp_Object obj)
1233 {
1234 Lisp_Specifier *face_background_placement
1235 = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj);
1236
1237 FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = Qnil;
1238 }
1239
1240 static void
1241 face_background_placement_mark (Lisp_Object obj)
1242 {
1243 Lisp_Specifier *face_background_placement
1244 = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj);
1245
1246 mark_object
1247 (FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement));
1248 }
1249
1250 /* No equal or hash methods; ignore the face the background-placement is based
1251 off of for `equal' */
1252
1253 extern Lisp_Object Qbackground_placement;
1254
1255 static Lisp_Object
1256 face_background_placement_instantiate (Lisp_Object UNUSED (specifier),
1257 Lisp_Object UNUSED (matchspec),
1258 Lisp_Object domain,
1259 Lisp_Object instantiator,
1260 Lisp_Object depth,
1261 int no_fallback)
1262 {
1263 /* When called, we're inside of call_with_suspended_errors(),
1264 so we can freely error. */
1265 if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative))
1266 return instantiator;
1267 else if (VECTORP (instantiator))
1268 {
1269 assert (XVECTOR_LENGTH (instantiator) == 1);
1270
1271 return FACE_PROPERTY_INSTANCE_1
1272 (Fget_face (XVECTOR_DATA (instantiator)[0]),
1273 Qbackground_placement, domain, ERROR_ME, no_fallback, depth);
1274 }
1275 else
1276 ABORT (); /* Eh? */
1277
1278 return Qunbound;
1279 }
1280
1281 static void
1282 face_background_placement_validate (Lisp_Object instantiator)
1283 {
1284 if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative))
1285 return;
1286 else if (VECTORP (instantiator) &&
1287 (XVECTOR_LENGTH (instantiator) == 1))
1288 {
1289 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
1290
1291 Fget_face (face); /* just to check that the face exists -- dvl */
1292 }
1293 else if (VECTORP (instantiator))
1294 sferror ("Wrong length for background-placement inheritance spec",
1295 instantiator);
1296 else
1297 invalid_argument
1298 ("\
1299 Background-placement instantiator must be absolute, relative or vector",
1300 instantiator);
1301 }
1302
1303 static void
1304 face_background_placement_after_change (Lisp_Object specifier,
1305 Lisp_Object locale)
1306 {
1307 Lisp_Object face
1308 = FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE
1309 (XFACE_BACKGROUND_PLACEMENT_SPECIFIER (specifier));
1310
1311 if (!NILP (face))
1312 {
1313 face_property_was_changed (face, Qbackground_placement, locale);
1314 if (BUFFERP (locale))
1315 XBUFFER (locale)->buffer_local_face_property = 1;
1316 }
1317 }
1318
1319 void
1320 set_face_background_placement_attached_to (Lisp_Object obj, Lisp_Object face)
1321 {
1322 Lisp_Specifier *face_background_placement
1323 = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj);
1324
1325 FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = face;
1326 }
1327
1328 DEFUN ("face-background-placement-specifier-p", Fface_background_placement_specifier_p, 1, 1, 0, /*
1329 Return non-nil if OBJECT is a face-background-placement specifier.
1330
1331 See `make-face-background-placement-specifier' for a description of possible
1332 face-background-placement instantiators.
1333 */
1334 (object))
1335 {
1336 return FACE_BACKGROUND_PLACEMENT_SPECIFIERP (object) ? Qt : Qnil;
1337 }
1338
1339
1215 /************************************************************************/ 1340 /************************************************************************/
1216 /* initialization */ 1341 /* initialization */
1217 /************************************************************************/ 1342 /************************************************************************/
1218 1343
1219 void 1344 void
1223 INIT_LRECORD_IMPLEMENTATION (font_instance); 1348 INIT_LRECORD_IMPLEMENTATION (font_instance);
1224 1349
1225 DEFSUBR (Fcolor_specifier_p); 1350 DEFSUBR (Fcolor_specifier_p);
1226 DEFSUBR (Ffont_specifier_p); 1351 DEFSUBR (Ffont_specifier_p);
1227 DEFSUBR (Fface_boolean_specifier_p); 1352 DEFSUBR (Fface_boolean_specifier_p);
1353 DEFSUBR (Fface_background_placement_specifier_p);
1228 1354
1229 DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep); 1355 DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep);
1230 DEFSUBR (Fmake_color_instance); 1356 DEFSUBR (Fmake_color_instance);
1231 DEFSUBR (Fcolor_instance_p); 1357 DEFSUBR (Fcolor_instance_p);
1232 DEFSUBR (Fcolor_instance_name); 1358 DEFSUBR (Fcolor_instance_name);
1247 DEFSUBR (Ffont_instance_properties); 1373 DEFSUBR (Ffont_instance_properties);
1248 DEFSUBR (Ffont_list); 1374 DEFSUBR (Ffont_list);
1249 1375
1250 /* Qcolor, Qfont defined in general.c */ 1376 /* Qcolor, Qfont defined in general.c */
1251 DEFSYMBOL (Qface_boolean); 1377 DEFSYMBOL (Qface_boolean);
1378
1379 DEFSYMBOL (Qface_background_placement);
1380 DEFSYMBOL (Qabsolute);
1381 DEFSYMBOL (Qrelative);
1252 } 1382 }
1253 1383
1254 void 1384 void
1255 specifier_type_create_objects (void) 1385 specifier_type_create_objects (void)
1256 { 1386 {
1257 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p"); 1387 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
1258 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p"); 1388 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
1259 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean", 1389 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
1260 "face-boolean-specifier-p"); 1390 "face-boolean-specifier-p");
1391 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_background_placement,
1392 "face-background-placement",
1393 "\
1394 face-background-placement-specifier-p");
1261 1395
1262 SPECIFIER_HAS_METHOD (color, instantiate); 1396 SPECIFIER_HAS_METHOD (color, instantiate);
1263 SPECIFIER_HAS_METHOD (font, instantiate); 1397 SPECIFIER_HAS_METHOD (font, instantiate);
1264 SPECIFIER_HAS_METHOD (face_boolean, instantiate); 1398 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
1399 SPECIFIER_HAS_METHOD (face_background_placement, instantiate);
1265 1400
1266 SPECIFIER_HAS_METHOD (color, validate); 1401 SPECIFIER_HAS_METHOD (color, validate);
1267 SPECIFIER_HAS_METHOD (font, validate); 1402 SPECIFIER_HAS_METHOD (font, validate);
1268 SPECIFIER_HAS_METHOD (face_boolean, validate); 1403 SPECIFIER_HAS_METHOD (face_boolean, validate);
1404 SPECIFIER_HAS_METHOD (face_background_placement, validate);
1269 1405
1270 SPECIFIER_HAS_METHOD (color, create); 1406 SPECIFIER_HAS_METHOD (color, create);
1271 SPECIFIER_HAS_METHOD (font, create); 1407 SPECIFIER_HAS_METHOD (font, create);
1272 SPECIFIER_HAS_METHOD (face_boolean, create); 1408 SPECIFIER_HAS_METHOD (face_boolean, create);
1409 SPECIFIER_HAS_METHOD (face_background_placement, create);
1273 1410
1274 SPECIFIER_HAS_METHOD (color, mark); 1411 SPECIFIER_HAS_METHOD (color, mark);
1275 SPECIFIER_HAS_METHOD (font, mark); 1412 SPECIFIER_HAS_METHOD (font, mark);
1276 SPECIFIER_HAS_METHOD (face_boolean, mark); 1413 SPECIFIER_HAS_METHOD (face_boolean, mark);
1414 SPECIFIER_HAS_METHOD (face_background_placement, mark);
1277 1415
1278 SPECIFIER_HAS_METHOD (color, after_change); 1416 SPECIFIER_HAS_METHOD (color, after_change);
1279 SPECIFIER_HAS_METHOD (font, after_change); 1417 SPECIFIER_HAS_METHOD (font, after_change);
1280 SPECIFIER_HAS_METHOD (face_boolean, after_change); 1418 SPECIFIER_HAS_METHOD (face_boolean, after_change);
1419 SPECIFIER_HAS_METHOD (face_background_placement, after_change);
1281 1420
1282 #ifdef MULE 1421 #ifdef MULE
1283 SPECIFIER_HAS_METHOD (font, validate_matchspec); 1422 SPECIFIER_HAS_METHOD (font, validate_matchspec);
1284 #endif 1423 #endif
1285 } 1424 }
1288 reinit_specifier_type_create_objects (void) 1427 reinit_specifier_type_create_objects (void)
1289 { 1428 {
1290 REINITIALIZE_SPECIFIER_TYPE (color); 1429 REINITIALIZE_SPECIFIER_TYPE (color);
1291 REINITIALIZE_SPECIFIER_TYPE (font); 1430 REINITIALIZE_SPECIFIER_TYPE (font);
1292 REINITIALIZE_SPECIFIER_TYPE (face_boolean); 1431 REINITIALIZE_SPECIFIER_TYPE (face_boolean);
1432 REINITIALIZE_SPECIFIER_TYPE (face_background_placement);
1293 } 1433 }
1294 1434
1295 void 1435 void
1296 reinit_vars_of_objects (void) 1436 reinit_vars_of_objects (void)
1297 { 1437 {