aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-09-29 11:57:48 +0000
committerKim F. Storm2004-09-29 11:57:48 +0000
commit4cce0ab79faf06a1fcb0c533c9062143c1daa777 (patch)
treeb99d752fa449ae4aa4977c589059a755a82bcf8b /src
parente72d73350680a887f3dc751276c6a75a0eb32cca (diff)
downloademacs-4cce0ab79faf06a1fcb0c533c9062143c1daa777.tar.gz
emacs-4cce0ab79faf06a1fcb0c533c9062143c1daa777.zip
Simplify last change.
(lookup_fringe_bitmap): New function. (valid_fringe_bitmap_p, resolve_fringe_bitmap): Remove. (Fdestroy_fringe_bitmap): Use lookup_fringe_bitmap. Keep standard bitmaps in Vfringe_bitmaps. (Fdefine_fringe_bitmap): Use lookup_fringe_bitmap. (Fset_fringe_bitmap_face): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/fringe.c94
1 files changed, 33 insertions, 61 deletions
diff --git a/src/fringe.c b/src/fringe.c
index 915652d6ba9..b971b6d9847 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -450,22 +450,28 @@ static unsigned fringe_faces[MAX_FRINGE_BITMAPS];
450 450
451static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS; 451static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
452 452
453/* Return 1 if FRINGE_ID is a valid fringe bitmap id. */ 453
454/* Lookup bitmap number for symbol BITMAP.
455 Return 0 if not a bitmap. */
454 456
455int 457int
456valid_fringe_bitmap_p (bitmap) 458lookup_fringe_bitmap (bitmap)
457 Lisp_Object bitmap; 459 Lisp_Object bitmap;
458{ 460{
459 int bn; 461 int bn;
460 462
463 bitmap = Fget (bitmap, Qfringe);
461 if (!INTEGERP (bitmap)) 464 if (!INTEGERP (bitmap))
462 return 0; 465 return 0;
463 466
464 bn = XINT (bitmap); 467 bn = XINT (bitmap);
465 return (bn >= NO_FRINGE_BITMAP 468 if (bn > NO_FRINGE_BITMAP
466 && bn < max_used_fringe_bitmap 469 && bn < max_used_fringe_bitmap
467 && (bn < MAX_STANDARD_FRINGE_BITMAPS 470 && (bn < MAX_STANDARD_FRINGE_BITMAPS
468 || fringe_bitmaps[bn] != NULL)); 471 || fringe_bitmaps[bn] != NULL))
472 return bn;
473
474 return 0;
469} 475}
470 476
471/* Get fringe bitmap name for bitmap number BN. 477/* Get fringe bitmap name for bitmap number BN.
@@ -501,42 +507,6 @@ get_fringe_bitmap_name (bn)
501} 507}
502 508
503 509
504/* Resolve a BITMAP parameter.
505
506 An INTEGER, corresponding to a bitmap number.
507 A STRING which is interned to a symbol.
508 A SYMBOL which has a fringe property which is a bitmap number.
509*/
510
511static int
512resolve_fringe_bitmap (bitmap, namep)
513 Lisp_Object bitmap;
514 Lisp_Object *namep;
515{
516 if (namep)
517 *namep = Qnil;
518
519 if (STRINGP (bitmap))
520 bitmap = intern (SDATA (bitmap));
521
522 if (SYMBOLP (bitmap))
523 {
524 if (namep)
525 *namep = bitmap;
526 bitmap = Fget (bitmap, Qfringe);
527 }
528
529 if (valid_fringe_bitmap_p (bitmap))
530 {
531 if (namep && NILP (*namep))
532 *namep = get_fringe_bitmap_name (XINT (bitmap));
533 return XINT (bitmap);
534 }
535
536 return -1;
537}
538
539
540/* Draw the bitmap WHICH in one of the left or right fringes of 510/* Draw the bitmap WHICH in one of the left or right fringes of
541 window W. ROW is the glyph row for which to display the bitmap; it 511 window W. ROW is the glyph row for which to display the bitmap; it
542 determines the vertical position at which the bitmap has to be 512 determines the vertical position at which the bitmap has to be
@@ -1068,7 +1038,9 @@ compute_fringe_widths (f, redraw)
1068} 1038}
1069 1039
1070 1040
1071void 1041/* Free resources used by a user-defined bitmap. */
1042
1043int
1072destroy_fringe_bitmap (n) 1044destroy_fringe_bitmap (n)
1073 int n; 1045 int n;
1074{ 1046{
@@ -1099,20 +1071,21 @@ If BITMAP overrides a standard fringe bitmap, the original bitmap is restored.
1099 Lisp_Object bitmap; 1071 Lisp_Object bitmap;
1100{ 1072{
1101 int n; 1073 int n;
1102 Lisp_Object sym;
1103 1074
1104 n = resolve_fringe_bitmap (bitmap, &sym); 1075 CHECK_SYMBOL (bitmap);
1105 if (n < 0) 1076 n = lookup_fringe_bitmap (bitmap);
1077 if (!n)
1106 return Qnil; 1078 return Qnil;
1107 1079
1108 destroy_fringe_bitmap (n); 1080 destroy_fringe_bitmap (n);
1109 1081
1110 if (SYMBOLP (sym)) 1082 if (n >= MAX_STANDARD_FRINGE_BITMAPS)
1111 { 1083 {
1112 Vfringe_bitmaps = Fdelq (sym, Vfringe_bitmaps); 1084 Vfringe_bitmaps = Fdelq (bitmap, Vfringe_bitmaps);
1113 /* It would be better to remove the fringe property. */ 1085 /* It would be better to remove the fringe property. */
1114 Fput (sym, Qfringe, Qnil); 1086 Fput (bitmap, Qfringe, Qnil);
1115 } 1087 }
1088
1116 return Qnil; 1089 return Qnil;
1117} 1090}
1118 1091
@@ -1216,12 +1189,10 @@ If BITMAP already exists, the existing definition is replaced. */)
1216 unsigned short *b; 1189 unsigned short *b;
1217 struct fringe_bitmap fb, *xfb; 1190 struct fringe_bitmap fb, *xfb;
1218 int fill1 = 0, fill2 = 0; 1191 int fill1 = 0, fill2 = 0;
1219 Lisp_Object sym;
1220 1192
1221 n = resolve_fringe_bitmap (bitmap, &sym); 1193 CHECK_SYMBOL (bitmap);
1222 1194
1223 if (NILP (sym) || INTEGERP (sym)) 1195 n = lookup_fringe_bitmap (bitmap);
1224 sym = wrong_type_argument (Qsymbolp, bitmap);
1225 1196
1226 if (!STRINGP (bits) && !VECTORP (bits)) 1197 if (!STRINGP (bits) && !VECTORP (bits))
1227 bits = wrong_type_argument (Qstringp, bits); 1198 bits = wrong_type_argument (Qstringp, bits);
@@ -1274,7 +1245,7 @@ If BITMAP already exists, the existing definition is replaced. */)
1274 else if (!NILP (align) && !EQ (align, Qcenter)) 1245 else if (!NILP (align) && !EQ (align, Qcenter))
1275 error ("Bad align argument"); 1246 error ("Bad align argument");
1276 1247
1277 if (n < 0) 1248 if (!n)
1278 { 1249 {
1279 if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS) 1250 if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS)
1280 n = max_used_fringe_bitmap++; 1251 n = max_used_fringe_bitmap++;
@@ -1289,8 +1260,8 @@ If BITMAP already exists, the existing definition is replaced. */)
1289 error ("Cannot define more fringe bitmaps"); 1260 error ("Cannot define more fringe bitmaps");
1290 } 1261 }
1291 1262
1292 Vfringe_bitmaps = Fcons (sym, Vfringe_bitmaps); 1263 Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps);
1293 Fput (sym, Qfringe, make_number (n)); 1264 Fput (bitmap, Qfringe, make_number (n));
1294 } 1265 }
1295 1266
1296 fb.dynamic = 1; 1267 fb.dynamic = 1;
@@ -1318,7 +1289,7 @@ If BITMAP already exists, the existing definition is replaced. */)
1318 1289
1319 init_fringe_bitmap (n, xfb, 0); 1290 init_fringe_bitmap (n, xfb, 0);
1320 1291
1321 return sym; 1292 return bitmap;
1322} 1293}
1323 1294
1324DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face, 1295DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face,
@@ -1328,11 +1299,12 @@ If FACE is nil, reset face to default fringe face. */)
1328 (bitmap, face) 1299 (bitmap, face)
1329 Lisp_Object bitmap, face; 1300 Lisp_Object bitmap, face;
1330{ 1301{
1331 int bn; 1302 int n;
1332 int face_id; 1303 int face_id;
1333 1304
1334 bn = resolve_fringe_bitmap (bitmap, 0); 1305 CHECK_SYMBOL (bitmap);
1335 if (bn < 0) 1306 n = lookup_fringe_bitmap (bitmap);
1307 if (!n)
1336 error ("Undefined fringe bitmap"); 1308 error ("Undefined fringe bitmap");
1337 1309
1338 if (!NILP (face)) 1310 if (!NILP (face))
@@ -1344,7 +1316,7 @@ If FACE is nil, reset face to default fringe face. */)
1344 else 1316 else
1345 face_id = FRINGE_FACE_ID; 1317 face_id = FRINGE_FACE_ID;
1346 1318
1347 fringe_faces [bn] = face_id; 1319 fringe_faces[n] = face_id;
1348 1320
1349 return Qnil; 1321 return Qnil;
1350} 1322}