1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23: #include <config.h>
24: #include <stdio.h>
25:
26: #include "lisp.h"
27: #include "frame.h"
28: #include "window.h"
29: #include "dispextern.h"
30: #include "buffer.h"
31: #include "blockinput.h"
32:
33: #ifdef HAVE_WINDOW_SYSTEM
34:
35: extern Lisp_Object Qfringe;
36: extern Lisp_Object Qtop, Qbottom, Qcenter;
37: extern Lisp_Object Qup, Qdown, Qleft, Qright;
38:
39:
40:
41: Lisp_Object Voverflow_newline_into_fringe;
42:
43:
44:
45:
46:
47:
48:
49:
50: Lisp_Object Vfringe_bitmaps;
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86: extern Lisp_Object Qunknown;
87: Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow;
88: Lisp_Object Qempty_line, Qtop_bottom;
89: extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
90: Lisp_Object Qhollow_small;
91:
92: enum fringe_bitmap_align
93: {
94: ALIGN_BITMAP_CENTER = 0,
95: ALIGN_BITMAP_TOP,
96: ALIGN_BITMAP_BOTTOM
97: };
98:
99: struct fringe_bitmap
100: {
101: unsigned short *bits;
102: unsigned height : 8;
103: unsigned width : 8;
104: unsigned period : 8;
105: unsigned align : 2;
106: unsigned dynamic : 1;
107: };
108:
109: ^L
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127: static unsigned short question_mark_bits[] = {
128: 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141: static unsigned short left_arrow_bits[] = {
142: 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156: static unsigned short right_arrow_bits[] = {
157: 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171: static unsigned short up_arrow_bits[] = {
172: 0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186: static unsigned short down_arrow_bits[] = {
187: 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200: static unsigned short left_curly_arrow_bits[] = {
201: 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214: static unsigned short right_curly_arrow_bits[] = {
215: 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228: static unsigned short left_triangle_bits[] = {
229: 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242: static unsigned short right_triangle_bits[] = {
243: 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256: static unsigned short top_left_angle_bits[] = {
257: 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00};
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270: static unsigned short top_right_angle_bits[] = {
271: 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284: static unsigned short bottom_left_angle_bits[] = {
285: 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298: static unsigned short bottom_right_angle_bits[] = {
299: 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314: static unsigned short left_bracket_bits[] = {
315: 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330: static unsigned short right_bracket_bits[] = {
331: 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349: static unsigned short filled_rectangle_bits[] = {
350: 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368: static unsigned short hollow_rectangle_bits[] = {
369: 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380: static unsigned short hollow_square_bits[] = {
381: 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392: static unsigned short filled_square_bits[] = {
393: 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e};
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411: static unsigned short vertical_bar_bits[] = {
412: 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
413:
414:
415:
416:
417:
418:
419: static unsigned short horizontal_bar_bits[] = {
420: 0xfe, 0xfe};
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433: static unsigned short empty_line_bits[] = {
434: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
435: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
436: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
437: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
438: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
439: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
440: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
441: 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
442:
443:
444: #define BYTES_PER_BITMAP_ROW (sizeof (unsigned short))
445: #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
446: #define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits)
447:
448:
449:
450:
451: struct fringe_bitmap standard_bitmaps[] =
452: {
453: { NULL, 0, 0, 0, 0, 0 },
454: { FRBITS (question_mark_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
455: { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
456: { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
457: { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
458: { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
459: { FRBITS (left_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
460: { FRBITS (right_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
461: { FRBITS (left_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
462: { FRBITS (right_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
463: { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
464: { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
465: { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
466: { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
467: { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
468: { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
469: { FRBITS (filled_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
470: { FRBITS (hollow_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
471: { FRBITS (filled_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
472: { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
473: { FRBITS (vertical_bar_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
474: { FRBITS (horizontal_bar_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
475: { FRBITS (empty_line_bits), 8, 3, ALIGN_BITMAP_TOP, 0 },
476: };
477:
478: #define NO_FRINGE_BITMAP 0
479: #define UNDEF_FRINGE_BITMAP 1
480: #define MAX_STANDARD_FRINGE_BITMAPS (sizeof(standard_bitmaps)/sizeof(standard_bitmaps[0]))
481:
482: static struct fringe_bitmap **fringe_bitmaps;
483: static Lisp_Object *fringe_faces;
484: static int max_fringe_bitmaps;
485:
486: static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
487:
488:
489:
490:
491:
492: int
493: lookup_fringe_bitmap (bitmap)
494: Lisp_Object bitmap;
495: {
496: int bn;
497:
498: bitmap = Fget (bitmap, Qfringe);
499: if (!INTEGERP (bitmap))
500: return 0;
501:
502: bn = XINT (bitmap);
503: if (bn > NO_FRINGE_BITMAP
504: && bn < max_used_fringe_bitmap
505: && (bn < MAX_STANDARD_FRINGE_BITMAPS
506: || fringe_bitmaps[bn] != NULL))
507: return bn;
508:
509: return 0;
510: }
511:
512:
513:
514:
515:
516:
517:
518:
519: static Lisp_Object
520: get_fringe_bitmap_name (bn)
521: int bn;
522: {
523: Lisp_Object bitmaps;
524: Lisp_Object num;
525:
526:
527: if (bn <= 0)
528: return Qnil;
529:
530: bitmaps = Vfringe_bitmaps;
531: num = make_number (bn);
532:
533: while (CONSP (bitmaps))
534: {
535: Lisp_Object bitmap = XCAR (bitmaps);
536: if (EQ (num, Fget (bitmap, Qfringe)))
537: return bitmap;
538: bitmaps = XCDR (bitmaps);
539: }
540:
541: return num;
542: }
543:
544:
545:
546:
547:
548:
549:
550:
551:
552: static void
553: draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
554: struct window *w;
555: struct glyph_row *row;
556: int left_p, overlay;
557: int which;
558: {
559: struct frame *f = XFRAME (WINDOW_FRAME (w));
560: struct draw_fringe_bitmap_params p;
561: struct fringe_bitmap *fb;
562: int period;
563: int face_id = DEFAULT_FACE_ID;
564:
565: p.cursor_p = 0;
566: p.overlay_p = (overlay & 1) == 1;
567: p.cursor_p = (overlay & 2) == 2;
568:
569: if (which != NO_FRINGE_BITMAP)
570: {
571: }
572: else if (left_p)
573: {
574: which = row->left_fringe_bitmap;
575: face_id = row->left_fringe_face_id;
576: }
577: else
578: {
579: which = row->right_fringe_bitmap;
580: face_id = row->right_fringe_face_id;
581: }
582:
583: if (face_id == DEFAULT_FACE_ID)
584: {
585: Lisp_Object face;
586:
587: if ((face = fringe_faces[which], NILP (face))
588: || (face_id = lookup_derived_face (f, face, 'A', FRINGE_FACE_ID, 0),
589: face_id < 0))
590: face_id = FRINGE_FACE_ID;
591: }
592:
593: fb = fringe_bitmaps[which];
594: if (fb == NULL)
595: fb = &standard_bitmaps[which < MAX_STANDARD_FRINGE_BITMAPS
596: ? which : UNDEF_FRINGE_BITMAP];
597:
598: period = fb->period;
599:
600:
601: p.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
602:
603: p.which = which;
604: p.bits = fb->bits;
605: p.wd = fb->width;
606:
607: p.h = fb->height;
608: p.dh = (period > 0 ? (p.y % period) : 0);
609: p.h -= p.dh;
610:
611: if (p.h > row->height)
612: p.h = row->height;
613:
614: p.face = FACE_FROM_ID (f, face_id);
615:
616: if (p.face == NULL)
617: {
618:
619:
620: return;
621: }
622:
623: PREPARE_FACE_FOR_DISPLAY (f, p.face);
624:
625: