aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-02-21 15:57:00 +0000
committerKaroly Lorentey2006-02-21 15:57:00 +0000
commit36b98f827848d2b1ece6aee7a372902e78120e98 (patch)
tree51d7af230b08c05b1733c11b89d27aadd3b8dda1 /src
parent0383bfd7963905724df93bed01ddeb3b7064222e (diff)
parent8ea094cffae04a654ddb76700fa86fa7e8d03eef (diff)
downloademacs-36b98f827848d2b1ece6aee7a372902e78120e98.tar.gz
emacs-36b98f827848d2b1ece6aee7a372902e78120e98.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-105 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-106 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-107 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-108 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-109 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-110 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-37 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-516
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog80
-rw-r--r--src/Makefile.in4
-rw-r--r--src/buffer.c48
-rw-r--r--src/buffer.h6
-rw-r--r--src/fringe.c435
-rw-r--r--src/macterm.c324
-rw-r--r--src/regex.c53
-rw-r--r--src/xfns.c10
8 files changed, 685 insertions, 275 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f2a6e1e2752..c016dc46e4b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,83 @@
12006-02-21 Kim F. Storm <storm@cua.dk>
2
3 * fringe.c (syms_of_fringe) <fringe-bitmaps>: Doc fix.
4
52006-02-21 Zhang Wei <brep@newsmth.org>
6
7 * xfns.c (Fx_file_dialog, Motif and GTK): DECODE_FILE before
8 returning it.
9
102006-02-21 Giorgos Keramidas <keramida@ceid.upatras.gr> (tiny change)
11
12 * fringe.c (horizontal_bar_bits): Rename from `horisontal_bar_bits'.
13 (standard_bitmaps): Use it.
14
152006-02-21 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
16
17 * macterm.c (mac_draw_string_common): Remove arg MODE. New arg
18 BG_WIDTH. All uses changed. Draw background if BG_WIDTH is not zero.
19 (mac_draw_image_string, mac_draw_image_string_16): New arg BG_WIDTH.
20 [USE_CG_TEXT_DRAWING] (mac_draw_image_string_cg): Rename from
21 mac_draw_string_cg. New arg BG_WIDTH. All uses changed. Draw
22 background if BG_WIDTH is not zero. Use float constants as
23 divisors instead of double. Use alloca instead of xmalloc/xfree.
24 (x_draw_glyph_string_background, x_draw_glyph_string_foreground)
25 [!MAC_OS8 || USE_ATSUI]: Background may be drawn using
26 mac_draw_image_string* functions.
27 (XLoadQueryFont) [MAC_OS8 && USE_ATSUI]: Don't adjust heights of
28 some fonts when srcCopy text transfer mode might be used.
29 (mac_begin_clip, mac_end_clip): Check if region is empty.
30 (mac_set_clip_rectangles): When resetting clip region, make it
31 empty instead of disposing of it.
32
332006-02-20 Kim F. Storm <storm@cua.dk>
34
35 * Makefile.in: Add fringe.elc to WINDOW_SUPPORT.
36
37 * buffer.h (struct buffer): New members fringe_indicator_alist and
38 fringe_cursor_alist.
39
40 * buffer.c (init_buffer_once): Set dummy default values for
41 fringe-indicator-alist and fringe-cursor-alist. The proper
42 default values are set by pre-loading fringe.el.
43 (syms_of_buffer): defvar_per_buffer new fringe-indicator-alist and
44 fringe-cursor-alist buffer-local variables and defvar_lisp_nopro
45 corresponding default- variables.
46
47 * fringe.c (enum fringe_bitmap_type): Remove. Change all uses
48 to use `int'.
49 (NO_FRINGE_BITMAP, UNDEF_FRINGE_BITMAP, MAX_STANDARD_FRINGE_BITMAPS):
50 Define explicitly.
51 (Qtruncation, Qcontinuation, Qempty_line, Qtop_bottom)
52 (Qhollow_small): New variables.
53 (syms_of_fringe): Intern and staticpro them.
54 (question_mark_bits): Rename from unknown_bits.
55 (left_curly_arrow_bits): Rename from continuation_bits.
56 (right_curly_arrow_bits): Rename from continued_bits.
57 (left_triangle_bits): Rename from ov_bits.
58 (right_triangle_bits): Added.
59 (filled_rectangle_bits): Rename from filled_box_cursor_bits.
60 (hollow_rectangle_bits): Rename from hollow_box_cursor_bits.
61 (filled_square_bits): Added.
62 (vertical_bar_bits): Rename from bar_cursor_bits.
63 (horizontal_bar_bits): Rename from hbar_cursor_bits.
64 (empty_line_bits): Rename from zv_bits.
65 (standard_bitmaps): Update to use new names.
66 (draw_fringe_bitmap_1): Make static.
67 (get_logical_cursor_bitmap, get_logical_fringe_bitmap): New functions
68 to map from logical cursors and indicators to physical bitmaps.
69 (draw_fringe_bitmap): Resolve fringe cursor and overlay-arrow
70 bitmaps using symbol names instead of bitmap numbers.
71 (update_window_fringes): Use logical indicator symbol names
72 instead of bitmap numbers for logical. Add bitmap cache.
73 (LEFT_FRINGE, RIGHT_FRINGE): New helper macros.
74
752006-02-20 Chong Yidong <cyd@stupidchicken.com>
76
77 * regex.c: Revert 2006-02-19 change.
78 (xmalloc, xrealloc): Define these when not linked to Emacs.
79 Redefine malloc -> xmalloc, realloc -> xrealloc as in Emacs case.
80
12006-02-19 Luc Teirlinck <teirllm@auburn.edu> 812006-02-19 Luc Teirlinck <teirllm@auburn.edu>
2 82
3 * regex.c (extend_range_table_work_area): Fix typo. 83 * regex.c (extend_range_table_work_area): Fix typo.
diff --git a/src/Makefile.in b/src/Makefile.in
index 32f339bb139..b63ae34aa2b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -678,11 +678,11 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(allocaobj) $(widgetobj) $(LIBO
678 678
679#ifdef HAVE_WINDOW_SYSTEM 679#ifdef HAVE_WINDOW_SYSTEM
680#ifdef HAVE_X_WINDOWS 680#ifdef HAVE_X_WINDOWS
681#define WINDOW_SUPPORT ${lispsource}image.elc \ 681#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
682 ${lispsource}international/fontset.elc ${lispsource}dnd.elc \ 682 ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
683 ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc 683 ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc
684#else 684#else
685#define WINDOW_SUPPORT ${lispsource}image.elc \ 685#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
686 ${lispsource}international/fontset.elc ${lispsource}dnd.elc \ 686 ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
687 ${lispsource}tool-bar.elc ${lispsource}mwheel.elc 687 ${lispsource}tool-bar.elc ${lispsource}mwheel.elc
688#endif 688#endif
diff --git a/src/buffer.c b/src/buffer.c
index dae07edf359..e1caaac5f89 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5023,6 +5023,8 @@ init_buffer_once ()
5023 buffer_defaults.vertical_scroll_bar_type = Qt; 5023 buffer_defaults.vertical_scroll_bar_type = Qt;
5024 buffer_defaults.indicate_empty_lines = Qnil; 5024 buffer_defaults.indicate_empty_lines = Qnil;
5025 buffer_defaults.indicate_buffer_boundaries = Qnil; 5025 buffer_defaults.indicate_buffer_boundaries = Qnil;
5026 buffer_defaults.fringe_indicator_alist = Qnil;
5027 buffer_defaults.fringe_cursor_alist = Qnil;
5026 buffer_defaults.scroll_up_aggressively = Qnil; 5028 buffer_defaults.scroll_up_aggressively = Qnil;
5027 buffer_defaults.scroll_down_aggressively = Qnil; 5029 buffer_defaults.scroll_down_aggressively = Qnil;
5028 buffer_defaults.display_time = Qnil; 5030 buffer_defaults.display_time = Qnil;
@@ -5094,6 +5096,8 @@ init_buffer_once ()
5094 XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx; 5096 XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx;
5095 XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx; 5097 XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
5096 XSETFASTINT (buffer_local_flags.indicate_buffer_boundaries, idx); ++idx; 5098 XSETFASTINT (buffer_local_flags.indicate_buffer_boundaries, idx); ++idx;
5099 XSETFASTINT (buffer_local_flags.fringe_indicator_alist, idx); ++idx;
5100 XSETFASTINT (buffer_local_flags.fringe_cursor_alist, idx); ++idx;
5097 XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx; 5101 XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
5098 XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx; 5102 XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
5099 XSETFASTINT (buffer_local_flags.header_line_format, idx); ++idx; 5103 XSETFASTINT (buffer_local_flags.header_line_format, idx); ++idx;
@@ -5387,6 +5391,16 @@ This is the same as (default-value 'indicate-empty-lines). */);
5387 doc: /* Default value of `indicate-buffer-boundaries' for buffers that don't override it. 5391 doc: /* Default value of `indicate-buffer-boundaries' for buffers that don't override it.
5388This is the same as (default-value 'indicate-buffer-boundaries). */); 5392This is the same as (default-value 'indicate-buffer-boundaries). */);
5389 5393
5394 DEFVAR_LISP_NOPRO ("default-fringe-indicator-alist",
5395 &buffer_defaults.fringe_indicator_alist,
5396 doc: /* Default value of `fringe-indicator-alist' for buffers that don't override it.
5397This is the same as (default-value 'fringe-indicator-alist'). */);
5398
5399 DEFVAR_LISP_NOPRO ("default-fringe-cursor-alist",
5400 &buffer_defaults.fringe_cursor_alist,
5401 doc: /* Default value of `fringe-cursor-alist' for buffers that don't override it.
5402This is the same as (default-value 'fringe-cursor-alist'). */);
5403
5390 DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively", 5404 DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",
5391 &buffer_defaults.scroll_up_aggressively, 5405 &buffer_defaults.scroll_up_aggressively,
5392 doc: /* Default value of `scroll-up-aggressively'. 5406 doc: /* Default value of `scroll-up-aggressively'.
@@ -5732,6 +5746,40 @@ left fringe, the bottom angle bitmap in right fringe, and both arrow
5732bitmaps in right fringe. To show just the angle bitmaps in the left 5746bitmaps in right fringe. To show just the angle bitmaps in the left
5733fringe, but no arrow bitmaps, use ((top . left) (bottom . left)). */); 5747fringe, but no arrow bitmaps, use ((top . left) (bottom . left)). */);
5734 5748
5749 DEFVAR_PER_BUFFER ("fringe-indicator-alist",
5750 &current_buffer->fringe_indicator_alist, Qnil,
5751 doc: /* *Mapping from logical to physical fringe indicator bitmaps.
5752The value is an alist where each element (INDICATOR . BITMAPS)
5753specifies the fringe bitmaps used to display a specific logical
5754fringe indicator.
5755
5756INDICATOR specifies the logical indicator type which is one of the
5757following symbols: `truncation' , `continuation', `overlay-arrow',
5758`top', `bottom', `up', `down', `one-line', `empty-line', or `unknown'.
5759
5760BITMAPS is list of symbols (LEFT RIGHT [LEFT1 RIGHT1]) which specifies
5761the actual bitmap shown in the left or right fringe for the logical
5762indicator. LEFT and RIGHT are the bitmaps shown in the left and/or
5763right fringe for the specific indicator. The LEFT1 or RIGHT1 bitmaps
5764are used only for the `bottom' and `one-line' indicators when the last
5765(only) line in has no final newline. BITMAPS may also be a single
5766symbol which is used in both left and right fringes. */);
5767
5768 DEFVAR_PER_BUFFER ("fringe-cursor-alist",
5769 &current_buffer->fringe_cursor_alist, Qnil,
5770 doc: /* *Mapping from logical to physical fringe cursor bitmaps.
5771The value is an alist where each element (CURSOR . BITMAP)
5772specifies the fringe bitmaps used to display a specific logical
5773cursor type in the fringe.
5774
5775CURSOR specifies the logical cursor type which is one of the following
5776symbols: `box' , `hollow', `bar', `hbar', or `hollow-small'. The last
5777one is used to show a hollow cursor on narrow lines display lines
5778where the normal hollow cursor will not fit.
5779
5780BITMAP is the corresponding fringe bitmap shown for the logical
5781cursor type. */);
5782
5735 DEFVAR_PER_BUFFER ("scroll-up-aggressively", 5783 DEFVAR_PER_BUFFER ("scroll-up-aggressively",
5736 &current_buffer->scroll_up_aggressively, Qnil, 5784 &current_buffer->scroll_up_aggressively, Qnil,
5737 doc: /* How far to scroll windows upward. 5785 doc: /* How far to scroll windows upward.
diff --git a/src/buffer.h b/src/buffer.h
index 737877f15de..60aa3e7aaed 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -739,6 +739,12 @@ struct buffer
739 /* Non-nil means indicate buffer boundaries and scrolling. */ 739 /* Non-nil means indicate buffer boundaries and scrolling. */
740 Lisp_Object indicate_buffer_boundaries; 740 Lisp_Object indicate_buffer_boundaries;
741 741
742 /* Logical to physical fringe bitmap mappings. */
743 Lisp_Object fringe_indicator_alist;
744
745 /* Logical to physical cursor bitmap mappings. */
746 Lisp_Object fringe_cursor_alist;
747
742 /* Time stamp updated each time this buffer is displayed in a window. */ 748 /* Time stamp updated each time this buffer is displayed in a window. */
743 Lisp_Object display_time; 749 Lisp_Object display_time;
744 750
diff --git a/src/fringe.c b/src/fringe.c
index 991df3bd60d..6a98b852e3e 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -50,31 +50,45 @@ Lisp_Object Voverflow_newline_into_fringe;
50 50
51Lisp_Object Vfringe_bitmaps; 51Lisp_Object Vfringe_bitmaps;
52 52
53enum fringe_bitmap_type 53/* Fringe bitmaps are represented in three different ways:
54{ 54
55 NO_FRINGE_BITMAP = 0, 55 Logical bitmaps are used internally to denote things like
56 UNDEF_FRINGE_BITMAP, 56 'end-of-buffer', 'left-truncation', 'overlay-arrow', etc.
57 LEFT_TRUNCATION_BITMAP, 57
58 RIGHT_TRUNCATION_BITMAP, 58 Physical bitmaps specify the visual appearence of the bitmap,
59 UP_ARROW_BITMAP, 59 e.g. 'bottom-left-angle', 'left-arrow', 'left-triangle', etc.
60 DOWN_ARROW_BITMAP, 60 User defined bitmaps are physical bitmaps.
61 CONTINUED_LINE_BITMAP, 61
62 CONTINUATION_LINE_BITMAP, 62 Internally, fringe bitmaps for a specific display row are
63 OVERLAY_ARROW_BITMAP, 63 represented as a simple integer that is used as an index
64 TOP_LEFT_ANGLE_BITMAP, 64 into the table of all defined bitmaps. This index is stored
65 TOP_RIGHT_ANGLE_BITMAP, 65 in the `fringe' property of the physical bitmap symbol.
66 BOTTOM_LEFT_ANGLE_BITMAP, 66
67 BOTTOM_RIGHT_ANGLE_BITMAP, 67 Logical bitmaps are mapped to physical bitmaps through the
68 LEFT_BRACKET_BITMAP, 68 buffer-local `fringe-indicator-alist' variable.
69 RIGHT_BRACKET_BITMAP, 69
70 FILLED_BOX_CURSOR_BITMAP, 70 Each element of this alist is a cons (LOGICAL . PHYSICAL)
71 HOLLOW_BOX_CURSOR_BITMAP, 71 mapping a logical bitmap to a physical bitmap.
72 HOLLOW_SQUARE_BITMAP, 72 PHYSICAL is either a symbol to use in both left and right fringe,
73 BAR_CURSOR_BITMAP, 73 or a cons of two symbols (LEFT . RIGHT) denoting different
74 HBAR_CURSOR_BITMAP, 74 bitmaps to use in left and right fringe.
75 ZV_LINE_BITMAP, 75
76 MAX_STANDARD_FRINGE_BITMAPS 76 LOGICAL is first looked up in the window's buffer's buffer-local
77}; 77 value of the fringe-indicator-alist variable, and if not present,
78 in the global value of fringe-indicator-alist.
79
80 If LOGICAL is not present in either alist, or the PHYSICAL value
81 found is nil, no bitmap is shown for the logical bitmap.
82
83 The `left-fringe' and `right-fringe' display properties
84 must specify physical bitmap symbols.
85*/
86
87extern Lisp_Object Qunknown;
88Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow;
89Lisp_Object Qempty_line, Qtop_bottom;
90extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
91Lisp_Object Qhollow_small;
78 92
79enum fringe_bitmap_align 93enum fringe_bitmap_align
80{ 94{
@@ -111,7 +125,7 @@ struct fringe_bitmap
111 ...xx... 125 ...xx...
112 ...xx... 126 ...xx...
113*/ 127*/
114static unsigned short unknown_bits[] = { 128static unsigned short question_mark_bits[] = {
115 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18}; 129 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
116 130
117/* An arrow like this: `<-'. */ 131/* An arrow like this: `<-'. */
@@ -173,20 +187,6 @@ static unsigned short up_arrow_bits[] = {
173static unsigned short down_arrow_bits[] = { 187static unsigned short down_arrow_bits[] = {
174 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18}; 188 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
175 189
176/* Marker for continued lines. */
177/*
178 ..xxxx..
179 ..xxxxx.
180 ......xx
181 ..x..xxx
182 ..xxxxxx
183 ..xxxxx.
184 ..xxxx..
185 ..xxxxx.
186*/
187static unsigned short continued_bits[] = {
188 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
189
190/* Marker for continuation lines. */ 190/* Marker for continuation lines. */
191/* 191/*
192 ..xxxx.. 192 ..xxxx..
@@ -198,24 +198,23 @@ static unsigned short continued_bits[] = {
198 ..xxxx.. 198 ..xxxx..
199 .xxxxx.. 199 .xxxxx..
200*/ 200*/
201static unsigned short continuation_bits[] = { 201static unsigned short left_curly_arrow_bits[] = {
202 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; 202 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
203 203
204/* Overlay arrow bitmap. A triangular arrow. */ 204/* Marker for continued lines. */
205/* 205/*
206 xx...... 206 ..xxxx..
207 xxxx.... 207 ..xxxxx.
208 xxxxx... 208 ......xx
209 xxxxxx.. 209 ..x..xxx
210 xxxxxx.. 210 ..xxxxxx
211 xxxxx... 211 ..xxxxx.
212 xxxx.... 212 ..xxxx..
213 xx...... 213 ..xxxxx.
214*/ 214*/
215static unsigned short ov_bits[] = { 215static unsigned short right_curly_arrow_bits[] = {
216 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0}; 216 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
217 217
218#if 0
219/* Reverse Overlay arrow bitmap. A triangular arrow. */ 218/* Reverse Overlay arrow bitmap. A triangular arrow. */
220/* 219/*
221 ......xx 220 ......xx
@@ -227,9 +226,22 @@ static unsigned short ov_bits[] = {
227 ....xxxx 226 ....xxxx
228 ......xx 227 ......xx
229*/ 228*/
230static unsigned short rev_ov_bits[] = { 229static unsigned short left_triangle_bits[] = {
231 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03}; 230 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
232#endif 231
232/* Overlay arrow bitmap. A triangular arrow. */
233/*
234 xx......
235 xxxx....
236 xxxxx...
237 xxxxxx..
238 xxxxxx..
239 xxxxx...
240 xxxx....
241 xx......
242*/
243static unsigned short right_triangle_bits[] = {
244 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
233 245
234/* First line bitmap. An top-left angle. */ 246/* First line bitmap. An top-left angle. */
235/* 247/*
@@ -335,7 +347,7 @@ static unsigned short right_bracket_bits[] = {
335 xxxxxxx. 347 xxxxxxx.
336 xxxxxxx. 348 xxxxxxx.
337*/ 349*/
338static unsigned short filled_box_cursor_bits[] = { 350static unsigned short filled_rectangle_bits[] = {
339 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe}; 351 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
340 352
341/* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */ 353/* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */
@@ -354,9 +366,33 @@ static unsigned short filled_box_cursor_bits[] = {
354 x.....x. 366 x.....x.
355 xxxxxxx. 367 xxxxxxx.
356*/ 368*/
357static unsigned short hollow_box_cursor_bits[] = { 369static unsigned short hollow_rectangle_bits[] = {
358 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe}; 370 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
359 371
372/* Hollow square bitmap. */
373/*
374 .xxxxxx.
375 .x....x.
376 .x....x.
377 .x....x.
378 .x....x.
379 .xxxxxx.
380*/
381static unsigned short hollow_square_bits[] = {
382 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
383
384/* Filled square bitmap. */
385/*
386 .xxxxxx.
387 .xxxxxx.
388 .xxxxxx.
389 .xxxxxx.
390 .xxxxxx.
391 .xxxxxx.
392*/
393static unsigned short filled_square_bits[] = {
394 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e};
395
360/* Bar cursor bitmap. A vertical bar; max 13 pixels high. */ 396/* Bar cursor bitmap. A vertical bar; max 13 pixels high. */
361/* 397/*
362 xx...... 398 xx......
@@ -373,15 +409,15 @@ static unsigned short hollow_box_cursor_bits[] = {
373 xx...... 409 xx......
374 xx...... 410 xx......
375*/ 411*/
376static unsigned short bar_cursor_bits[] = { 412static unsigned short vertical_bar_bits[] = {
377 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}; 413 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
378 414
379/* HBar cursor bitmap. A horisontal bar; 2 pixels high. */ 415/* HBar cursor bitmap. A horizontal bar; 2 pixels high. */
380/* 416/*
381 xxxxxxx. 417 xxxxxxx.
382 xxxxxxx. 418 xxxxxxx.
383*/ 419*/
384static unsigned short hbar_cursor_bits[] = { 420static unsigned short horizontal_bar_bits[] = {
385 0xfe, 0xfe}; 421 0xfe, 0xfe};
386 422
387 423
@@ -395,7 +431,7 @@ static unsigned short hbar_cursor_bits[] = {
395 ..xxxx.. 431 ..xxxx..
396 ........ 432 ........
397*/ 433*/
398static unsigned short zv_bits[] = { 434static unsigned short empty_line_bits[] = {
399 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 435 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
400 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 436 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
401 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 437 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
@@ -405,48 +441,45 @@ static unsigned short zv_bits[] = {
405 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 441 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
406 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00}; 442 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
407 443
408/* Hollow square bitmap. */
409/*
410 .xxxxxx.
411 .x....x.
412 .x....x.
413 .x....x.
414 .x....x.
415 .xxxxxx.
416*/
417static unsigned short hollow_square_bits[] = {
418 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
419
420 444
421#define BYTES_PER_BITMAP_ROW (sizeof (unsigned short)) 445#define BYTES_PER_BITMAP_ROW (sizeof (unsigned short))
422#define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW) 446#define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
423#define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits) 447#define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits)
424 448
425struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] = 449/* NOTE: The order of these bitmaps must match the sequence
450 used in fringe.el to define the corresponding symbols. */
451
452struct fringe_bitmap standard_bitmaps[] =
426{ 453{
427 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */ 454 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
428 { FRBITS (unknown_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 455 { FRBITS (question_mark_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
429 { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 456 { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
430 { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 457 { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
431 { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, 458 { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
432 { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, 459 { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
433 { FRBITS (continued_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 460 { FRBITS (left_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
434 { FRBITS (continuation_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 461 { FRBITS (right_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
435 { FRBITS (ov_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 462 { FRBITS (left_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
463 { FRBITS (right_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
436 { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, 464 { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
437 { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, 465 { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
438 { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, 466 { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
439 { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, 467 { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
440 { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 468 { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
441 { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 469 { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
442 { FRBITS (filled_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 470 { FRBITS (filled_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
443 { FRBITS (hollow_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 471 { FRBITS (hollow_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
472 { FRBITS (filled_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
444 { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 473 { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
445 { FRBITS (bar_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, 474 { FRBITS (vertical_bar_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
446 { FRBITS (hbar_cursor_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, 475 { FRBITS (horizontal_bar_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
447 { FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 }, 476 { FRBITS (empty_line_bits), 8, 3, ALIGN_BITMAP_TOP, 0 },
448}; 477};
449 478
479#define NO_FRINGE_BITMAP 0
480#define UNDEF_FRINGE_BITMAP 1
481#define MAX_STANDARD_FRINGE_BITMAPS (sizeof(standard_bitmaps)/sizeof(standard_bitmaps[0]))
482
450static struct fringe_bitmap **fringe_bitmaps; 483static struct fringe_bitmap **fringe_bitmaps;
451static Lisp_Object *fringe_faces; 484static Lisp_Object *fringe_faces;
452static int max_fringe_bitmaps; 485static int max_fringe_bitmaps;
@@ -517,12 +550,12 @@ get_fringe_bitmap_name (bn)
517 LEFT_P is 1 for left fringe, 0 for right fringe. 550 LEFT_P is 1 for left fringe, 0 for right fringe.
518*/ 551*/
519 552
520void 553static void
521draw_fringe_bitmap_1 (w, row, left_p, overlay, which) 554draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
522 struct window *w; 555 struct window *w;
523 struct glyph_row *row; 556 struct glyph_row *row;
524 int left_p, overlay; 557 int left_p, overlay;
525 enum fringe_bitmap_type which; 558 int which;
526{ 559{
527 struct frame *f = XFRAME (WINDOW_FRAME (w)); 560 struct frame *f = XFRAME (WINDOW_FRAME (w));
528 struct draw_fringe_bitmap_params p; 561 struct draw_fringe_bitmap_params p;
@@ -657,6 +690,134 @@ draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
657 FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p); 690 FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p);
658} 691}
659 692
693static int
694get_logical_cursor_bitmap (w, cursor)
695 struct window *w;
696 Lisp_Object cursor;
697{
698 Lisp_Object cmap, bm = Qnil;
699
700 if ((cmap = XBUFFER (w->buffer)->fringe_cursor_alist), !NILP (cmap))
701 {
702 bm = Fassq (cursor, cmap);
703 if (CONSP (bm))
704 {
705 if ((bm = XCDR (bm)), NILP (bm))
706 return NO_FRINGE_BITMAP;
707 return lookup_fringe_bitmap (bm);
708 }
709 }
710 if (EQ (cmap, buffer_defaults.fringe_cursor_alist))
711 return NO_FRINGE_BITMAP;
712 bm = Fassq (cursor, buffer_defaults.fringe_cursor_alist);
713 if (!CONSP (bm) || ((bm = XCDR (bm)), NILP (bm)))
714 return NO_FRINGE_BITMAP;
715 return lookup_fringe_bitmap (bm);
716}
717
718static int
719get_logical_fringe_bitmap (w, bitmap, right_p, partial_p)
720 struct window *w;
721 Lisp_Object bitmap;
722 int right_p, partial_p;
723{
724 Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm;
725 int ln1 = 0, ln2 = 0;
726 int ix1 = right_p;
727 int ix2 = ix1 + (partial_p ? 2 : 0);
728
729 /* Lookup in buffer-local fringe-indicator-alist before global alist.
730
731 Elements are:
732 BITMAP -- use for all
733 (L R) -- use for left right (whether partial or not)
734 (L R PL PR) -- use for left rigth partial-left partial-right
735 If any value in local binding is not present or t, use global value.
736
737 If partial, lookup partial bitmap in default value if not found here.
738 If not partial, or no partial spec is present, use non-partial bitmap. */
739
740 if ((cmap = XBUFFER (w->buffer)->fringe_indicator_alist), !NILP (cmap))
741 {
742 bm1 = Fassq (bitmap, cmap);
743 if (CONSP (bm1))
744 {
745 if ((bm1 = XCDR (bm1)), NILP (bm1))
746 return NO_FRINGE_BITMAP;
747 if (CONSP (bm1))
748 {
749 ln1 = XINT (Flength (bm1));
750 if (partial_p)
751 {
752 if (ln1 > ix2)
753 {
754 bm = Fnth (make_number (ix2), bm1);
755 if (!EQ (bm, Qt))
756 goto found;
757 }
758 }
759 else
760 {
761 if (ln1 > ix1)
762 {
763 bm = Fnth (make_number (ix1), bm1);
764 if (!EQ (bm, Qt))
765 goto found;
766 }
767 }
768 }
769 else if ((bm = bm1, !EQ (bm, Qt)))
770 goto found;
771 }
772 }
773
774 if (!EQ (cmap, buffer_defaults.fringe_indicator_alist)
775 && !NILP (buffer_defaults.fringe_indicator_alist))
776 {
777 bm2 = Fassq (bitmap, buffer_defaults.fringe_indicator_alist);
778 if (CONSP (bm2))
779 {
780 if ((bm2 = XCDR (bm2)), !NILP (bm2))
781 {
782 if (CONSP (bm2))
783 {
784 ln2 = XINT (Flength (bm2));
785 if (partial_p)
786 {
787 if (ln2 > ix2)
788 {
789 bm = Fnth (make_number (ix2), bm2);
790 if (!EQ (bm, Qt))
791 goto found;
792 }
793 }
794 }
795 }
796 }
797 }
798
799 if (ln1 > ix1)
800 {
801 bm = Fnth (make_number (ix1), bm1);
802 if (!EQ (bm, Qt))
803 goto found;
804 }
805
806 if (ln2 > ix1)
807 {
808 bm = Fnth (make_number (ix1), bm2);
809 if (!EQ (bm, Qt))
810 goto found;
811 return NO_FRINGE_BITMAP;
812 }
813 else if ((bm = bm2, NILP (bm)))
814 return NO_FRINGE_BITMAP;
815
816 found:
817 return lookup_fringe_bitmap (bm);
818}
819
820
660void 821void
661draw_fringe_bitmap (w, row, left_p) 822draw_fringe_bitmap (w, row, left_p)
662 struct window *w; 823 struct window *w;
@@ -667,24 +828,24 @@ draw_fringe_bitmap (w, row, left_p)
667 828
668 if (!left_p && row->cursor_in_fringe_p) 829 if (!left_p && row->cursor_in_fringe_p)
669 { 830 {
670 int cursor = NO_FRINGE_BITMAP; 831 Lisp_Object cursor = Qnil;
671 832
672 switch (w->phys_cursor_type) 833 switch (w->phys_cursor_type)
673 { 834 {
674 case HOLLOW_BOX_CURSOR: 835 case HOLLOW_BOX_CURSOR:
675 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits)) 836 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_rectangle_bits))
676 cursor = HOLLOW_BOX_CURSOR_BITMAP; 837 cursor = Qhollow;
677 else 838 else
678 cursor = HOLLOW_SQUARE_BITMAP; 839 cursor = Qhollow_small;
679 break; 840 break;
680 case FILLED_BOX_CURSOR: 841 case FILLED_BOX_CURSOR:
681 cursor = FILLED_BOX_CURSOR_BITMAP; 842 cursor = Qbox;
682 break; 843 break;
683 case BAR_CURSOR: 844 case BAR_CURSOR:
684 cursor = BAR_CURSOR_BITMAP; 845 cursor = Qbar;
685 break; 846 break;
686 case HBAR_CURSOR: 847 case HBAR_CURSOR:
687 cursor = HBAR_CURSOR_BITMAP; 848 cursor = Qhbar;
688 break; 849 break;
689 case NO_CURSOR: 850 case NO_CURSOR:
690 default: 851 default:
@@ -692,10 +853,14 @@ draw_fringe_bitmap (w, row, left_p)
692 row->cursor_in_fringe_p = 0; 853 row->cursor_in_fringe_p = 0;
693 break; 854 break;
694 } 855 }
695 if (cursor != NO_FRINGE_BITMAP) 856 if (!NILP (cursor))
696 { 857 {
697 draw_fringe_bitmap_1 (w, row, 0, 2, cursor); 858 int bm = get_logical_cursor_bitmap (w, cursor);
698 overlay = cursor == FILLED_BOX_CURSOR_BITMAP ? 3 : 1; 859 if (bm != NO_FRINGE_BITMAP)
860 {
861 draw_fringe_bitmap_1 (w, row, 0, 2, bm);
862 overlay = EQ (cursor, Qbox) ? 3 : 1;
863 }
699 } 864 }
700 } 865 }
701 866
@@ -704,7 +869,7 @@ draw_fringe_bitmap (w, row, left_p)
704 if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP) 869 if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP)
705 draw_fringe_bitmap_1 (w, row, 1, 1, 870 draw_fringe_bitmap_1 (w, row, 1, 1,
706 (row->overlay_arrow_bitmap < 0 871 (row->overlay_arrow_bitmap < 0
707 ? OVERLAY_ARROW_BITMAP 872 ? get_logical_cursor_bitmap (w, Qoverlay_arrow)
708 : row->overlay_arrow_bitmap)); 873 : row->overlay_arrow_bitmap));
709} 874}
710 875
@@ -796,6 +961,8 @@ update_window_fringes (w, keep_current_p)
796 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil; 961 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil;
797 Lisp_Object empty_pos; 962 Lisp_Object empty_pos;
798 Lisp_Object ind = Qnil; 963 Lisp_Object ind = Qnil;
964#define MAX_BITMAP_CACHE (8*4)
965 int bitmap_cache[MAX_BITMAP_CACHE];
799 966
800 if (w->pseudo_window_p) 967 if (w->pseudo_window_p)
801 return 0; 968 return 0;
@@ -881,11 +1048,27 @@ update_window_fringes (w, keep_current_p)
881 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) 1048 if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
882 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; 1049 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
883 1050
1051 for (y = 0; y < MAX_BITMAP_CACHE; y++)
1052 bitmap_cache[y] = -1;
1053
1054#define LEFT_FRINGE(cache, which, partial_p) \
1055 (bitmap_cache[cache*4+partial_p] >= 0 \
1056 ? bitmap_cache[cache*4+partial_p] \
1057 : (bitmap_cache[cache*4+partial_p] = \
1058 get_logical_fringe_bitmap (w, which, 0, partial_p)))
1059
1060#define RIGHT_FRINGE(cache, which, partial_p) \
1061 (bitmap_cache[cache*4+2+partial_p] >= 0 \
1062 ? bitmap_cache[cache*4+2+partial_p] \
1063 : (bitmap_cache[cache*4+2+partial_p] = \
1064 get_logical_fringe_bitmap (w, which, 1, partial_p)))
1065
1066
884 for (y = 0, rn = 0; 1067 for (y = 0, rn = 0;
885 y < yb && rn < nrows; 1068 y < yb && rn < nrows;
886 y += row->height, rn++) 1069 y += row->height, rn++)
887 { 1070 {
888 enum fringe_bitmap_type left, right; 1071 int left, right;
889 unsigned left_face_id, right_face_id; 1072 unsigned left_face_id, right_face_id;
890 1073
891 row = w->desired_matrix->rows + rn; 1074 row = w->desired_matrix->rows + rn;
@@ -904,23 +1087,21 @@ update_window_fringes (w, keep_current_p)
904 left_face_id = row->left_user_fringe_face_id; 1087 left_face_id = row->left_user_fringe_face_id;
905 } 1088 }
906 else if (row->truncated_on_left_p) 1089 else if (row->truncated_on_left_p)
907 left = LEFT_TRUNCATION_BITMAP; 1090 left = LEFT_FRINGE(0, Qtruncation, 0);
908 else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) 1091 else if (row->indicate_bob_p && EQ (boundary_top, Qleft))
909 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) 1092 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft))
910 ? (row->ends_at_zv_p 1093 ? LEFT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p)
911 ? TOP_RIGHT_ANGLE_BITMAP : LEFT_BRACKET_BITMAP) 1094 : LEFT_FRINGE (2, Qtop, 0));
912 : TOP_LEFT_ANGLE_BITMAP);
913 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft)) 1095 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft))
914 left = (row->ends_at_zv_p 1096 left = LEFT_FRINGE (3, Qbottom, row->ends_at_zv_p);
915 ? TOP_RIGHT_ANGLE_BITMAP : BOTTOM_LEFT_ANGLE_BITMAP);
916 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) 1097 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
917 left = CONTINUATION_LINE_BITMAP; 1098 left = LEFT_FRINGE (4, Qcontinuation, 0);
918 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) 1099 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft))
919 left = ZV_LINE_BITMAP; 1100 left = LEFT_FRINGE (5, Qempty_line, 0);
920 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft)) 1101 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft))
921 left = UP_ARROW_BITMAP; 1102 left = LEFT_FRINGE (6, Qup, 0);
922 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft)) 1103 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft))
923 left = DOWN_ARROW_BITMAP; 1104 left = LEFT_FRINGE (7, Qdown, 0);
924 else 1105 else
925 left = NO_FRINGE_BITMAP; 1106 left = NO_FRINGE_BITMAP;
926 1107
@@ -933,23 +1114,21 @@ update_window_fringes (w, keep_current_p)
933 right_face_id = row->right_user_fringe_face_id; 1114 right_face_id = row->right_user_fringe_face_id;
934 } 1115 }
935 else if (row->truncated_on_right_p) 1116 else if (row->truncated_on_right_p)
936 right = RIGHT_TRUNCATION_BITMAP; 1117 right = RIGHT_FRINGE (0, Qtruncation, 0);
937 else if (row->indicate_bob_p && EQ (boundary_top, Qright)) 1118 else if (row->indicate_bob_p && EQ (boundary_top, Qright))
938 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright)) 1119 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright))
939 ? (row->ends_at_zv_p 1120 ? RIGHT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p)
940 ? TOP_LEFT_ANGLE_BITMAP : RIGHT_BRACKET_BITMAP) 1121 : RIGHT_FRINGE (2, Qtop, 0));
941 : TOP_RIGHT_ANGLE_BITMAP);
942 else if (row->indicate_eob_p && EQ (boundary_bot, Qright)) 1122 else if (row->indicate_eob_p && EQ (boundary_bot, Qright))
943 right = (row->ends_at_zv_p 1123 right = RIGHT_FRINGE (3, Qbottom, row->ends_at_zv_p);
944 ? TOP_LEFT_ANGLE_BITMAP : BOTTOM_RIGHT_ANGLE_BITMAP);
945 else if (row->continued_p) 1124 else if (row->continued_p)
946 right = CONTINUED_LINE_BITMAP; 1125 right = RIGHT_FRINGE (4, Qcontinuation, 0);
947 else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) 1126 else if (row->indicate_top_line_p && EQ (arrow_top, Qright))
948 right = UP_ARROW_BITMAP; 1127 right = RIGHT_FRINGE (6, Qup, 0);
949 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright)) 1128 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright))
950 right = DOWN_ARROW_BITMAP; 1129 right = RIGHT_FRINGE (7, Qdown, 0);
951 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright)) 1130 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright))
952 right = ZV_LINE_BITMAP; 1131 right = RIGHT_FRINGE (5, Qempty_line, 0);
953 else 1132 else
954 right = NO_FRINGE_BITMAP; 1133 right = NO_FRINGE_BITMAP;
955 1134
@@ -1153,7 +1332,7 @@ If BITMAP overrides a standard fringe bitmap, the original bitmap is restored.
1153 1332
1154void 1333void
1155init_fringe_bitmap (which, fb, once_p) 1334init_fringe_bitmap (which, fb, once_p)
1156 enum fringe_bitmap_type which; 1335 int which;
1157 struct fringe_bitmap *fb; 1336 struct fringe_bitmap *fb;
1158 int once_p; 1337 int once_p;
1159{ 1338{
@@ -1442,6 +1621,19 @@ Return nil if POS is not visible in WINDOW. */)
1442void 1621void
1443syms_of_fringe () 1622syms_of_fringe ()
1444{ 1623{
1624 Qtruncation = intern ("truncation");
1625 staticpro (&Qtruncation);
1626 Qcontinuation = intern ("continuation");
1627 staticpro (&Qcontinuation);
1628 Qoverlay_arrow = intern ("overlay-arrow");
1629 staticpro (&Qoverlay_arrow);
1630 Qempty_line = intern ("empty-line");
1631 staticpro (&Qempty_line);
1632 Qtop_bottom = intern ("top-bottom");
1633 staticpro (&Qtop_bottom);
1634 Qhollow_small = intern ("hollow-small");
1635 staticpro (&Qhollow_small);
1636
1445 defsubr (&Sdestroy_fringe_bitmap); 1637 defsubr (&Sdestroy_fringe_bitmap);
1446 defsubr (&Sdefine_fringe_bitmap); 1638 defsubr (&Sdefine_fringe_bitmap);
1447 defsubr (&Sfringe_bitmaps_at_pos); 1639 defsubr (&Sfringe_bitmaps_at_pos);
@@ -1457,8 +1649,7 @@ If nil, also continue lines which are exactly as wide as the window. */);
1457 Voverflow_newline_into_fringe = Qt; 1649 Voverflow_newline_into_fringe = Qt;
1458 1650
1459 DEFVAR_LISP ("fringe-bitmaps", &Vfringe_bitmaps, 1651 DEFVAR_LISP ("fringe-bitmaps", &Vfringe_bitmaps,
1460 doc: /* List of fringe bitmap symbols. 1652 doc: /* List of fringe bitmap symbols. */);
1461You must (require 'fringe) to use fringe bitmap symbols in your programs." */);
1462 Vfringe_bitmaps = Qnil; 1653 Vfringe_bitmaps = Qnil;
1463} 1654}
1464 1655
@@ -1479,7 +1670,7 @@ mark_fringe_data ()
1479void 1670void
1480init_fringe_once () 1671init_fringe_once ()
1481{ 1672{
1482 enum fringe_bitmap_type bt; 1673 int bt;
1483 1674
1484 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) 1675 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
1485 init_fringe_bitmap(bt, &standard_bitmaps[bt], 1); 1676 init_fringe_bitmap(bt, &standard_bitmaps[bt], 1);
@@ -1509,7 +1700,7 @@ init_fringe ()
1509void 1700void
1510w32_init_fringe () 1701w32_init_fringe ()
1511{ 1702{
1512 enum fringe_bitmap_type bt; 1703 int bt;
1513 1704
1514 if (!rif) 1705 if (!rif)
1515 return; 1706 return;
diff --git a/src/macterm.c b/src/macterm.c
index a0c4f298e66..5e341a4eeae 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -283,7 +283,7 @@ mac_begin_clip (region)
283 if (new_region == NULL) 283 if (new_region == NULL)
284 new_region = NewRgn (); 284 new_region = NewRgn ();
285 285
286 if (region) 286 if (region && !EmptyRgn (region))
287 { 287 {
288 GetClip (saved_port_clip_region); 288 GetClip (saved_port_clip_region);
289 SectRgn (saved_port_clip_region, region, new_region); 289 SectRgn (saved_port_clip_region, region, new_region);
@@ -295,7 +295,7 @@ static void
295mac_end_clip (region) 295mac_end_clip (region)
296 RgnHandle region; 296 RgnHandle region;
297{ 297{
298 if (region) 298 if (region && !EmptyRgn (region))
299 SetClip (saved_port_clip_region); 299 SetClip (saved_port_clip_region);
300} 300}
301 301
@@ -682,27 +682,15 @@ mac_invert_rectangle (f, x, y, width, height)
682 682
683 683
684static void 684static void
685mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char) 685mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
686 struct frame *f; 686 struct frame *f;
687 GC gc; 687 GC gc;
688 int x, y; 688 int x, y;
689 char *buf; 689 char *buf;
690 int nchars, mode, bytes_per_char; 690 int nchars, bg_width, bytes_per_char;
691{ 691{
692#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
693 UInt32 textFlags, savedFlags;
694 if (mac_use_core_graphics) {
695 textFlags = kQDUseCGTextRendering;
696 savedFlags = SwapQDTextFlags(textFlags);
697 }
698#endif
699
700 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 692 SetPortWindowPort (FRAME_MAC_WINDOW (f));
701 693
702 RGBForeColor (GC_FORE_COLOR (gc));
703 if (mode != srcOr)
704 RGBBackColor (GC_BACK_COLOR (gc));
705
706#if USE_ATSUI 694#if USE_ATSUI
707 if (GC_FONT (gc)->mac_style) 695 if (GC_FONT (gc)->mac_style)
708 { 696 {
@@ -724,91 +712,144 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
724 nchars, 712 nchars,
725 GC_FONT (gc)->mac_style, 713 GC_FONT (gc)->mac_style,
726 &text_layout); 714 &text_layout);
727 if (err == noErr) 715 if (err != noErr)
728 { 716 return;
729#ifdef MAC_OSX 717#ifdef MAC_OSX
730 if (!mac_use_core_graphics) 718 if (!mac_use_core_graphics)
731 { 719 {
732#endif 720#endif
733 mac_begin_clip (GC_CLIP_REGION (gc)); 721 mac_begin_clip (GC_CLIP_REGION (gc));
734 MoveTo (x, y); 722 RGBForeColor (GC_FORE_COLOR (gc));
735 ATSUDrawText (text_layout, 723 if (bg_width)
736 kATSUFromTextBeginning, kATSUToTextEnd, 724 {
737 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); 725 Rect r;
738 mac_end_clip (GC_CLIP_REGION (gc)); 726
739#ifdef MAC_OSX 727 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
728 x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
729 RGBBackColor (GC_BACK_COLOR (gc));
730 EraseRect (&r);
731 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
740 } 732 }
741 else 733 MoveTo (x, y);
734 ATSUDrawText (text_layout,
735 kATSUFromTextBeginning, kATSUToTextEnd,
736 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
737 mac_end_clip (GC_CLIP_REGION (gc));
738#ifdef MAC_OSX
739 }
740 else
741 {
742 CGrafPtr port;
743 CGContextRef context;
744 float port_height = FRAME_PIXEL_HEIGHT (f);
745 ATSUAttributeTag tags[] = {kATSUCGContextTag};
746 ByteCount sizes[] = {sizeof (CGContextRef)};
747 ATSUAttributeValuePtr values[] = {&context};
748
749 GetPort (&port);
750 QDBeginCGContext (port, &context);
751 if (gc->n_clip_rects || bg_width)
742 { 752 {
743 CGrafPtr port; 753 CGContextTranslateCTM (context, 0, port_height);
744 CGContextRef context; 754 CGContextScaleCTM (context, 1, -1);
745 float port_height = FRAME_PIXEL_HEIGHT (f);
746 ATSUAttributeTag tags[] = {kATSUCGContextTag};
747 ByteCount sizes[] = {sizeof (CGContextRef)};
748 ATSUAttributeValuePtr values[] = {&context};
749
750 GetPort (&port);
751 QDBeginCGContext (port, &context);
752 if (gc->n_clip_rects) 755 if (gc->n_clip_rects)
756 CGContextClipToRects (context, gc->clip_rects,
757 gc->n_clip_rects);
758 if (bg_width)
753 { 759 {
754 CGContextTranslateCTM (context, 0, port_height); 760 CGContextSetRGBFillColor
755 CGContextScaleCTM (context, 1, -1); 761 (context,
756 CGContextClipToRects (context, gc->clip_rects, 762 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
757 gc->n_clip_rects); 763 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
758 CGContextScaleCTM (context, 1, -1); 764 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
759 CGContextTranslateCTM (context, 0, -port_height); 765 1.0);
766 CGContextFillRect
767 (context,
768 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)),
769 bg_width, FONT_HEIGHT (GC_FONT (gc))));
760 } 770 }
761 CGContextSetRGBFillColor 771 CGContextScaleCTM (context, 1, -1);
762 (context, 772 CGContextTranslateCTM (context, 0, -port_height);
763 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, 773 }
764 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, 774 CGContextSetRGBFillColor
765 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, 775 (context,
766 1.0); 776 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
767 err = ATSUSetLayoutControls (text_layout, 777 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
768 sizeof (tags) / sizeof (tags[0]), 778 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
769 tags, sizes, values); 779 1.0);
770 if (err == noErr) 780 err = ATSUSetLayoutControls (text_layout,
771 ATSUDrawText (text_layout,
772 kATSUFromTextBeginning, kATSUToTextEnd,
773 Long2Fix (x), Long2Fix (port_height - y));
774 CGContextSynchronize (context);
775 QDEndCGContext (port, &context);
776#if 0
777 /* This doesn't work on Mac OS X 10.1. */
778 ATSUClearLayoutControls (text_layout,
779 sizeof (tags) / sizeof (tags[0]), 781 sizeof (tags) / sizeof (tags[0]),
780 tags); 782 tags, sizes, values);
783 if (err == noErr)
784 ATSUDrawText (text_layout,
785 kATSUFromTextBeginning, kATSUToTextEnd,
786 Long2Fix (x), Long2Fix (port_height - y));
787 CGContextSynchronize (context);
788 QDEndCGContext (port, &context);
789#if 0
790 /* This doesn't work on Mac OS X 10.1. */
791 ATSUClearLayoutControls (text_layout,
792 sizeof (tags) / sizeof (tags[0]), tags);
781#else 793#else
782 ATSUSetLayoutControls (text_layout, 794 ATSUSetLayoutControls (text_layout,
783 sizeof (tags) / sizeof (tags[0]), 795 sizeof (tags) / sizeof (tags[0]),
784 tags, sizes, values); 796 tags, sizes, values);
785#endif
786 }
787#endif 797#endif
788 } 798 }
799#endif /* MAC_OSX */
789 } 800 }
790 else 801 else
802#endif /* USE_ATSUI */
791 { 803 {
804#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
805 UInt32 savedFlags;
806
807 if (mac_use_core_graphics)
808 savedFlags = SwapQDTextFlags (kQDUseCGTextRendering);
792#endif 809#endif
793 TextFont (GC_FONT (gc)->mac_fontnum); 810 mac_begin_clip (GC_CLIP_REGION (gc));
794 TextSize (GC_FONT (gc)->mac_fontsize); 811 RGBForeColor (GC_FORE_COLOR (gc));
795 TextFace (GC_FONT (gc)->mac_fontface); 812#ifdef MAC_OS8
796 TextMode (mode); 813 if (bg_width)
814 {
815 RGBBackColor (GC_BACK_COLOR (gc));
816 TextMode (srcCopy);
817 }
818 else
819 TextMode (srcOr);
820#else
821 /* We prefer not to use srcCopy text transfer mode on Mac OS X
822 because:
823 - Screen is double-buffered. (In srcCopy mode, a text is
824 drawn into an offscreen graphics world first. So
825 performance gain cannot be expected.)
826 - It lowers rendering quality.
827 - Some fonts leave garbage on cursor movement. */
828 if (bg_width)
829 {
830 Rect r;
797 831
798 mac_begin_clip (GC_CLIP_REGION (gc)); 832 RGBBackColor (GC_BACK_COLOR (gc));
799 MoveTo (x, y); 833 SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
800 DrawText (buf, 0, nchars * bytes_per_char); 834 x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
801 mac_end_clip (GC_CLIP_REGION (gc)); 835 EraseRect (&r);
802#if USE_ATSUI 836 }
803 } 837 TextMode (srcOr);
804#endif 838#endif
839 TextFont (GC_FONT (gc)->mac_fontnum);
840 TextSize (GC_FONT (gc)->mac_fontsize);
841 TextFace (GC_FONT (gc)->mac_fontface);
842 MoveTo (x, y);
843 DrawText (buf, 0, nchars * bytes_per_char);
844 if (bg_width)
845 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
846 mac_end_clip (GC_CLIP_REGION (gc));
805 847
806 if (mode != srcOr)
807 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
808#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 848#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
809 if (mac_use_core_graphics) 849 if (mac_use_core_graphics)
810 SwapQDTextFlags(savedFlags); 850 SwapQDTextFlags(savedFlags);
811#endif 851#endif
852 }
812} 853}
813 854
814 855
@@ -822,7 +863,7 @@ mac_draw_string (f, gc, x, y, buf, nchars)
822 char *buf; 863 char *buf;
823 int nchars; 864 int nchars;
824{ 865{
825 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1); 866 mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1);
826} 867}
827 868
828 869
@@ -836,35 +877,35 @@ mac_draw_string_16 (f, gc, x, y, buf, nchars)
836 XChar2b *buf; 877 XChar2b *buf;
837 int nchars; 878 int nchars;
838{ 879{
839 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2); 880 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2);
840} 881}
841 882
842 883
843/* Mac replacement for XDrawImageString. */ 884/* Mac replacement for XDrawImageString. */
844 885
845static void 886static void
846mac_draw_image_string (f, gc, x, y, buf, nchars) 887mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width)
847 struct frame *f; 888 struct frame *f;
848 GC gc; 889 GC gc;
849 int x, y; 890 int x, y;
850 char *buf; 891 char *buf;
851 int nchars; 892 int nchars, bg_width;
852{ 893{
853 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1); 894 mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1);
854} 895}
855 896
856 897
857/* Mac replacement for XDrawString16. */ 898/* Mac replacement for XDrawString16. */
858 899
859static void 900static void
860mac_draw_image_string_16 (f, gc, x, y, buf, nchars) 901mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width)
861 struct frame *f; 902 struct frame *f;
862 GC gc; 903 GC gc;
863 int x, y; 904 int x, y;
864 XChar2b *buf; 905 XChar2b *buf;
865 int nchars; 906 int nchars, bg_width;
866{ 907{
867 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2); 908 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2);
868} 909}
869 910
870 911
@@ -1038,12 +1079,12 @@ init_cg_text_anti_aliasing_threshold ()
1038} 1079}
1039 1080
1040static int 1081static int
1041mac_draw_string_cg (f, gc, x, y, buf, nchars) 1082mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1042 struct frame *f; 1083 struct frame *f;
1043 GC gc; 1084 GC gc;
1044 int x, y; 1085 int x, y;
1045 XChar2b *buf; 1086 XChar2b *buf;
1046 int nchars; 1087 int nchars, bg_width;
1047{ 1088{
1048 CGrafPtr port; 1089 CGrafPtr port;
1049 float port_height, gx, gy; 1090 float port_height, gx, gy;
@@ -1060,7 +1101,9 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1060 gx = x; 1101 gx = x;
1061 gy = port_height - y; 1102 gy = port_height - y;
1062 glyphs = (CGGlyph *)buf; 1103 glyphs = (CGGlyph *)buf;
1063 advances = xmalloc (sizeof (CGSize) * nchars); 1104 advances = alloca (sizeof (CGSize) * nchars);
1105 if (advances == NULL)
1106 return 0;
1064 for (i = 0; i < nchars; i++) 1107 for (i = 0; i < nchars; i++)
1065 { 1108 {
1066 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0); 1109 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0);
@@ -1072,18 +1115,32 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1072 } 1115 }
1073 1116
1074 QDBeginCGContext (port, &context); 1117 QDBeginCGContext (port, &context);
1075 if (gc->n_clip_rects) 1118 if (gc->n_clip_rects || bg_width)
1076 { 1119 {
1077 CGContextTranslateCTM (context, 0, port_height); 1120 CGContextTranslateCTM (context, 0, port_height);
1078 CGContextScaleCTM (context, 1, -1); 1121 CGContextScaleCTM (context, 1, -1);
1079 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); 1122 if (gc->n_clip_rects)
1123 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
1124 if (bg_width)
1125 {
1126 CGContextSetRGBFillColor
1127 (context,
1128 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
1129 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
1130 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
1131 1.0);
1132 CGContextFillRect
1133 (context,
1134 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)),
1135 bg_width, FONT_HEIGHT (GC_FONT (gc))));
1136 }
1080 CGContextScaleCTM (context, 1, -1); 1137 CGContextScaleCTM (context, 1, -1);
1081 CGContextTranslateCTM (context, 0, -port_height); 1138 CGContextTranslateCTM (context, 0, -port_height);
1082 } 1139 }
1083 CGContextSetRGBFillColor (context, 1140 CGContextSetRGBFillColor (context,
1084 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1141 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1085 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1142 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1086 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0, 1143 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1087 1.0); 1144 1.0);
1088 CGContextSetFont (context, GC_FONT (gc)->cg_font); 1145 CGContextSetFont (context, GC_FONT (gc)->cg_font);
1089 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); 1146 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
@@ -1102,8 +1159,6 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
1102 CGContextSynchronize (context); 1159 CGContextSynchronize (context);
1103 QDEndCGContext (port, &context); 1160 QDEndCGContext (port, &context);
1104 1161
1105 xfree (advances);
1106
1107 return 1; 1162 return 1;
1108} 1163}
1109#endif 1164#endif
@@ -1375,10 +1430,7 @@ mac_set_clip_rectangles (display, gc, rectangles, n)
1375 if (n == 0) 1430 if (n == 0)
1376 { 1431 {
1377 if (gc->clip_region) 1432 if (gc->clip_region)
1378 { 1433 SetEmptyRgn (gc->clip_region);
1379 DisposeRgn (gc->clip_region);
1380 gc->clip_region = NULL;
1381 }
1382 } 1434 }
1383 else 1435 else
1384 { 1436 {
@@ -2322,14 +2374,6 @@ x_clear_glyph_string_rect (s, x, y, w, h)
2322} 2374}
2323 2375
2324 2376
2325/* We prefer not to use XDrawImageString (srcCopy text transfer mode)
2326 on Mac OS X because:
2327 - Screen is double-buffered. (In srcCopy mode, a text is drawn
2328 into an offscreen graphics world first. So performance gain
2329 cannot be expected.)
2330 - It lowers rendering quality.
2331 - Some fonts leave garbage on cursor movement. */
2332
2333/* Draw the background of glyph_string S. If S->background_filled_p 2377/* Draw the background of glyph_string S. If S->background_filled_p
2334 is non-zero don't draw it. FORCE_P non-zero means draw the 2378 is non-zero don't draw it. FORCE_P non-zero means draw the
2335 background even if it wouldn't be drawn normally. This is used 2379 background even if it wouldn't be drawn normally. This is used
@@ -2361,12 +2405,10 @@ x_draw_glyph_string_background (s, force_p)
2361 } 2405 }
2362 else 2406 else
2363#endif 2407#endif
2364#if defined (MAC_OS8) && !USE_ATSUI
2365 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 2408 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
2366 || s->font_not_found_p 2409 || s->font_not_found_p
2367 || s->extends_to_end_of_line_p 2410 || s->extends_to_end_of_line_p
2368 || force_p) 2411 || force_p)
2369#endif
2370 { 2412 {
2371 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, 2413 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
2372 s->background_width, 2414 s->background_width,
@@ -2383,7 +2425,7 @@ static void
2383x_draw_glyph_string_foreground (s) 2425x_draw_glyph_string_foreground (s)
2384 struct glyph_string *s; 2426 struct glyph_string *s;
2385{ 2427{
2386 int i, x; 2428 int i, x, bg_width;
2387 2429
2388 /* If first glyph of S has a left box line, start drawing the text 2430 /* If first glyph of S has a left box line, start drawing the text
2389 of S to the right of that box line. */ 2431 of S to the right of that box line. */
@@ -2422,7 +2464,6 @@ x_draw_glyph_string_foreground (s)
2422 for (i = 0; i < s->nchars; ++i) 2464 for (i = 0; i < s->nchars; ++i)
2423 char1b[i] = s->char2b[i].byte2; 2465 char1b[i] = s->char2b[i].byte2;
2424 2466
2425#if defined (MAC_OS8) && !USE_ATSUI
2426 /* Draw text with XDrawString if background has already been 2467 /* Draw text with XDrawString if background has already been
2427 filled. Otherwise, use XDrawImageString. (Note that 2468 filled. Otherwise, use XDrawImageString. (Note that
2428 XDrawImageString is usually faster than XDrawString.) Always 2469 XDrawImageString is usually faster than XDrawString.) Always
@@ -2430,38 +2471,27 @@ x_draw_glyph_string_foreground (s)
2430 no chance that characters under a box cursor are invisible. */ 2471 no chance that characters under a box cursor are invisible. */
2431 if (s->for_overlaps 2472 if (s->for_overlaps
2432 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 2473 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2433#endif 2474 bg_width = 0; /* Corresponds to XDrawString. */
2434 { 2475 else
2435 /* Draw characters with 16-bit or 8-bit functions. */ 2476 bg_width = s->background_width; /* Corresponds to XDrawImageString. */
2436 if (s->two_byte_p 2477
2478 if (s->two_byte_p
2437#if USE_ATSUI 2479#if USE_ATSUI
2438 || GC_FONT (s->gc)->mac_style 2480 || GC_FONT (s->gc)->mac_style
2439#endif 2481#endif
2440 ) 2482 )
2441#if USE_CG_TEXT_DRAWING 2483#if USE_CG_TEXT_DRAWING
2442 if (!s->two_byte_p 2484 if (!s->two_byte_p
2443 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff, 2485 && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff,
2444 s->char2b, s->nchars)) 2486 s->char2b, s->nchars, bg_width))
2445 ; 2487 ;
2446 else 2488 else
2447#endif 2489#endif
2448 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, 2490 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2449 s->char2b, s->nchars); 2491 s->char2b, s->nchars, bg_width);
2450 else
2451 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2452 char1b, s->nchars);
2453 }
2454#if defined (MAC_OS8) && !USE_ATSUI
2455 else 2492 else
2456 { 2493 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2457 if (s->two_byte_p) 2494 char1b, s->nchars, bg_width);
2458 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2459 s->char2b, s->nchars);
2460 else
2461 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2462 char1b, s->nchars);
2463 }
2464#endif
2465 } 2495 }
2466} 2496}
2467 2497
@@ -7837,9 +7867,13 @@ XLoadQueryFont (Display *dpy, char *fontname)
7837#if !defined (MAC_OS8) || USE_ATSUI 7867#if !defined (MAC_OS8) || USE_ATSUI
7838 /* AppKit and WebKit do some adjustment to the heights of Courier, 7868 /* AppKit and WebKit do some adjustment to the heights of Courier,
7839 Helvetica, and Times. This only works on the environments where 7869 Helvetica, and Times. This only works on the environments where
7840 the XDrawImageString counterpart is never used. */ 7870 srcCopy text transfer mode is never used. */
7841 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0 7871 if (
7842 || strcmp (family, "times") == 0) 7872#ifdef MAC_OS8 /* implies USE_ATSUI */
7873 font->mac_style &&
7874#endif
7875 (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
7876 || strcmp (family, "times") == 0))
7843 font->ascent += (font->ascent + font->descent) * .15 + 0.5; 7877 font->ascent += (font->ascent + font->descent) * .15 + 0.5;
7844#endif 7878#endif
7845 7879
diff --git a/src/regex.c b/src/regex.c
index cd6301938a7..846c87041b1 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -181,6 +181,51 @@ char *malloc ();
181char *realloc (); 181char *realloc ();
182# endif 182# endif
183 183
184/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
185
186void *
187xmalloc (size)
188 size_t size;
189{
190 register void *val;
191 val = (void *) malloc (size);
192 if (!val && size)
193 {
194 write (2, "virtual memory exhausted\n", 25);
195 exit (1);
196 }
197 return val;
198}
199
200void *
201xrealloc (block, size)
202 void *block;
203 size_t size;
204{
205 register void *val;
206 /* We must call malloc explicitly when BLOCK is 0, since some
207 reallocs don't do this. */
208 if (! block)
209 val = (void *) malloc (size);
210 else
211 val = (void *) realloc (block, size);
212 if (!val && size)
213 {
214 write (2, "virtual memory exhausted\n", 25);
215 exit (1);
216 }
217 return val;
218}
219
220# ifdef malloc
221# undef malloc
222# endif
223# define malloc xmalloc
224# ifdef realloc
225# undef realloc
226# endif
227# define realloc xrealloc
228
184/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. 229/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
185 If nothing else has been done, use the method below. */ 230 If nothing else has been done, use the method below. */
186# ifdef INHIBIT_STRING_HEADER 231# ifdef INHIBIT_STRING_HEADER
@@ -3609,12 +3654,12 @@ regex_compile (pattern, size, syntax, bufp)
3609 if (! fail_stack.stack) 3654 if (! fail_stack.stack)
3610 fail_stack.stack 3655 fail_stack.stack
3611 = (fail_stack_elt_t *) malloc (fail_stack.size 3656 = (fail_stack_elt_t *) malloc (fail_stack.size
3612 * sizeof (fail_stack_elt_t)); 3657 * sizeof (fail_stack_elt_t));
3613 else 3658 else
3614 fail_stack.stack 3659 fail_stack.stack
3615 = (fail_stack_elt_t *) realloc (fail_stack.stack, 3660 = (fail_stack_elt_t *) realloc (fail_stack.stack,
3616 (fail_stack.size 3661 (fail_stack.size
3617 * sizeof (fail_stack_elt_t))); 3662 * sizeof (fail_stack_elt_t)));
3618 } 3663 }
3619 3664
3620 regex_grow_registers (num_regs); 3665 regex_grow_registers (num_regs);
@@ -6300,7 +6345,7 @@ regcomp (preg, pattern, cflags)
6300 6345
6301 preg->translate 6346 preg->translate
6302 = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE 6347 = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
6303 * sizeof (*(RE_TRANSLATE_TYPE)0)); 6348 * sizeof (*(RE_TRANSLATE_TYPE)0));
6304 if (preg->translate == NULL) 6349 if (preg->translate == NULL)
6305 return (int) REG_ESPACE; 6350 return (int) REG_ESPACE;
6306 6351
diff --git a/src/xfns.c b/src/xfns.c
index eb790263867..b9b1a8fe3fc 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5332,6 +5332,7 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5332 int result; 5332 int result;
5333 struct frame *f = SELECTED_FRAME (); 5333 struct frame *f = SELECTED_FRAME ();
5334 Lisp_Object file = Qnil; 5334 Lisp_Object file = Qnil;
5335 Lisp_Object decoded_file;
5335 Widget dialog, text, help; 5336 Widget dialog, text, help;
5336 Arg al[10]; 5337 Arg al[10];
5337 int ac = 0; 5338 int ac = 0;
@@ -5472,7 +5473,9 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5472 if (NILP (file)) 5473 if (NILP (file))
5473 Fsignal (Qquit, Qnil); 5474 Fsignal (Qquit, Qnil);
5474 5475
5475 return unbind_to (count, file); 5476 decoded_file = DECODE_FILE (file);
5477
5478 return unbind_to (count, decoded_file);
5476} 5479}
5477 5480
5478#endif /* USE_MOTIF */ 5481#endif /* USE_MOTIF */
@@ -5500,6 +5503,7 @@ directories. */)
5500 FRAME_PTR f = SELECTED_FRAME (); 5503 FRAME_PTR f = SELECTED_FRAME ();
5501 char *fn; 5504 char *fn;
5502 Lisp_Object file = Qnil; 5505 Lisp_Object file = Qnil;
5506 Lisp_Object decoded_file;
5503 int count = SPECPDL_INDEX (); 5507 int count = SPECPDL_INDEX ();
5504 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5508 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5505 char *cdef_file; 5509 char *cdef_file;
@@ -5540,7 +5544,9 @@ directories. */)
5540 if (NILP (file)) 5544 if (NILP (file))
5541 Fsignal (Qquit, Qnil); 5545 Fsignal (Qquit, Qnil);
5542 5546
5543 return unbind_to (count, file); 5547 decoded_file = DECODE_FILE (file);
5548
5549 return unbind_to (count, decoded_file);
5544} 5550}
5545 5551
5546#endif /* USE_GTK */ 5552#endif /* USE_GTK */