[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/fringe.c [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/fringe.c [emacs-unicode-2] |
Date: |
Wed, 29 Sep 2004 21:43:37 -0400 |
Index: emacs/src/fringe.c
diff -c emacs/src/fringe.c:1.10.2.2 emacs/src/fringe.c:1.10.2.3
*** emacs/src/fringe.c:1.10.2.2 Wed Sep 29 07:22:18 2004
--- emacs/src/fringe.c Thu Sep 30 01:20:35 2004
***************
*** 445,471 ****
{ FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 },
};
! static struct fringe_bitmap *fringe_bitmaps[MAX_FRINGE_BITMAPS];
! static unsigned fringe_faces[MAX_FRINGE_BITMAPS];
static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
! /* Return 1 if FRINGE_ID is a valid fringe bitmap id. */
int
! valid_fringe_bitmap_p (bitmap)
Lisp_Object bitmap;
{
int bn;
if (!INTEGERP (bitmap))
return 0;
bn = XINT (bitmap);
! return (bn >= NO_FRINGE_BITMAP
! && bn < max_used_fringe_bitmap
! && (bn < MAX_STANDARD_FRINGE_BITMAPS
! || fringe_bitmaps[bn] != NULL));
}
/* Get fringe bitmap name for bitmap number BN.
--- 445,478 ----
{ FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 },
};
! static struct fringe_bitmap **fringe_bitmaps;
! static unsigned *fringe_faces;
! static int max_fringe_bitmaps;
static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
!
! /* Lookup bitmap number for symbol BITMAP.
! Return 0 if not a bitmap. */
int
! lookup_fringe_bitmap (bitmap)
Lisp_Object bitmap;
{
int bn;
+ bitmap = Fget (bitmap, Qfringe);
if (!INTEGERP (bitmap))
return 0;
bn = XINT (bitmap);
! if (bn > NO_FRINGE_BITMAP
! && bn < max_used_fringe_bitmap
! && (bn < MAX_STANDARD_FRINGE_BITMAPS
! || fringe_bitmaps[bn] != NULL))
! return bn;
!
! return 0;
}
/* Get fringe bitmap name for bitmap number BN.
***************
*** 501,542 ****
}
- /* Resolve a BITMAP parameter.
-
- An INTEGER, corresponding to a bitmap number.
- A STRING which is interned to a symbol.
- A SYMBOL which has a fringe property which is a bitmap number.
- */
-
- static int
- resolve_fringe_bitmap (bitmap, namep)
- Lisp_Object bitmap;
- Lisp_Object *namep;
- {
- if (namep)
- *namep = Qnil;
-
- if (STRINGP (bitmap))
- bitmap = intern (SDATA (bitmap));
-
- if (SYMBOLP (bitmap))
- {
- if (namep)
- *namep = bitmap;
- bitmap = Fget (bitmap, Qfringe);
- }
-
- if (valid_fringe_bitmap_p (bitmap))
- {
- if (namep && NILP (*namep))
- *namep = get_fringe_bitmap_name (XINT (bitmap));
- return XINT (bitmap);
- }
-
- return -1;
- }
-
-
/* Draw the bitmap WHICH in one of the left or right fringes of
window W. ROW is the glyph row for which to display the bitmap; it
determines the vertical position at which the bitmap has to be
--- 508,513 ----
***************
*** 1068,1074 ****
}
! void
destroy_fringe_bitmap (n)
int n;
{
--- 1039,1047 ----
}
! /* Free resources used by a user-defined bitmap. */
!
! int
destroy_fringe_bitmap (n)
int n;
{
***************
*** 1079,1085 ****
fbp = &fringe_bitmaps[n];
if (*fbp && (*fbp)->dynamic)
{
! if (rif->destroy_fringe_bitmap)
rif->destroy_fringe_bitmap (n);
xfree (*fbp);
*fbp = NULL;
--- 1052,1058 ----
fbp = &fringe_bitmaps[n];
if (*fbp && (*fbp)->dynamic)
{
! if (rif && rif->destroy_fringe_bitmap)
rif->destroy_fringe_bitmap (n);
xfree (*fbp);
*fbp = NULL;
***************
*** 1099,1118 ****
Lisp_Object bitmap;
{
int n;
- Lisp_Object sym;
! n = resolve_fringe_bitmap (bitmap, &sym);
! if (n < 0)
return Qnil;
destroy_fringe_bitmap (n);
! if (SYMBOLP (sym))
{
! Vfringe_bitmaps = Fdelq (sym, Vfringe_bitmaps);
/* It would be better to remove the fringe property. */
! Fput (sym, Qfringe, Qnil);
}
return Qnil;
}
--- 1072,1092 ----
Lisp_Object bitmap;
{
int n;
! CHECK_SYMBOL (bitmap);
! n = lookup_fringe_bitmap (bitmap);
! if (!n)
return Qnil;
destroy_fringe_bitmap (n);
! if (n >= MAX_STANDARD_FRINGE_BITMAPS)
{
! Vfringe_bitmaps = Fdelq (bitmap, Vfringe_bitmaps);
/* It would be better to remove the fringe property. */
! Fput (bitmap, Qfringe, Qnil);
}
+
return Qnil;
}
***************
*** 1185,1191 ****
{
destroy_fringe_bitmap (which);
! if (rif->define_fringe_bitmap)
rif->define_fringe_bitmap (which, fb->bits, fb->height, fb->width);
fringe_bitmaps[which] = fb;
--- 1159,1165 ----
{
destroy_fringe_bitmap (which);
! if (rif && rif->define_fringe_bitmap)
rif->define_fringe_bitmap (which, fb->bits, fb->height, fb->width);
fringe_bitmaps[which] = fb;
***************
*** 1216,1227 ****
unsigned short *b;
struct fringe_bitmap fb, *xfb;
int fill1 = 0, fill2 = 0;
- Lisp_Object sym;
! n = resolve_fringe_bitmap (bitmap, &sym);
!
! if (NILP (sym) || INTEGERP (sym))
! sym = wrong_type_argument (Qsymbolp, bitmap);
if (!STRINGP (bits) && !VECTORP (bits))
bits = wrong_type_argument (Qstringp, bits);
--- 1190,1197 ----
unsigned short *b;
struct fringe_bitmap fb, *xfb;
int fill1 = 0, fill2 = 0;
! CHECK_SYMBOL (bitmap);
if (!STRINGP (bits) && !VECTORP (bits))
bits = wrong_type_argument (Qstringp, bits);
***************
*** 1274,1296 ****
else if (!NILP (align) && !EQ (align, Qcenter))
error ("Bad align argument");
! if (n < 0)
{
! if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS)
n = max_used_fringe_bitmap++;
else
{
for (n = MAX_STANDARD_FRINGE_BITMAPS;
! n < MAX_FRINGE_BITMAPS;
n++)
if (fringe_bitmaps[n] == NULL)
break;
! if (n == MAX_FRINGE_BITMAPS)
! error ("Cannot define more fringe bitmaps");
}
! Vfringe_bitmaps = Fcons (sym, Vfringe_bitmaps);
! Fput (sym, Qfringe, make_number (n));
}
fb.dynamic = 1;
--- 1244,1285 ----
else if (!NILP (align) && !EQ (align, Qcenter))
error ("Bad align argument");
! n = lookup_fringe_bitmap (bitmap);
! if (!n)
{
! if (max_used_fringe_bitmap < max_fringe_bitmaps)
n = max_used_fringe_bitmap++;
else
{
for (n = MAX_STANDARD_FRINGE_BITMAPS;
! n < max_fringe_bitmaps;
n++)
if (fringe_bitmaps[n] == NULL)
break;
!
! if (n == max_fringe_bitmaps)
! {
! if ((max_fringe_bitmaps + 20) > MAX_FRINGE_BITMAPS)
! error ("No free fringe bitmap slots");
!
! i = max_fringe_bitmaps;
! max_fringe_bitmaps += 20;
! fringe_bitmaps
! = ((struct fringe_bitmap **)
! xrealloc (fringe_bitmaps, max_fringe_bitmaps * sizeof
(struct fringe_bitmap *)));
! fringe_faces
! = (unsigned *) xrealloc (fringe_faces, max_fringe_bitmaps *
sizeof (unsigned));
!
! for (; i < max_fringe_bitmaps; i++)
! {
! fringe_bitmaps[i] = NULL;
! fringe_faces[i] = FRINGE_FACE_ID;
! }
! }
}
! Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps);
! Fput (bitmap, Qfringe, make_number (n));
}
fb.dynamic = 1;
***************
*** 1318,1324 ****
init_fringe_bitmap (n, xfb, 0);
! return sym;
}
DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face,
Sset_fringe_bitmap_face,
--- 1307,1313 ----
init_fringe_bitmap (n, xfb, 0);
! return bitmap;
}
DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face,
Sset_fringe_bitmap_face,
***************
*** 1328,1338 ****
(bitmap, face)
Lisp_Object bitmap, face;
{
! int bn;
int face_id;
! bn = resolve_fringe_bitmap (bitmap, 0);
! if (bn < 0)
error ("Undefined fringe bitmap");
if (!NILP (face))
--- 1317,1328 ----
(bitmap, face)
Lisp_Object bitmap, face;
{
! int n;
int face_id;
! CHECK_SYMBOL (bitmap);
! n = lookup_fringe_bitmap (bitmap);
! if (!n)
error ("Undefined fringe bitmap");
if (!NILP (face))
***************
*** 1344,1350 ****
else
face_id = FRINGE_FACE_ID;
! fringe_faces [bn] = face_id;
return Qnil;
}
--- 1334,1340 ----
else
face_id = FRINGE_FACE_ID;
! fringe_faces[n] = face_id;
return Qnil;
}
***************
*** 1433,1441 ****
{
int i;
! bzero (fringe_bitmaps, sizeof fringe_bitmaps);
! for (i = 0; i < MAX_FRINGE_BITMAPS; i++)
! fringe_faces[i] = FRINGE_FACE_ID;
}
#ifdef HAVE_NTGUI
--- 1423,1440 ----
{
int i;
! max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
!
! fringe_bitmaps
! = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct
fringe_bitmap *));
! fringe_faces
! = (unsigned *) xmalloc (max_fringe_bitmaps * sizeof (unsigned));
!
! for (i = 0; i < max_fringe_bitmaps; i++)
! {
! fringe_bitmaps[i] = NULL;
! fringe_faces[i] = FRINGE_FACE_ID;
! }
}
#ifdef HAVE_NTGUI
***************
*** 1445,1450 ****
--- 1444,1452 ----
{
enum fringe_bitmap_type bt;
+ if (!rif)
+ return;
+
for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
{
struct fringe_bitmap *fb = &standard_bitmaps[bt];
***************
*** 1458,1463 ****
--- 1460,1468 ----
/* Destroy row bitmaps. */
int bt;
+ if (!rif)
+ return;
+
for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++)
rif->destroy_fringe_bitmap (bt);
}