aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog58
-rw-r--r--src/alloc.c6
-rw-r--r--src/buffer.c2
-rw-r--r--src/image.c10
-rw-r--r--src/lread.c3
-rw-r--r--src/nsfns.m13
-rw-r--r--src/nsfont.m57
-rw-r--r--src/nsmenu.m23
-rw-r--r--src/nsterm.h8
-rw-r--r--src/nsterm.m214
-rw-r--r--src/print.c12
11 files changed, 301 insertions, 105 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d618b30ceba..9e8aedfd36b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,9 +1,65 @@
12011-07-28 Paul Eggert <eggert@cs.ucla.edu> 12011-07-29 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * Makefile.in (gl-stamp): move-if-change now in build-aux (Bug#9169). 3 * Makefile.in (gl-stamp): move-if-change now in build-aux (Bug#9169).
4 4
52011-07-28 Paul Eggert <eggert@cs.ucla.edu> 52011-07-28 Paul Eggert <eggert@cs.ucla.edu>
6 6
7 * image.c (check_image_size): Use 1024x1024 if unknown frame (Bug#9189).
8 This is needed if max-image-size is a floating-point number.
9
102011-07-28 Andreas Schwab <schwab@linux-m68k.org>
11
12 * print.c (print_object): Print empty symbol as ##.
13
14 * lread.c (read1): Read ## as empty symbol.
15
162011-07-28 Alp Aker <alp.tekin.aker@gmail.com>
17
18 * nsfns.m (x_set_foreground_color): Set f->foreground_pixel when
19 setting frame foreground color (Bug#9175).
20 (x_set_background_color): Likewise.
21
22 * nsmenu.m (-setText): Size tooltip dimensions precisely to
23 contents (Bug#9176).
24 (EmacsTooltip -init): Remove bezels and add shadows to
25 tooltip windows.
26
27 * nsterm.m (ns_dumpglyphs_stretch): Avoid overwriting left fringe
28 or scroll bar (Bug#8470).
29
30 * nsfont.m (nsfont_open): Remove assignment to voffset and
31 unnecessary vars hshink, expand, hd, full_height, min_height.
32 (nsfont_draw): Use s->ybase as baseline for glyph drawing (Bug#8913).
33
34 * nsterm.h (nsfont_info): Remove voffset field.
35
362011-07-28 Alp Aker <alp.tekin.aker@gmail.com>
37
38 Implement strike-through and overline on NextStep (Bug#8863).
39
40 * nsfont.m (nsfont_open): Use underline position provided by font,
41 instead of hard-coded value of 2.
42 (nsfont_draw): Call ns_draw_text_decoration instead.
43
44 * nsterm.h: Add declaration for ns_draw_text_decoration.
45
46 * nsterm.m (ns_draw_text_decoration): New function for drawing
47 underline, overline, and strike-through.
48 (ns_dumpglyphs_image, ns_dumpglyphs_stretch): Add call to
49 ns_draw_text_decoration. Change treatment of cursor drawing to
50 accomodate underlining, etc.
51
522011-07-28 Eli Zaretskii <eliz@gnu.org>
53
54 * buffer.c (init_buffer_once): Set bidi-display-reordering to t by
55 default.
56
572011-07-28 Paul Eggert <eggert@cs.ucla.edu>
58
59 * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
60 Without this fix, if a signal arrives just after memory fills up,
61 'malloc' might be invoked reentrantly.
62
7 * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1. 63 * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1.
8 In other words, assume that every image size is allowed, on non-X 64 In other words, assume that every image size is allowed, on non-X
9 hosts. This assumption is probably wrong, but it lets Emacs compile. 65 hosts. This assumption is probably wrong, but it lets Emacs compile.
diff --git a/src/alloc.c b/src/alloc.c
index eb0185a8e35..b96fc1f0642 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3282,12 +3282,16 @@ memory_full (size_t nbytes)
3282 int enough_free_memory = 0; 3282 int enough_free_memory = 0;
3283 if (SPARE_MEMORY < nbytes) 3283 if (SPARE_MEMORY < nbytes)
3284 { 3284 {
3285 void *p = malloc (SPARE_MEMORY); 3285 void *p;
3286
3287 MALLOC_BLOCK_INPUT;
3288 p = malloc (SPARE_MEMORY);
3286 if (p) 3289 if (p)
3287 { 3290 {
3288 free (p); 3291 free (p);
3289 enough_free_memory = 1; 3292 enough_free_memory = 1;
3290 } 3293 }
3294 MALLOC_UNBLOCK_INPUT;
3291 } 3295 }
3292 3296
3293 if (! enough_free_memory) 3297 if (! enough_free_memory)
diff --git a/src/buffer.c b/src/buffer.c
index a40275db8de..45d6fa36d04 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4926,7 +4926,7 @@ init_buffer_once (void)
4926 BVAR (&buffer_defaults, truncate_lines) = Qnil; 4926 BVAR (&buffer_defaults, truncate_lines) = Qnil;
4927 BVAR (&buffer_defaults, word_wrap) = Qnil; 4927 BVAR (&buffer_defaults, word_wrap) = Qnil;
4928 BVAR (&buffer_defaults, ctl_arrow) = Qt; 4928 BVAR (&buffer_defaults, ctl_arrow) = Qt;
4929 BVAR (&buffer_defaults, bidi_display_reordering) = Qnil; 4929 BVAR (&buffer_defaults, bidi_display_reordering) = Qt;
4930 BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil; 4930 BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil;
4931 BVAR (&buffer_defaults, cursor_type) = Qt; 4931 BVAR (&buffer_defaults, cursor_type) = Qt;
4932 BVAR (&buffer_defaults, extra_line_spacing) = Qnil; 4932 BVAR (&buffer_defaults, extra_line_spacing) = Qnil;
diff --git a/src/image.c b/src/image.c
index fb1d825fa54..d1091aec6f3 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1053,9 +1053,13 @@ check_image_size (struct frame *f, int width, int height)
1053 && height <= XINT (Vmax_image_size)); 1053 && height <= XINT (Vmax_image_size));
1054 else if (FLOATP (Vmax_image_size)) 1054 else if (FLOATP (Vmax_image_size))
1055 { 1055 {
1056 xassert (f); 1056 if (f != NULL)
1057 w = FRAME_PIXEL_WIDTH (f); 1057 {
1058 h = FRAME_PIXEL_HEIGHT (f); 1058 w = FRAME_PIXEL_WIDTH (f);
1059 h = FRAME_PIXEL_HEIGHT (f);
1060 }
1061 else
1062 w = h = 1024; /* Arbitrary size for unknown frame. */
1059 return (width <= XFLOAT_DATA (Vmax_image_size) * w 1063 return (width <= XFLOAT_DATA (Vmax_image_size) * w
1060 && height <= XFLOAT_DATA (Vmax_image_size) * h); 1064 && height <= XFLOAT_DATA (Vmax_image_size) * h);
1061 } 1065 }
diff --git a/src/lread.c b/src/lread.c
index 0613ad037bf..78ff195e990 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2670,6 +2670,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2670 } 2670 }
2671 goto read_symbol; 2671 goto read_symbol;
2672 } 2672 }
2673 /* ## is the empty symbol. */
2674 if (c == '#')
2675 return Fintern (build_string (""), Qnil);
2673 /* Reader forms that can reuse previously read objects. */ 2676 /* Reader forms that can reuse previously read objects. */
2674 if (c >= '0' && c <= '9') 2677 if (c >= '0' && c <= '9')
2675 { 2678 {
diff --git a/src/nsfns.m b/src/nsfns.m
index 0452086201e..85246a4c25f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -321,6 +321,7 @@ static void
321x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 321x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
322{ 322{
323 NSColor *col; 323 NSColor *col;
324 CGFloat r, g, b, alpha;
324 325
325 if (ns_lisp_to_color (arg, &col)) 326 if (ns_lisp_to_color (arg, &col))
326 { 327 {
@@ -332,6 +333,10 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
332 [f->output_data.ns->foreground_color release]; 333 [f->output_data.ns->foreground_color release];
333 f->output_data.ns->foreground_color = col; 334 f->output_data.ns->foreground_color = col;
334 335
336 [col getRed: &r green: &g blue: &b alpha: &alpha];
337 FRAME_FOREGROUND_PIXEL (f) =
338 ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff));
339
335 if (FRAME_NS_VIEW (f)) 340 if (FRAME_NS_VIEW (f))
336 { 341 {
337 update_face_from_frame_parameter (f, Qforeground_color, arg); 342 update_face_from_frame_parameter (f, Qforeground_color, arg);
@@ -348,7 +353,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
348 struct face *face; 353 struct face *face;
349 NSColor *col; 354 NSColor *col;
350 NSView *view = FRAME_NS_VIEW (f); 355 NSView *view = FRAME_NS_VIEW (f);
351 float alpha; 356 CGFloat r, g, b, alpha;
352 357
353 if (ns_lisp_to_color (arg, &col)) 358 if (ns_lisp_to_color (arg, &col))
354 { 359 {
@@ -364,10 +369,14 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
364 [col retain]; 369 [col retain];
365 [f->output_data.ns->background_color release]; 370 [f->output_data.ns->background_color release];
366 f->output_data.ns->background_color = col; 371 f->output_data.ns->background_color = col;
372
373 [col getRed: &r green: &g blue: &b alpha: &alpha];
374 FRAME_BACKGROUND_PIXEL (f) =
375 ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff));
376
367 if (view != nil) 377 if (view != nil)
368 { 378 {
369 [[view window] setBackgroundColor: col]; 379 [[view window] setBackgroundColor: col];
370 alpha = [col alphaComponent];
371 380
372 if (alpha != 1.0) 381 if (alpha != 1.0)
373 [[view window] setOpaque: NO]; 382 [[view window] setOpaque: NO];
diff --git a/src/nsfont.m b/src/nsfont.m
index 76c70aadf9f..60f8c5321aa 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -804,8 +804,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
804 font->props[FONT_FILE_INDEX] = Qnil; 804 font->props[FONT_FILE_INDEX] = Qnil;
805 805
806 { 806 {
807 double expand, hshrink;
808 float full_height, min_height, hd;
809 const char *fontName = [[nsfont fontName] UTF8String]; 807 const char *fontName = [[nsfont fontName] UTF8String];
810 int len = strlen (fontName); 808 int len = strlen (fontName);
811 809
@@ -837,26 +835,16 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
837 [sfont maximumAdvancement].width : ns_char_width (sfont, '0'); 835 [sfont maximumAdvancement].width : ns_char_width (sfont, '0');
838 836
839 brect = [sfont boundingRectForFont]; 837 brect = [sfont boundingRectForFont];
840 full_height = brect.size.height;
841 min_height = [sfont ascender] - adjusted_descender;
842 hd = full_height - min_height;
843 838
844 /* standard height, similar to Carbon. Emacs.app: was 0.5 by default. */ 839 font_info->underpos = [sfont underlinePosition];
845 expand = 0.0;
846 hshrink = 1.0;
847
848 font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */
849 font_info->underwidth = [sfont underlineThickness]; 840 font_info->underwidth = [sfont underlineThickness];
850 font_info->size = font->pixel_size; 841 font_info->size = font->pixel_size;
851 font_info->voffset = lrint (hshrink * [sfont ascender] + expand * hd / 2);
852 842
853 /* max bounds */ 843 /* max bounds */
854 font_info->max_bounds.ascent = 844 font_info->max_bounds.ascent = lrint ([sfont ascender]);
855 lrint (hshrink * [sfont ascender] + expand * hd/2);
856 /* Descender is usually negative. Use floor to avoid 845 /* Descender is usually negative. Use floor to avoid
857 clipping descenders. */ 846 clipping descenders. */
858 font_info->max_bounds.descent = 847 font_info->max_bounds.descent = -lrint (floor(adjusted_descender));
859 -lrint (floor(hshrink* adjusted_descender - expand*hd/2));
860 font_info->height = 848 font_info->height =
861 font_info->max_bounds.ascent + font_info->max_bounds.descent; 849 font_info->max_bounds.ascent + font_info->max_bounds.descent;
862 font_info->max_bounds.width = lrint (font_info->width); 850 font_info->max_bounds.width = lrint (font_info->width);
@@ -1165,7 +1153,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1165 1153
1166 1154
1167 /* set up for character rendering */ 1155 /* set up for character rendering */
1168 r.origin.y += font->voffset + (s->height - font->height)/2; 1156 r.origin.y = s->ybase;
1169 1157
1170 col = (NS_FACE_FOREGROUND (face) != 0 1158 col = (NS_FACE_FOREGROUND (face) != 0
1171 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) 1159 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f)
@@ -1196,20 +1184,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1196/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ 1184/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
1197 } 1185 }
1198 1186
1199 /* do underline */ 1187 [col set];
1200 if (face->underline_p)
1201 {
1202 if (face->underline_color != 0)
1203 [ns_lookup_indexed_color (face->underline_color, s->f) set];
1204 else
1205 [col set];
1206 DPSmoveto (context, r.origin.x, r.origin.y + font->underpos);
1207 DPSlineto (context, r.origin.x+r.size.width, r.origin.y+font->underpos);
1208 if (face->underline_color != 0)
1209 [col set];
1210 }
1211 else
1212 [col set];
1213 1188
1214 /* draw with DPSxshow () */ 1189 /* draw with DPSxshow () */
1215 DPSmoveto (context, r.origin.x, r.origin.y); 1190 DPSmoveto (context, r.origin.x, r.origin.y);
@@ -1255,23 +1230,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1255 CGContextSetTextDrawingMode (gcontext, kCGTextFill); 1230 CGContextSetTextDrawingMode (gcontext, kCGTextFill);
1256 } 1231 }
1257 1232
1258 if (face->underline_p) 1233 [col set];
1259 {
1260 if (face->underline_color != 0)
1261 [ns_lookup_indexed_color (face->underline_color, s->f) set];
1262 else
1263 [col set];
1264 CGContextBeginPath (gcontext);
1265 CGContextMoveToPoint (gcontext,
1266 r.origin.x, r.origin.y + font->underpos);
1267 CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width,
1268 r.origin.y + font->underpos);
1269 CGContextStrokePath (gcontext);
1270 if (face->underline_color != 0)
1271 [col set];
1272 }
1273 else
1274 [col set];
1275 1234
1276 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); 1235 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y);
1277 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, 1236 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
@@ -1287,6 +1246,10 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1287 CGContextRestoreGState (gcontext); 1246 CGContextRestoreGState (gcontext);
1288 } 1247 }
1289#endif /* NS_IMPL_COCOA */ 1248#endif /* NS_IMPL_COCOA */
1249
1250 /* Draw underline, overline, strike-through. */
1251 ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x);
1252
1290 return to-from; 1253 return to-from;
1291} 1254}
1292 1255
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 6931b7a3c01..6bde229ed4d 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1228,8 +1228,8 @@ update_frame_tool_bar (FRAME_PTR f)
1228 1228
1229 [textField setEditable: NO]; 1229 [textField setEditable: NO];
1230 [textField setSelectable: NO]; 1230 [textField setSelectable: NO];
1231 [textField setBordered: YES]; 1231 [textField setBordered: NO];
1232 [textField setBezeled: YES]; 1232 [textField setBezeled: NO];
1233 [textField setDrawsBackground: YES]; 1233 [textField setDrawsBackground: YES];
1234 1234
1235 win = [[NSWindow alloc] 1235 win = [[NSWindow alloc]
@@ -1237,6 +1237,7 @@ update_frame_tool_bar (FRAME_PTR f)
1237 styleMask: 0 1237 styleMask: 0
1238 backing: NSBackingStoreBuffered 1238 backing: NSBackingStoreBuffered
1239 defer: YES]; 1239 defer: YES];
1240 [win setHasShadow: YES];
1240 [win setReleasedWhenClosed: NO]; 1241 [win setReleasedWhenClosed: NO];
1241 [win setDelegate: self]; 1242 [win setDelegate: self];
1242 [[win contentView] addSubview: textField]; 1243 [[win contentView] addSubview: textField];
@@ -1257,17 +1258,15 @@ update_frame_tool_bar (FRAME_PTR f)
1257- (void) setText: (char *)text 1258- (void) setText: (char *)text
1258{ 1259{
1259 NSString *str = [NSString stringWithUTF8String: text]; 1260 NSString *str = [NSString stringWithUTF8String: text];
1260 NSRect r = [textField frame]; 1261 NSRect r = [textField frame];
1261 NSSize textSize = [str sizeWithAttributes: 1262 NSSize tooltipDims;
1262 [NSDictionary dictionaryWithObject: [[textField font] screenFont] 1263
1263 forKey: NSFontAttributeName]];
1264 NSSize padSize = [[[textField font] screenFont]
1265 boundingRectForFont].size;
1266
1267 r.size.width = textSize.width + padSize.width/2;
1268 r.size.height = textSize.height + padSize.height/2;
1269 [textField setFrame: r];
1270 [textField setStringValue: str]; 1264 [textField setStringValue: str];
1265 tooltipDims = [[textField cell] cellSize];
1266
1267 r.size.width = tooltipDims.width;
1268 r.size.height = tooltipDims.height;
1269 [textField setFrame: r];
1271} 1270}
1272 1271
1273- (void) showAtX: (int)x Y: (int)y for: (int)seconds 1272- (void) showAtX: (int)x Y: (int)y for: (int)seconds
diff --git a/src/nsterm.h b/src/nsterm.h
index f419391a11e..6ea9161c922 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -467,7 +467,6 @@ struct nsfont_info
467#endif 467#endif
468 char bold, ital; /* convenience flags */ 468 char bold, ital; /* convenience flags */
469 char synthItal; 469 char synthItal;
470 float voffset; /* mean of ascender/descender offsets */
471 XCharStruct max_bounds; 470 XCharStruct max_bounds;
472 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed 471 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
473 by hibyte, lobyte */ 472 by hibyte, lobyte */
@@ -825,6 +824,13 @@ extern unsigned long ns_get_rgb_color (struct frame *f,
825 float r, float g, float b, float a); 824 float r, float g, float b, float a);
826extern NSPoint last_mouse_motion_position; 825extern NSPoint last_mouse_motion_position;
827 826
827/* From nsterm.m, needed in nsfont.m. */
828#ifdef __OBJC__
829extern void
830ns_draw_text_decoration (struct glyph_string *s, struct face *face,
831 NSColor *defaultCol, CGFloat width, CGFloat x);
832#endif
833
828#ifdef NS_IMPL_GNUSTEP 834#ifdef NS_IMPL_GNUSTEP
829extern char gnustep_base_version[]; /* version tracking */ 835extern char gnustep_base_version[]; /* version tracking */
830#endif 836#endif
diff --git a/src/nsterm.m b/src/nsterm.m
index e45dc1a902d..d4b1a3f8473 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -263,8 +263,6 @@ static void ns_condemn_scroll_bars (struct frame *f);
263static void ns_judge_scroll_bars (struct frame *f); 263static void ns_judge_scroll_bars (struct frame *f);
264void x_set_frame_alpha (struct frame *f); 264void x_set_frame_alpha (struct frame *f);
265 265
266/* FIXME: figure out what to do with underline_minimum_offset. */
267
268 266
269/* ========================================================================== 267/* ==========================================================================
270 268
@@ -2597,6 +2595,107 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2597 return n; 2595 return n;
2598} 2596}
2599 2597
2598void
2599ns_draw_text_decoration (struct glyph_string *s, struct face *face,
2600 NSColor *defaultCol, CGFloat width, CGFloat x)
2601/* --------------------------------------------------------------------------
2602 Draw underline, overline, and strike-through on glyph string s.
2603 -------------------------------------------------------------------------- */
2604{
2605 if (s->for_overlaps)
2606 return;
2607
2608 /* Do underline. */
2609 if (face->underline_p)
2610 {
2611 NSRect r;
2612 unsigned long thickness, position;
2613
2614 /* If the prev was underlined, match its appearance. */
2615 if (s->prev && s->prev->face->underline_p
2616 && s->prev->underline_thickness > 0)
2617 {
2618 thickness = s->prev->underline_thickness;
2619 position = s->prev->underline_position;
2620 }
2621 else
2622 {
2623 struct font *font;
2624 unsigned long descent;
2625
2626 font=s->font;
2627 descent = s->y + s->height - s->ybase;
2628
2629 /* Use underline thickness of font, defaulting to 1. */
2630 thickness = (font && font->underline_thickness > 0)
2631 ? font->underline_thickness : 1;
2632
2633 /* Determine the offset of underlining from the baseline. */
2634 if (x_underline_at_descent_line)
2635 position = descent - thickness;
2636 else if (x_use_underline_position_properties
2637 && font && font->underline_position >= 0)
2638 position = font->underline_position;
2639 else if (font)
2640 position = lround (font->descent / 2);
2641 else
2642 position = underline_minimum_offset;
2643
2644 position = max (position, underline_minimum_offset);
2645
2646 /* Ensure underlining is not cropped. */
2647 if (descent <= position)
2648 {
2649 position = descent - 1;
2650 thickness = 1;
2651 }
2652 else if (descent < position + thickness)
2653 thickness = 1;
2654 }
2655
2656 s->underline_thickness = thickness;
2657 s->underline_position = position;
2658
2659 r = NSMakeRect (x, s->ybase + position, width, thickness);
2660
2661 if (face->underline_defaulted_p)
2662 [defaultCol set];
2663 else
2664 [ns_lookup_indexed_color (face->underline_color, s->f) set];
2665 NSRectFill (r);
2666 }
2667
2668 /* Do overline. We follow other terms in using a thickness of 1
2669 and ignoring overline_margin. */
2670 if (face->overline_p)
2671 {
2672 NSRect r;
2673 r = NSMakeRect (x, s->y, width, 1);
2674
2675 if (face->overline_color_defaulted_p)
2676 [defaultCol set];
2677 else
2678 [ns_lookup_indexed_color (face->overline_color, s->f) set];
2679 NSRectFill (r);
2680 }
2681
2682 /* Do strike-through. We follow other terms for thickness and
2683 vertical position.*/
2684 if (face->strike_through_p)
2685 {
2686 NSRect r;
2687 unsigned long dy;
2688
2689 dy = lrint ((s->height - 1) / 2);
2690 r = NSMakeRect (x, s->y + dy, width, 1);
2691
2692 if (face->strike_through_color_defaulted_p)
2693 [defaultCol set];
2694 else
2695 [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
2696 NSRectFill (r);
2697 }
2698}
2600 2699
2601static void 2700static void
2602ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p) 2701ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p)
@@ -2854,6 +2953,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2854 char raised_p; 2953 char raised_p;
2855 NSRect br; 2954 NSRect br;
2856 struct face *face; 2955 struct face *face;
2956 NSColor *tdCol;
2857 2957
2858 NSTRACE (ns_dumpglyphs_image); 2958 NSTRACE (ns_dumpglyphs_image);
2859 2959
@@ -2882,10 +2982,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2882 else 2982 else
2883 face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 2983 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
2884 2984
2885 if (s->hl == DRAW_CURSOR) 2985 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set];
2886 [FRAME_CURSOR_COLOR (s->f) set];
2887 else
2888 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set];
2889 2986
2890 if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin 2987 if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
2891 || s->img->mask || s->img->pixmap == 0 || s->width != s->background_width) 2988 || s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
@@ -2923,6 +3020,27 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2923 [img compositeToPoint: NSMakePoint (x, y + s->slice.height) 3020 [img compositeToPoint: NSMakePoint (x, y + s->slice.height)
2924 operation: NSCompositeSourceOver]; 3021 operation: NSCompositeSourceOver];
2925 3022
3023 if (s->hl == DRAW_CURSOR)
3024 {
3025 [FRAME_CURSOR_COLOR (s->f) set];
3026 if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
3027 tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3028 else
3029 /* Currently on NS img->mask is always 0. Since
3030 get_window_cursor_type specifies a hollow box cursor when on
3031 a non-masked image we never reach this clause. But we put it
3032 in in antipication of better support for image masks on
3033 NS. */
3034 tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3035 }
3036 else
3037 {
3038 tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3039 }
3040
3041 /* Draw underline, overline, strike-through. */
3042 ns_draw_text_decoration (s, face, tdCol, br.size.width, br.origin.x);
3043
2926 /* Draw relief, if requested */ 3044 /* Draw relief, if requested */
2927 if (s->img->relief || s->hl ==DRAW_IMAGE_RAISED || s->hl ==DRAW_IMAGE_SUNKEN) 3045 if (s->img->relief || s->hl ==DRAW_IMAGE_RAISED || s->hl ==DRAW_IMAGE_SUNKEN)
2928 { 3046 {
@@ -2967,22 +3085,49 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
2967 NSRect r[2]; 3085 NSRect r[2];
2968 int n, i; 3086 int n, i;
2969 struct face *face; 3087 struct face *face;
3088 NSColor *fgCol, *bgCol;
2970 3089
2971 if (!s->background_filled_p) 3090 if (!s->background_filled_p)
2972 { 3091 {
2973 n = ns_get_glyph_string_clip_rect (s, r); 3092 n = ns_get_glyph_string_clip_rect (s, r);
2974 *r = NSMakeRect (s->x, s->y, s->background_width, s->height); 3093 *r = NSMakeRect (s->x, s->y, s->background_width, s->height);
2975 3094
3095 ns_focus (s->f, r, n);
3096
3097 if (s->hl == DRAW_MOUSE_FACE)
3098 {
3099 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3100 if (!face)
3101 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3102 }
3103 else
3104 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
3105
3106 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3107 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3108
2976 for (i=0; i<n; i++) 3109 for (i=0; i<n; i++)
2977 { 3110 {
2978 if (!s->row->full_width_p) 3111 if (!s->row->full_width_p)
2979 { 3112 {
3113 int overrun, leftoverrun;
3114
2980 /* truncate to avoid overwriting fringe and/or scrollbar */ 3115 /* truncate to avoid overwriting fringe and/or scrollbar */
2981 int overrun = max (0, (s->x + s->background_width) 3116 overrun = max (0, (s->x + s->background_width)
2982 - (WINDOW_BOX_RIGHT_EDGE_X (s->w) 3117 - (WINDOW_BOX_RIGHT_EDGE_X (s->w)
2983 - WINDOW_RIGHT_FRINGE_WIDTH (s->w))); 3118 - WINDOW_RIGHT_FRINGE_WIDTH (s->w)));
2984 r[i].size.width -= overrun; 3119 r[i].size.width -= overrun;
2985 3120
3121 /* truncate to avoid overwriting to left of the window box */
3122 leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w)
3123 + WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x;
3124
3125 if (leftoverrun > 0)
3126 {
3127 r[i].origin.x += leftoverrun;
3128 r[i].size.width -= leftoverrun;
3129 }
3130
2986 /* XXX: Try to work between problem where a stretch glyph on 3131 /* XXX: Try to work between problem where a stretch glyph on
2987 a partially-visible bottom row will clear part of the 3132 a partially-visible bottom row will clear part of the
2988 modeline, and another where list-buffers headers and similar 3133 modeline, and another where list-buffers headers and similar
@@ -2998,30 +3143,37 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
2998 FRAME_PIXEL_WIDTH (s->f)); 3143 FRAME_PIXEL_WIDTH (s->f));
2999 } 3144 }
3000 3145
3146 [bgCol set];
3147
3001 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid 3148 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid
3002 overwriting cursor (usually when cursor on a tab) */ 3149 overwriting cursor (usually when cursor on a tab) */
3003 if (s->hl == DRAW_CURSOR) 3150 if (s->hl == DRAW_CURSOR)
3004 { 3151 {
3005 r[i].origin.x += s->width; 3152 CGFloat x, width;
3006 r[i].size.width -= s->width;
3007 }
3008 }
3009 3153
3010 ns_focus (s->f, r, n); 3154 x = r[i].origin.x;
3155 width = s->w->phys_cursor_width;
3156 r[i].size.width -= width;
3157 r[i].origin.x += width;
3011 3158
3012 if (s->hl == DRAW_MOUSE_FACE) 3159 NSRectFill (r[i]);
3013 {
3014 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3015 if (!face)
3016 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3017 }
3018 else
3019 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
3020 3160
3021 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set]; 3161 /* Draw overlining, etc. on the cursor. */
3162 if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
3163 ns_draw_text_decoration (s, face, bgCol, width, x);
3164 else
3165 ns_draw_text_decoration (s, face, fgCol, width, x);
3166 }
3167 else
3168 {
3169 NSRectFill (r[i]);
3170 }
3022 3171
3023 NSRectFill (r[0]); 3172 /* Draw overlining, etc. on the stretch glyph (or the part
3024 NSRectFill (r[1]); 3173 of the stretch glyph after the cursor). */
3174 ns_draw_text_decoration (s, face, fgCol, r[i].size.width,
3175 r[i].origin.x);
3176 }
3025 ns_unfocus (s->f); 3177 ns_unfocus (s->f);
3026 s->background_filled_p = 1; 3178 s->background_filled_p = 1;
3027 } 3179 }
@@ -6556,23 +6708,17 @@ Only works on OSX 10.6 or later. */);
6556 Vx_toolkit_scroll_bars = Qnil; 6708 Vx_toolkit_scroll_bars = Qnil;
6557#endif 6709#endif
6558 6710
6559 /* these are unsupported but we need the declarations to avoid whining
6560 messages from cus-start.el */
6561 DEFVAR_BOOL ("x-use-underline-position-properties", 6711 DEFVAR_BOOL ("x-use-underline-position-properties",
6562 x_use_underline_position_properties, 6712 x_use_underline_position_properties,
6563 doc: /* NOT SUPPORTED UNDER NS. 6713 doc: /*Non-nil means make use of UNDERLINE_POSITION font properties.
6564*Non-nil means make use of UNDERLINE_POSITION font properties.
6565A value of nil means ignore them. If you encounter fonts with bogus 6714A value of nil means ignore them. If you encounter fonts with bogus
6566UNDERLINE_POSITION font properties, for example 7x13 on XFree prior 6715UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
6567to 4.1, set this to nil. 6716to 4.1, set this to nil. */);
6568
6569NOTE: Not supported on Mac yet. */);
6570 x_use_underline_position_properties = 0; 6717 x_use_underline_position_properties = 0;
6571 6718
6572 DEFVAR_BOOL ("x-underline-at-descent-line", 6719 DEFVAR_BOOL ("x-underline-at-descent-line",
6573 x_underline_at_descent_line, 6720 x_underline_at_descent_line,
6574 doc: /* NOT SUPPORTED UNDER NS. 6721 doc: /* Non-nil means to draw the underline at the same place as the descent line.
6575*Non-nil means to draw the underline at the same place as the descent line.
6576A value of nil means to draw the underline according to the value of the 6722A value of nil means to draw the underline according to the value of the
6577variable `x-use-underline-position-properties', which is usually at the 6723variable `x-use-underline-position-properties', which is usually at the
6578baseline level. The default value is nil. */); 6724baseline level. The default value is nil. */);
diff --git a/src/print.c b/src/print.c
index f1907a31465..35f89860843 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1536,13 +1536,19 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1536 else 1536 else
1537 confusing = 0; 1537 confusing = 0;
1538 1538
1539 size_byte = SBYTES (name);
1540
1539 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj)) 1541 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj))
1540 { 1542 {
1541 PRINTCHAR ('#'); 1543 PRINTCHAR ('#');
1542 PRINTCHAR (':'); 1544 PRINTCHAR (':');
1543 } 1545 }
1544 1546 else if (size_byte == 0)
1545 size_byte = SBYTES (name); 1547 {
1548 PRINTCHAR ('#');
1549 PRINTCHAR ('#');
1550 break;
1551 }
1546 1552
1547 for (i = 0, i_byte = 0; i_byte < size_byte;) 1553 for (i = 0, i_byte = 0; i_byte < size_byte;)
1548 { 1554 {
@@ -1555,7 +1561,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1555 { 1561 {
1556 if (c == '\"' || c == '\\' || c == '\'' 1562 if (c == '\"' || c == '\\' || c == '\''
1557 || c == ';' || c == '#' || c == '(' || c == ')' 1563 || c == ';' || c == '#' || c == '(' || c == ')'
1558 || c == ',' || c =='.' || c == '`' 1564 || c == ',' || c == '.' || c == '`'
1559 || c == '[' || c == ']' || c == '?' || c <= 040 1565 || c == '[' || c == ']' || c == '?' || c <= 040
1560 || confusing) 1566 || confusing)
1561 PRINTCHAR ('\\'), confusing = 0; 1567 PRINTCHAR ('\\'), confusing = 0;