struct fringe_bitmap
{
- unsigned char *bits;
+ unsigned short *bits;
unsigned height : 8;
unsigned width : 8;
unsigned period : 8;
...xx...
...xx...
*/
-static unsigned char unknown_bits[] = {
+static unsigned short unknown_bits[] = {
0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
/* An arrow like this: `<-'. */
..xx....
...xx...
*/
-static unsigned char left_arrow_bits[] = {
+static unsigned short left_arrow_bits[] = {
0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
....xx..
...xx...
*/
-static unsigned char right_arrow_bits[] = {
+static unsigned short right_arrow_bits[] = {
0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
...xx...
...xx...
*/
-static unsigned char up_arrow_bits[] = {
+static unsigned short up_arrow_bits[] = {
0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
..xxxx..
...xx...
*/
-static unsigned char down_arrow_bits[] = {
+static unsigned short down_arrow_bits[] = {
0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
/* Marker for continued lines. */
..xxxx..
..xxxxx.
*/
-static unsigned char continued_bits[] = {
+static unsigned short continued_bits[] = {
0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
/* Marker for continuation lines. */
..xxxx..
.xxxxx..
*/
-static unsigned char continuation_bits[] = {
+static unsigned short continuation_bits[] = {
0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
/* Overlay arrow bitmap. A triangular arrow. */
xxxx....
xx......
*/
-static unsigned char ov_bits[] = {
+static unsigned short ov_bits[] = {
0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
#if 0
....xxxx
......xx
*/
-static unsigned char rev_ov_bits[] = {
+static unsigned short rev_ov_bits[] = {
0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
#endif
xx......
........
*/
-static unsigned char top_left_angle_bits[] = {
+static unsigned short top_left_angle_bits[] = {
0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00};
/* First line bitmap. An right-up angle. */
......xx
........
*/
-static unsigned char top_right_angle_bits[] = {
+static unsigned short top_right_angle_bits[] = {
0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
/* Last line bitmap. An left-down angle. */
xxxxxx..
xxxxxx..
*/
-static unsigned char bottom_left_angle_bits[] = {
+static unsigned short bottom_left_angle_bits[] = {
0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
/* Last line bitmap. An right-down angle. */
..xxxxxx
..xxxxxx
*/
-static unsigned char bottom_right_angle_bits[] = {
+static unsigned short bottom_right_angle_bits[] = {
0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
/* First/last line bitmap. An left bracket. */
xxxxxx..
xxxxxx..
*/
-static unsigned char left_bracket_bits[] = {
+static unsigned short left_bracket_bits[] = {
0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
/* First/last line bitmap. An right bracket. */
..xxxxxx
..xxxxxx
*/
-static unsigned char right_bracket_bits[] = {
+static unsigned short right_bracket_bits[] = {
0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
/* Filled box cursor bitmap. A filled box; max 13 pixels high. */
xxxxxxx.
xxxxxxx.
*/
-static unsigned char filled_box_cursor_bits[] = {
+static unsigned short filled_box_cursor_bits[] = {
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
/* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */
x.....x.
xxxxxxx.
*/
-static unsigned char hollow_box_cursor_bits[] = {
+static unsigned short hollow_box_cursor_bits[] = {
0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
/* Bar cursor bitmap. A vertical bar; max 13 pixels high. */
xx......
xx......
*/
-static unsigned char bar_cursor_bits[] = {
+static unsigned short bar_cursor_bits[] = {
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
/* HBar cursor bitmap. A horisontal bar; 2 pixels high. */
xxxxxxx.
xxxxxxx.
*/
-static unsigned char hbar_cursor_bits[] = {
+static unsigned short hbar_cursor_bits[] = {
0xfe, 0xfe};
..xxxx..
........
*/
-static unsigned char zv_bits[] = {
+static unsigned short zv_bits[] = {
0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
.x....x.
.xxxxxx.
*/
-static unsigned char hollow_square_bits[] = {
+static unsigned short hollow_square_bits[] = {
0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
+#define BYTES_PER_BITMAP_ROW (sizeof (unsigned short))
+#define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
+#define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits)
-#define FRBITS(bits) bits, sizeof bits
struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] =
{
{ NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
switch (w->phys_cursor_type)
{
case HOLLOW_BOX_CURSOR:
- if (row->visible_height >= sizeof(hollow_box_cursor_bits))
+ if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits))
cursor = HOLLOW_BOX_CURSOR_BITMAP;
else
cursor = HOLLOW_SQUARE_BITMAP;
/* Initialize bitmap bit.
- On X and MAC, we bit-swap the built-in bitmaps.
- On W32, there's no need to do this.
+
+ On X, we bit-swap the built-in bitmaps and reduce bitmap
+ from short to char array if width is <= 8 bits.
+
+ On W32 and MAC, there's no need to do this.
*/
void
{
if (once_p || fb->dynamic)
{
-#if defined (HAVE_X_WINDOWS) || defined (MAC_OS)
- unsigned char *bits = fb->bits;
+#if defined (HAVE_X_WINDOWS)
+ static unsigned char swap_nibble[16]
+ = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
+ 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
+ 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
+ 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
+ unsigned short *bits = fb->bits;
int j;
- for (j = 0; j < fb->height; j++)
+
+ if (fb->width <= 8)
+ {
+ unsigned char *cbits = (unsigned char *)fb->bits;
+ for (j = 0; j < fb->height; j++)
+ {
+ unsigned short b = *bits++;
+ unsigned char c;
+ c = (unsigned char)((swap_nibble[b & 0xf] << 4)
+ | (swap_nibble[(b>>4) & 0xf]));
+ *cbits++ = (c >> (8 - fb->width));
+ }
+ }
+ else
{
- static unsigned char swap_nibble[16]
- = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
- 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
- 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
- 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
-
- unsigned char b = *bits;
- *bits++ = (unsigned short)((swap_nibble[b & 0xf]<<4)
- | (swap_nibble[(b>>4) & 0xf]));
+ for (j = 0; j < fb->height; j++)
+ {
+ unsigned short b = *bits;
+ b = (unsigned short)((swap_nibble[b & 0xf] << 12)
+ | (swap_nibble[(b>>4) & 0xf] << 8)
+ | (swap_nibble[(b>>8) & 0xf] << 4)
+ | (swap_nibble[(b>>12) & 0xf]));
+ *bits++ = (b >> (16 - fb->width));
+ }
}
#endif
}
DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap,
1, 5, 0,
doc: /* Define a fringe bitmap from BITS of height HEIGHT and width WIDTH.
-BITS is either a string or a vector. If HEIGHT is nil, use number of bytes
-in BITS. If WIDTH is zero, default to 8. Optional forth arg ALIGN may be
-one of `top', `center', or `bottom', indicating the positioning of the
-bitmap relative to the rows where it is used; the default is to center the
-bitmap. Fourth arg may also be a list (ALIGN PERIODIC) where
-PERIODIC non-nil specifies that the bitmap should be repeated.
+BITS is either a string or a vector of integers.
+HEIGHT is height of bitmap. If HEIGHT is nil, use length of BITS.
+WIDTH must be an integer between 1 and 16, or nil which defaults to 8.
+Optional forth arg ALIGN may be one of `top', `center', or `bottom',
+indicating the positioning of the bitmap relative to the rows where it
+is used; the default is to center the bitmap. Fourth arg may also be a
+list (ALIGN PERIODIC) where PERIODIC non-nil specifies that the bitmap
+should be repeated.
Optional fifth argument WHICH is bitmap number to redefine.
Return new bitmap number, or nil of no more free bitmap slots. */)
(bits, height, width, align, which)
{
Lisp_Object len;
int n, h, i, j;
- unsigned char *b;
+ unsigned short *b;
struct fringe_bitmap fb, *xfb;
int fill1 = 0, fill2 = 0;
fb.dynamic = 1;
- xfb = (struct fringe_bitmap *)xmalloc (sizeof fb + fb.height);
- fb.bits = b = (unsigned char *)(xfb+1);
+ xfb = (struct fringe_bitmap *)xmalloc (sizeof fb
+ + fb.height * BYTES_PER_BITMAP_ROW);
+ fb.bits = b = (unsigned short *)(xfb+1);
bzero (b, fb.height);
j = 0;