comparison src/macterm.c @ 83514:d9f8d2a65d18

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-252 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-253 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-254 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-255 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-256 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-257 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-258 Clean up lisp/gnus/ChangeLog a bit * emacs@sv.gnu.org/emacs--devo--0--patch-259 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-260 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-261 lisp/replace.el (occur-engine): Bind `inhibit-field-text-motion' to t * emacs@sv.gnu.org/emacs--devo--0--patch-262 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-96 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-97 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-98 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-554
author Karoly Lorentey <lorentey@elte.hu>
date Wed, 03 May 2006 11:56:53 +0000
parents 966a40e7fb54 085795461ed0
children 1321f6cfb389
comparison
equal deleted inserted replaced
83513:966a40e7fb54 83514:d9f8d2a65d18
387 GC gc; 387 GC gc;
388 int x1, y1, x2, y2; 388 int x1, y1, x2, y2;
389 { 389 {
390 #if USE_CG_DRAWING 390 #if USE_CG_DRAWING
391 CGContextRef context; 391 CGContextRef context;
392 float gx1 = x1, gy1 = y1, gx2 = x2, gy2 = y2;
393
394 if (y1 != y2)
395 gx1 += 0.5f, gx2 += 0.5f;
396 if (x1 != x2)
397 gy1 += 0.5f, gy2 += 0.5f;
392 398
393 context = mac_begin_cg_clip (f, gc); 399 context = mac_begin_cg_clip (f, gc);
394 CG_SET_STROKE_COLOR (context, gc->xgcv.foreground); 400 CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
395 CGContextBeginPath (context); 401 CGContextBeginPath (context);
396 CGContextMoveToPoint (context, x1 + 0.5f, y1 + 0.5f); 402 CGContextMoveToPoint (context, gx1, gy1);
397 CGContextAddLineToPoint (context, x2 + 0.5f, y2 + 0.5f); 403 CGContextAddLineToPoint (context, gx2, gy2);
398 CGContextClosePath (context); 404 CGContextClosePath (context);
399 CGContextStrokePath (context); 405 CGContextStrokePath (context);
400 mac_end_cg_clip (f); 406 mac_end_cg_clip (f);
401 #else 407 #else
408 if (x1 == x2)
409 {
410 if (y1 > y2)
411 y1--;
412 else if (y2 > y1)
413 y2--;
414 }
415 else if (y1 == y2)
416 {
417 if (x1 > x2)
418 x1--;
419 else
420 x2--;
421 }
422
402 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 423 SetPortWindowPort (FRAME_MAC_WINDOW (f));
403 424
404 RGBForeColor (GC_FORE_COLOR (gc)); 425 RGBForeColor (GC_FORE_COLOR (gc));
405 426
406 mac_begin_clip (gc); 427 mac_begin_clip (gc);
417 GC gc; 438 GC gc;
418 int x1, y1, x2, y2; 439 int x1, y1, x2, y2;
419 { 440 {
420 CGrafPtr old_port; 441 CGrafPtr old_port;
421 GDHandle old_gdh; 442 GDHandle old_gdh;
443
444 if (x1 == x2)
445 {
446 if (y1 > y2)
447 y1--;
448 else if (y2 > y1)
449 y2--;
450 }
451 else if (y1 == y2)
452 {
453 if (x1 > x2)
454 x1--;
455 else
456 x2--;
457 }
422 458
423 GetGWorld (&old_port, &old_gdh); 459 GetGWorld (&old_port, &old_gdh);
424 SetGWorld (p, NULL); 460 SetGWorld (p, NULL);
425 461
426 RGBForeColor (GC_FORE_COLOR (gc)); 462 RGBForeColor (GC_FORE_COLOR (gc));
1623 UnionRgn (gc->clip_region, region, gc->clip_region); 1659 UnionRgn (gc->clip_region, region, gc->clip_region);
1624 } 1660 }
1625 DisposeRgn (region); 1661 DisposeRgn (region);
1626 } 1662 }
1627 } 1663 }
1628 #if defined (MAC_OSX) && USE_ATSUI 1664 #if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING)
1629 for (i = 0; i < n; i++) 1665 for (i = 0; i < n; i++)
1630 { 1666 {
1631 Rect *rect = rectangles + i; 1667 Rect *rect = rectangles + i;
1632 1668
1633 gc->clip_rects[i] = CGRectMake (rect->left, rect->top, 1669 gc->clip_rects[i] = CGRectMake (rect->left, rect->top,
2134 2170
2135 static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); 2171 static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
2136 static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); 2172 static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *));
2137 2173
2138 2174
2175 static void
2176 pcm_init (pcm, count)
2177 XCharStruct *pcm;
2178 int count;
2179 {
2180 bzero (pcm, sizeof (XCharStruct) * count);
2181 while (--count >= 0)
2182 {
2183 pcm->descent = PCM_INVALID;
2184 pcm++;
2185 }
2186 }
2187
2188 static enum pcm_status
2189 pcm_get_status (pcm)
2190 XCharStruct *pcm;
2191 {
2192 int height = pcm->ascent + pcm->descent;
2193
2194 /* Negative height means some special status. */
2195 return height >= 0 ? PCM_VALID : height;
2196 }
2197
2139 /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B 2198 /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B
2140 is not contained in the font. */ 2199 is not contained in the font. */
2141 2200
2142 static INLINE XCharStruct * 2201 static INLINE XCharStruct *
2143 x_per_char_metric (font, char2b) 2202 x_per_char_metric (font, char2b)
2150 xassert (font && char2b); 2209 xassert (font && char2b);
2151 2210
2152 #if USE_ATSUI 2211 #if USE_ATSUI
2153 if (font->mac_style) 2212 if (font->mac_style)
2154 { 2213 {
2155 XCharStructRow **row = font->bounds.rows + char2b->byte1; 2214 XCharStruct **row = font->bounds.rows + char2b->byte1;
2156 2215
2157 if (*row == NULL) 2216 if (*row == NULL)
2158 { 2217 {
2159 *row = xmalloc (sizeof (XCharStructRow)); 2218 *row = xmalloc (sizeof (XCharStruct) * 0x100);
2160 bzero (*row, sizeof (XCharStructRow)); 2219 pcm_init (*row, 0x100);
2161 } 2220 }
2162 pcm = (*row)->per_char + char2b->byte2; 2221 pcm = *row + char2b->byte2;
2163 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2)) 2222 if (pcm_get_status (pcm) != PCM_VALID)
2164 { 2223 {
2165 BLOCK_INPUT; 2224 BLOCK_INPUT;
2166 mac_query_char_extents (font->mac_style, 2225 mac_query_char_extents (font->mac_style,
2167 (char2b->byte1 << 8) + char2b->byte2, 2226 (char2b->byte1 << 8) + char2b->byte2,
2168 NULL, NULL, pcm, NULL); 2227 NULL, NULL, pcm, NULL);
2169 UNBLOCK_INPUT; 2228 UNBLOCK_INPUT;
2170 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
2171 } 2229 }
2172 } 2230 }
2173 else 2231 else
2174 { 2232 {
2175 #endif 2233 #endif
3120 /* Top. */ 3178 /* Top. */
3121 if (top_p) 3179 if (top_p)
3122 for (i = 0; i < width; ++i) 3180 for (i = 0; i < width; ++i)
3123 mac_draw_line (f, gc, 3181 mac_draw_line (f, gc,
3124 left_x + i * left_p, top_y + i, 3182 left_x + i * left_p, top_y + i,
3125 right_x - i * right_p, top_y + i); 3183 right_x + 1 - i * right_p, top_y + i);
3126 3184
3127 /* Left. */ 3185 /* Left. */
3128 if (left_p) 3186 if (left_p)
3129 for (i = 0; i < width; ++i) 3187 for (i = 0; i < width; ++i)
3130 mac_draw_line (f, gc, 3188 mac_draw_line (f, gc,
3131 left_x + i, top_y + i, left_x + i, bottom_y - i); 3189 left_x + i, top_y + i, left_x + i, bottom_y - i + 1);
3132 3190
3133 mac_reset_clip_rectangles (dpy, gc); 3191 mac_reset_clip_rectangles (dpy, gc);
3134 if (raised_p) 3192 if (raised_p)
3135 gc = f->output_data.mac->black_relief.gc; 3193 gc = f->output_data.mac->black_relief.gc;
3136 else 3194 else
3140 /* Bottom. */ 3198 /* Bottom. */
3141 if (bot_p) 3199 if (bot_p)
3142 for (i = 0; i < width; ++i) 3200 for (i = 0; i < width; ++i)
3143 mac_draw_line (f, gc, 3201 mac_draw_line (f, gc,
3144 left_x + i * left_p, bottom_y - i, 3202 left_x + i * left_p, bottom_y - i,
3145 right_x - i * right_p, bottom_y - i); 3203 right_x + 1 - i * right_p, bottom_y - i);
3146 3204
3147 /* Right. */ 3205 /* Right. */
3148 if (right_p) 3206 if (right_p)
3149 for (i = 0; i < width; ++i) 3207 for (i = 0; i < width; ++i)
3150 mac_draw_line (f, gc, 3208 mac_draw_line (f, gc,
3151 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); 3209 right_x - i, top_y + i + 1, right_x - i, bottom_y - i);
3152 3210
3153 mac_reset_clip_rectangles (dpy, gc); 3211 mac_reset_clip_rectangles (dpy, gc);
3154 } 3212 }
3155 3213
3156 3214
6297 6355
6298 x_free_gcs (f); 6356 x_free_gcs (f);
6299 6357
6300 if (FRAME_SIZE_HINTS (f)) 6358 if (FRAME_SIZE_HINTS (f))
6301 xfree (FRAME_SIZE_HINTS (f)); 6359 xfree (FRAME_SIZE_HINTS (f));
6360
6361 #if TARGET_API_MAC_CARBON
6362 if (FRAME_FILE_NAME (f))
6363 xfree (FRAME_FILE_NAME (f));
6364 #endif
6302 6365
6303 xfree (f->output_data.mac); 6366 xfree (f->output_data.mac);
6304 f->output_data.mac = NULL; 6367 f->output_data.mac = NULL;
6305 6368
6306 if (f == dpyinfo->x_focus_frame) 6369 if (f == dpyinfo->x_focus_frame)
7744 font->min_byte1 = 0; 7807 font->min_byte1 = 0;
7745 font->max_byte1 = 0xff; 7808 font->max_byte1 = 0xff;
7746 font->min_char_or_byte2 = 0; 7809 font->min_char_or_byte2 = 0;
7747 font->max_char_or_byte2 = 0xff; 7810 font->max_char_or_byte2 = 0xff;
7748 7811
7749 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100); 7812 font->bounds.rows = xmalloc (sizeof (XCharStruct *) * 0x100);
7750 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100); 7813 bzero (font->bounds.rows, sizeof (XCharStruct *) * 0x100);
7751 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow)); 7814 font->bounds.rows[0] = xmalloc (sizeof (XCharStruct) * 0x100);
7752 bzero (font->bounds.rows[0], sizeof (XCharStructRow)); 7815 pcm_init (font->bounds.rows[0], 0x100);
7753 7816
7754 #if USE_CG_TEXT_DRAWING 7817 #if USE_CG_TEXT_DRAWING
7755 { 7818 {
7756 FMFontFamily font_family; 7819 FMFontFamily font_family;
7757 FMFontStyle style; 7820 FMFontStyle style;
7773 { 7836 {
7774 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100); 7837 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7775 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100); 7838 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7776 } 7839 }
7777 #endif 7840 #endif
7778 space_bounds = font->bounds.rows[0]->per_char + 0x20; 7841 space_bounds = font->bounds.rows[0] + 0x20;
7779 err = mac_query_char_extents (font->mac_style, 0x20, 7842 err = mac_query_char_extents (font->mac_style, 0x20,
7780 &font->ascent, &font->descent, 7843 &font->ascent, &font->descent,
7781 space_bounds, 7844 space_bounds,
7782 #if USE_CG_TEXT_DRAWING 7845 #if USE_CG_TEXT_DRAWING
7783 (font->cg_glyphs ? font->cg_glyphs + 0x20 7846 (font->cg_glyphs ? font->cg_glyphs + 0x20
7789 if (err != noErr) 7852 if (err != noErr)
7790 { 7853 {
7791 mac_unload_font (&one_mac_display_info, font); 7854 mac_unload_font (&one_mac_display_info, font);
7792 return NULL; 7855 return NULL;
7793 } 7856 }
7794 XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], 0x20); 7857
7795 7858 pcm = font->bounds.rows[0];
7796 pcm = font->bounds.rows[0]->per_char;
7797 for (c = 0x21; c <= 0xff; c++) 7859 for (c = 0x21; c <= 0xff; c++)
7798 { 7860 {
7799 if (c == 0xad) 7861 if (c == 0xad)
7800 /* Soft hyphen is not supported in ATSUI. */ 7862 /* Soft hyphen is not supported in ATSUI. */
7801 continue; 7863 continue;
7811 : NULL) 7873 : NULL)
7812 #else 7874 #else
7813 NULL 7875 NULL
7814 #endif 7876 #endif
7815 ); 7877 );
7816 XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], c);
7817 7878
7818 #if USE_CG_TEXT_DRAWING 7879 #if USE_CG_TEXT_DRAWING
7819 if (font->cg_glyphs && font->cg_glyphs[c] == 0) 7880 if (font->cg_glyphs && font->cg_glyphs[c] == 0)
7820 { 7881 {
7821 /* Don't use CG text drawing if font substitution occurs in 7882 /* Don't use CG text drawing if font substitution occurs in
9995 break; 10056 break;
9996 } 10057 }
9997 } 10058 }
9998 break; 10059 break;
9999 10060
10061 #if TARGET_API_MAC_CARBON
10062 case inProxyIcon:
10063 if (TrackWindowProxyDrag (window_ptr, er.where)
10064 != errUserWantsToDragWindow)
10065 break;
10066 /* fall through */
10067 #endif
10000 case inDrag: 10068 case inDrag:
10001 #if TARGET_API_MAC_CARBON 10069 #if TARGET_API_MAC_CARBON
10070 if (IsWindowPathSelectClick (window_ptr, &er))
10071 {
10072 WindowPathSelect (window_ptr, NULL, NULL);
10073 break;
10074 }
10002 DragWindow (window_ptr, er.where, NULL); 10075 DragWindow (window_ptr, er.where, NULL);
10003 #else /* not TARGET_API_MAC_CARBON */ 10076 #else /* not TARGET_API_MAC_CARBON */
10004 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); 10077 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
10005 #endif /* not TARGET_API_MAC_CARBON */ 10078 #endif /* not TARGET_API_MAC_CARBON */
10006 /* Update the frame parameters. */ 10079 /* Update the frame parameters. */
11048 11121
11049 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics, 11122 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics,
11050 doc: /* *If non-nil, allow anti-aliasing. 11123 doc: /* *If non-nil, allow anti-aliasing.
11051 The text will be rendered using Core Graphics text rendering which 11124 The text will be rendered using Core Graphics text rendering which
11052 may anti-alias the text. */); 11125 may anti-alias the text. */);
11126 #if USE_CG_DRAWING
11127 mac_use_core_graphics = 1;
11128 #else
11053 mac_use_core_graphics = 0; 11129 mac_use_core_graphics = 0;
11130 #endif
11054 11131
11055 /* Register an entry for `mac-roman' so that it can be used when 11132 /* Register an entry for `mac-roman' so that it can be used when
11056 creating the terminal frame on Mac OS 9 before loading 11133 creating the terminal frame on Mac OS 9 before loading
11057 term/mac-win.elc. */ 11134 term/mac-win.elc. */
11058 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist, 11135 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,