Mercurial > emacs
comparison src/fringe.c @ 83212:f70dc61a797f
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-581
Fix exec-shield autoconf test
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-582
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-583
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-584
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-585
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-586
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-587
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-588
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-589
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-590
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-591
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-592
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-38
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-39
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-40
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-41
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-252
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 03 Oct 2004 13:08:55 +0000 |
parents | b85b19b8eb65 85230b6628b3 |
children | d83f49cefda3 |
comparison
equal
deleted
inserted
replaced
83211:b85b19b8eb65 | 83212:f70dc61a797f |
---|---|
444 { FRBITS (bar_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 444 { FRBITS (bar_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
445 { FRBITS (hbar_cursor_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, | 445 { FRBITS (hbar_cursor_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, |
446 { FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 }, | 446 { FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 }, |
447 }; | 447 }; |
448 | 448 |
449 static struct fringe_bitmap *fringe_bitmaps[MAX_FRINGE_BITMAPS]; | 449 static struct fringe_bitmap **fringe_bitmaps; |
450 static unsigned fringe_faces[MAX_FRINGE_BITMAPS]; | 450 static unsigned *fringe_faces; |
451 static int max_fringe_bitmaps; | |
451 | 452 |
452 static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS; | 453 static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS; |
453 | 454 |
454 /* Return 1 if FRINGE_ID is a valid fringe bitmap id. */ | 455 |
456 /* Lookup bitmap number for symbol BITMAP. | |
457 Return 0 if not a bitmap. */ | |
455 | 458 |
456 int | 459 int |
457 valid_fringe_bitmap_p (bitmap) | 460 lookup_fringe_bitmap (bitmap) |
458 Lisp_Object bitmap; | 461 Lisp_Object bitmap; |
459 { | 462 { |
460 int bn; | 463 int bn; |
461 | 464 |
465 bitmap = Fget (bitmap, Qfringe); | |
462 if (!INTEGERP (bitmap)) | 466 if (!INTEGERP (bitmap)) |
463 return 0; | 467 return 0; |
464 | 468 |
465 bn = XINT (bitmap); | 469 bn = XINT (bitmap); |
466 return (bn >= NO_FRINGE_BITMAP | 470 if (bn > NO_FRINGE_BITMAP |
467 && bn < max_used_fringe_bitmap | 471 && bn < max_used_fringe_bitmap |
468 && (bn < MAX_STANDARD_FRINGE_BITMAPS | 472 && (bn < MAX_STANDARD_FRINGE_BITMAPS |
469 || fringe_bitmaps[bn] != NULL)); | 473 || fringe_bitmaps[bn] != NULL)) |
474 return bn; | |
475 | |
476 return 0; | |
470 } | 477 } |
471 | 478 |
472 /* Get fringe bitmap name for bitmap number BN. | 479 /* Get fringe bitmap name for bitmap number BN. |
473 | 480 |
474 Found by traversing Vfringe_bitmaps comparing BN to the | 481 Found by traversing Vfringe_bitmaps comparing BN to the |
497 return bitmap; | 504 return bitmap; |
498 bitmaps = XCDR (bitmaps); | 505 bitmaps = XCDR (bitmaps); |
499 } | 506 } |
500 | 507 |
501 return num; | 508 return num; |
502 } | |
503 | |
504 | |
505 /* Resolve a BITMAP parameter. | |
506 | |
507 An INTEGER, corresponding to a bitmap number. | |
508 A STRING which is interned to a symbol. | |
509 A SYMBOL which has a fringe property which is a bitmap number. | |
510 */ | |
511 | |
512 static int | |
513 resolve_fringe_bitmap (bitmap, namep) | |
514 Lisp_Object bitmap; | |
515 Lisp_Object *namep; | |
516 { | |
517 if (namep) | |
518 *namep = Qnil; | |
519 | |
520 if (STRINGP (bitmap)) | |
521 bitmap = intern (SDATA (bitmap)); | |
522 | |
523 if (SYMBOLP (bitmap)) | |
524 { | |
525 if (namep) | |
526 *namep = bitmap; | |
527 bitmap = Fget (bitmap, Qfringe); | |
528 } | |
529 | |
530 if (valid_fringe_bitmap_p (bitmap)) | |
531 { | |
532 if (namep && NILP (*namep)) | |
533 *namep = get_fringe_bitmap_name (XINT (bitmap)); | |
534 return XINT (bitmap); | |
535 } | |
536 | |
537 return -1; | |
538 } | 509 } |
539 | 510 |
540 | 511 |
541 /* Draw the bitmap WHICH in one of the left or right fringes of | 512 /* Draw the bitmap WHICH in one of the left or right fringes of |
542 window W. ROW is the glyph row for which to display the bitmap; it | 513 window W. ROW is the glyph row for which to display the bitmap; it |
1067 o_cols != FRAME_FRINGE_COLS (f)) | 1038 o_cols != FRAME_FRINGE_COLS (f)) |
1068 redraw_frame (f); | 1039 redraw_frame (f); |
1069 } | 1040 } |
1070 | 1041 |
1071 | 1042 |
1072 void | 1043 /* Free resources used by a user-defined bitmap. */ |
1044 | |
1045 int | |
1073 destroy_fringe_bitmap (n) | 1046 destroy_fringe_bitmap (n) |
1074 int n; | 1047 int n; |
1075 { | 1048 { |
1076 struct fringe_bitmap **fbp; | 1049 struct fringe_bitmap **fbp; |
1077 | 1050 |
1079 | 1052 |
1080 fbp = &fringe_bitmaps[n]; | 1053 fbp = &fringe_bitmaps[n]; |
1081 if (*fbp && (*fbp)->dynamic) | 1054 if (*fbp && (*fbp)->dynamic) |
1082 { | 1055 { |
1083 /* XXX Is SELECTED_FRAME OK here? */ | 1056 /* XXX Is SELECTED_FRAME OK here? */ |
1084 if (FRAME_RIF (SELECTED_FRAME ())->destroy_fringe_bitmap) | 1057 struct redisplay_interface *rif = FRAME_RIF (SELECTED_FRAME ()); |
1085 FRAME_RIF (SELECTED_FRAME ())->destroy_fringe_bitmap (n); | 1058 if (rif && rif->destroy_fringe_bitmap) |
1059 rif->destroy_fringe_bitmap (n); | |
1086 xfree (*fbp); | 1060 xfree (*fbp); |
1087 *fbp = NULL; | 1061 *fbp = NULL; |
1088 } | 1062 } |
1089 | 1063 |
1090 while (max_used_fringe_bitmap > MAX_STANDARD_FRINGE_BITMAPS | 1064 while (max_used_fringe_bitmap > MAX_STANDARD_FRINGE_BITMAPS |
1099 If BITMAP overrides a standard fringe bitmap, the original bitmap is restored. */) | 1073 If BITMAP overrides a standard fringe bitmap, the original bitmap is restored. */) |
1100 (bitmap) | 1074 (bitmap) |
1101 Lisp_Object bitmap; | 1075 Lisp_Object bitmap; |
1102 { | 1076 { |
1103 int n; | 1077 int n; |
1104 Lisp_Object sym; | 1078 |
1105 | 1079 CHECK_SYMBOL (bitmap); |
1106 n = resolve_fringe_bitmap (bitmap, &sym); | 1080 n = lookup_fringe_bitmap (bitmap); |
1107 if (n < 0) | 1081 if (!n) |
1108 return Qnil; | 1082 return Qnil; |
1109 | 1083 |
1110 destroy_fringe_bitmap (n); | 1084 destroy_fringe_bitmap (n); |
1111 | 1085 |
1112 if (SYMBOLP (sym)) | 1086 if (n >= MAX_STANDARD_FRINGE_BITMAPS) |
1113 { | 1087 { |
1114 Vfringe_bitmaps = Fdelq (sym, Vfringe_bitmaps); | 1088 Vfringe_bitmaps = Fdelq (bitmap, Vfringe_bitmaps); |
1115 /* It would be better to remove the fringe property. */ | 1089 /* It would be better to remove the fringe property. */ |
1116 Fput (sym, Qfringe, Qnil); | 1090 Fput (bitmap, Qfringe, Qnil); |
1117 } | 1091 } |
1092 | |
1118 return Qnil; | 1093 return Qnil; |
1119 } | 1094 } |
1120 | 1095 |
1121 | 1096 |
1122 /* Initialize bitmap bit. | 1097 /* Initialize bitmap bit. |
1186 if (!once_p) | 1161 if (!once_p) |
1187 { | 1162 { |
1188 destroy_fringe_bitmap (which); | 1163 destroy_fringe_bitmap (which); |
1189 | 1164 |
1190 /* XXX Is SELECTED_FRAME OK here? */ | 1165 /* XXX Is SELECTED_FRAME OK here? */ |
1191 if (FRAME_RIF (SELECTED_FRAME ())->define_fringe_bitmap) | 1166 struct redisplay_interface *rif = FRAME_RIF (SELECTED_FRAME ()); |
1192 FRAME_RIF (SELECTED_FRAME ())->define_fringe_bitmap (which, fb->bits, fb->height, fb->width); | 1167 if (rif && rif->define_fringe_bitmap) |
1168 rif->define_fringe_bitmap (which, fb->bits, fb->height, fb->width); | |
1193 | 1169 |
1194 fringe_bitmaps[which] = fb; | 1170 fringe_bitmaps[which] = fb; |
1195 if (which >= max_used_fringe_bitmap) | 1171 if (which >= max_used_fringe_bitmap) |
1196 max_used_fringe_bitmap = which + 1; | 1172 max_used_fringe_bitmap = which + 1; |
1197 } | 1173 } |
1217 Lisp_Object len; | 1193 Lisp_Object len; |
1218 int n, h, i, j; | 1194 int n, h, i, j; |
1219 unsigned short *b; | 1195 unsigned short *b; |
1220 struct fringe_bitmap fb, *xfb; | 1196 struct fringe_bitmap fb, *xfb; |
1221 int fill1 = 0, fill2 = 0; | 1197 int fill1 = 0, fill2 = 0; |
1222 Lisp_Object sym; | 1198 |
1223 | 1199 CHECK_SYMBOL (bitmap); |
1224 n = resolve_fringe_bitmap (bitmap, &sym); | |
1225 | |
1226 if (NILP (sym) || INTEGERP (sym)) | |
1227 sym = wrong_type_argument (Qsymbolp, bitmap); | |
1228 | 1200 |
1229 if (!STRINGP (bits) && !VECTORP (bits)) | 1201 if (!STRINGP (bits) && !VECTORP (bits)) |
1230 bits = wrong_type_argument (Qstringp, bits); | 1202 bits = wrong_type_argument (Qstringp, bits); |
1231 | 1203 |
1232 len = Flength (bits); | 1204 len = Flength (bits); |
1275 else if (EQ (align, Qbottom)) | 1247 else if (EQ (align, Qbottom)) |
1276 fb.align = ALIGN_BITMAP_BOTTOM; | 1248 fb.align = ALIGN_BITMAP_BOTTOM; |
1277 else if (!NILP (align) && !EQ (align, Qcenter)) | 1249 else if (!NILP (align) && !EQ (align, Qcenter)) |
1278 error ("Bad align argument"); | 1250 error ("Bad align argument"); |
1279 | 1251 |
1280 if (n < 0) | 1252 n = lookup_fringe_bitmap (bitmap); |
1281 { | 1253 if (!n) |
1282 if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS) | 1254 { |
1255 if (max_used_fringe_bitmap < max_fringe_bitmaps) | |
1283 n = max_used_fringe_bitmap++; | 1256 n = max_used_fringe_bitmap++; |
1284 else | 1257 else |
1285 { | 1258 { |
1286 for (n = MAX_STANDARD_FRINGE_BITMAPS; | 1259 for (n = MAX_STANDARD_FRINGE_BITMAPS; |
1287 n < MAX_FRINGE_BITMAPS; | 1260 n < max_fringe_bitmaps; |
1288 n++) | 1261 n++) |
1289 if (fringe_bitmaps[n] == NULL) | 1262 if (fringe_bitmaps[n] == NULL) |
1290 break; | 1263 break; |
1291 if (n == MAX_FRINGE_BITMAPS) | 1264 |
1292 error ("Cannot define more fringe bitmaps"); | 1265 if (n == max_fringe_bitmaps) |
1293 } | 1266 { |
1294 | 1267 if ((max_fringe_bitmaps + 20) > MAX_FRINGE_BITMAPS) |
1295 Vfringe_bitmaps = Fcons (sym, Vfringe_bitmaps); | 1268 error ("No free fringe bitmap slots"); |
1296 Fput (sym, Qfringe, make_number (n)); | 1269 |
1270 i = max_fringe_bitmaps; | |
1271 max_fringe_bitmaps += 20; | |
1272 fringe_bitmaps | |
1273 = ((struct fringe_bitmap **) | |
1274 xrealloc (fringe_bitmaps, max_fringe_bitmaps * sizeof (struct fringe_bitmap *))); | |
1275 fringe_faces | |
1276 = (unsigned *) xrealloc (fringe_faces, max_fringe_bitmaps * sizeof (unsigned)); | |
1277 | |
1278 for (; i < max_fringe_bitmaps; i++) | |
1279 { | |
1280 fringe_bitmaps[i] = NULL; | |
1281 fringe_faces[i] = FRINGE_FACE_ID; | |
1282 } | |
1283 } | |
1284 } | |
1285 | |
1286 Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps); | |
1287 Fput (bitmap, Qfringe, make_number (n)); | |
1297 } | 1288 } |
1298 | 1289 |
1299 fb.dynamic = 1; | 1290 fb.dynamic = 1; |
1300 | 1291 |
1301 xfb = (struct fringe_bitmap *) xmalloc (sizeof fb | 1292 xfb = (struct fringe_bitmap *) xmalloc (sizeof fb |
1319 | 1310 |
1320 *xfb = fb; | 1311 *xfb = fb; |
1321 | 1312 |
1322 init_fringe_bitmap (n, xfb, 0); | 1313 init_fringe_bitmap (n, xfb, 0); |
1323 | 1314 |
1324 return sym; | 1315 return bitmap; |
1325 } | 1316 } |
1326 | 1317 |
1327 DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face, | 1318 DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face, |
1328 1, 2, 0, | 1319 1, 2, 0, |
1329 doc: /* Set face for fringe bitmap BITMAP to FACE. | 1320 doc: /* Set face for fringe bitmap BITMAP to FACE. |
1330 If FACE is nil, reset face to default fringe face. */) | 1321 If FACE is nil, reset face to default fringe face. */) |
1331 (bitmap, face) | 1322 (bitmap, face) |
1332 Lisp_Object bitmap, face; | 1323 Lisp_Object bitmap, face; |
1333 { | 1324 { |
1334 int bn; | 1325 int n; |
1335 int face_id; | 1326 int face_id; |
1336 | 1327 |
1337 bn = resolve_fringe_bitmap (bitmap, 0); | 1328 CHECK_SYMBOL (bitmap); |
1338 if (bn < 0) | 1329 n = lookup_fringe_bitmap (bitmap); |
1330 if (!n) | |
1339 error ("Undefined fringe bitmap"); | 1331 error ("Undefined fringe bitmap"); |
1340 | 1332 |
1341 if (!NILP (face)) | 1333 if (!NILP (face)) |
1342 { | 1334 { |
1343 face_id = lookup_named_face (SELECTED_FRAME (), face, 'A'); | 1335 face_id = lookup_named_face (SELECTED_FRAME (), face, 'A'); |
1345 error ("No such face"); | 1337 error ("No such face"); |
1346 } | 1338 } |
1347 else | 1339 else |
1348 face_id = FRINGE_FACE_ID; | 1340 face_id = FRINGE_FACE_ID; |
1349 | 1341 |
1350 fringe_faces [bn] = face_id; | 1342 fringe_faces[n] = face_id; |
1351 | 1343 |
1352 return Qnil; | 1344 return Qnil; |
1353 } | 1345 } |
1354 | 1346 |
1355 DEFUN ("fringe-bitmaps-at-pos", Ffringe_bitmaps_at_pos, Sfringe_bitmaps_at_pos, | 1347 DEFUN ("fringe-bitmaps-at-pos", Ffringe_bitmaps_at_pos, Sfringe_bitmaps_at_pos, |
1433 void | 1425 void |
1434 init_fringe () | 1426 init_fringe () |
1435 { | 1427 { |
1436 int i; | 1428 int i; |
1437 | 1429 |
1438 bzero (fringe_bitmaps, sizeof fringe_bitmaps); | 1430 max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20; |
1439 for (i = 0; i < MAX_FRINGE_BITMAPS; i++) | 1431 |
1440 fringe_faces[i] = FRINGE_FACE_ID; | 1432 fringe_bitmaps |
1433 = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *)); | |
1434 fringe_faces | |
1435 = (unsigned *) xmalloc (max_fringe_bitmaps * sizeof (unsigned)); | |
1436 | |
1437 for (i = 0; i < max_fringe_bitmaps; i++) | |
1438 { | |
1439 fringe_bitmaps[i] = NULL; | |
1440 fringe_faces[i] = FRINGE_FACE_ID; | |
1441 } | |
1441 } | 1442 } |
1442 | 1443 |
1443 #ifdef HAVE_NTGUI | 1444 #ifdef HAVE_NTGUI |
1444 | 1445 |
1445 void | 1446 void |
1446 w32_init_fringe () | 1447 w32_init_fringe () |
1447 { | 1448 { |
1448 enum fringe_bitmap_type bt; | 1449 enum fringe_bitmap_type bt; |
1449 | 1450 |
1451 if (!rif) | |
1452 return; | |
1453 | |
1450 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) | 1454 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) |
1451 { | 1455 { |
1452 struct fringe_bitmap *fb = &standard_bitmaps[bt]; | 1456 struct fringe_bitmap *fb = &standard_bitmaps[bt]; |
1453 rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width); | 1457 rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width); |
1454 } | 1458 } |
1458 w32_reset_fringes () | 1462 w32_reset_fringes () |
1459 { | 1463 { |
1460 /* Destroy row bitmaps. */ | 1464 /* Destroy row bitmaps. */ |
1461 int bt; | 1465 int bt; |
1462 | 1466 |
1467 if (!rif) | |
1468 return; | |
1469 | |
1463 for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++) | 1470 for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++) |
1464 rif->destroy_fringe_bitmap (bt); | 1471 rif->destroy_fringe_bitmap (bt); |
1465 } | 1472 } |
1466 | 1473 |
1467 #endif /* HAVE_NTGUI */ | 1474 #endif /* HAVE_NTGUI */ |