summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2005-10-07 07:15:40 +0000
committerMiles Bader <miles@gnu.org>2005-10-07 07:15:40 +0000
commit00e18f33adde1d2f196fdf9cadf11235cc4fcc8f (patch)
tree8c553c9a361da158ba47f3d0ed0429da180d957f /src
parentba4c328314c2b01e6dcc3807a0666a644c3f3954 (diff)
parent9e1cb4bc96d36af6e8b893d467970a25afead03b (diff)
downloademacs-00e18f33adde1d2f196fdf9cadf11235cc4fcc8f.tar.gz
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-88
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 569-579) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 129-132) - Update from CVS - Merge from emacs--cvs-trunk--0
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog108
-rw-r--r--src/alloc.c50
-rw-r--r--src/dired.c2
-rw-r--r--src/dispextern.h1
-rw-r--r--src/editfns.c4
-rw-r--r--src/emacs.c4
-rw-r--r--src/image.c4
-rw-r--r--src/keyboard.c23
-rw-r--r--src/macfns.c14
-rw-r--r--src/macgui.h20
-rw-r--r--src/macterm.c771
-rw-r--r--src/minibuf.c26
-rw-r--r--src/process.c2
-rw-r--r--src/regex.c4
-rw-r--r--src/regex.h5
-rw-r--r--src/systime.h8
-rw-r--r--src/unexelf.c2
-rw-r--r--src/window.c80
-rw-r--r--src/xdisp.c3
-rw-r--r--src/xfaces.c19
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c4
22 files changed, 939 insertions, 217 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cd25ba97e90..172700a810b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,107 @@
+2005-10-04 Kim F. Storm <storm@cua.dk>
+
+ * window.c (window_split_tree): New function.
+ (Fwindow_split_tree): New defun.
+ (syms_of_window): Defsubr it.
+
+2005-10-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macterm.c (mac_invert_rectangle): New function.
+ (XTflash): Use it.
+
+2005-10-04 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * regex.h (re_char): Don't expose it in the interface.
+ (re_set_whitespace_regexp): Adjust the arg's type to not use it.
+
+ * regex.c (re_char): Move it back here.
+ (re_set_whitespace_regexp): Change the arg's type to not use it.
+
+ * keyboard.c (make_lispy_event): If point has moved between down and up
+ event, make it a drag, not a click, to mirror what
+ mouse-drag-region expects.
+
+2005-10-02 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * lisp.h (fatal): Undo previous change.
+ * term.c (fatal): Undo previous change.
+
+2005-10-01 Richard M. Stallman <rms@gnu.org>
+
+ * xfaces.c (face_color_gray_p): Colors close to black count as gray.
+
+2005-10-01 Kim F. Storm <storm@cua.dk>
+
+ * xdisp.c (try_window): Skip scroll-margin check if ZV is visible.
+
+2005-10-01 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler.
+
+ * macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c.
+ (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debug code.
+ (Fx_create_frame, x_create_tip_frame) [USE_ATSUI]:
+ Try ATSUI-compatible 12pt Monaco font first.
+
+ * macgui.h (struct _XCharStruct): New member valid_p.
+ (STORE_XCHARSTRUCT): Set valid_p.
+ (struct MacFontStruct) [USE_ATSUI]: New member mac_style.
+
+ * macterm.c (mac_draw_string_common, x_per_char_metric)
+ (mac_compute_glyph_string_overhangs, init_font_name_table)
+ (XLoadQueryFont, mac_unload_font) [USE_ATSUI]: Add ATSUI support.
+ (atsu_get_text_layout_with_text_ptr) [USE_ATSUI]: New function.
+ (x_draw_glyph_string_background)
+ (x_draw_glyph_string_foreground) [MAC_OS8 && USE_ATSUI]: Don't use
+ XDrawImageString. Always draw background and foreground separately.
+ (x_draw_glyph_string_foreground) [USE_ATSUI]: Don't use 8-bit
+ functions for one-byte chars when using ATSUI-compatible fonts.
+ (atsu_font_id_hash) [USE_ATSUI]: New variable.
+ (syms_of_macterm) [USE_ATSUI]: Initialize and staticpro it.
+ (XLoadQueryFont): Set min_byte1, max_byte1, min_char_or_byte2, and
+ max_char_or_byte2 more in detail.
+ (quit_char_comp, mac_check_for_quit_char) [MAC_OSX]: Remove functions.
+
+2005-09-30 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct type.
+ * xterm.c (handle_one_xevent, handle_one_xevent): Likewise.
+
+ * unexelf.c (fatal): Fix prototype.
+
+ * term.c (fatal): Implement using varargs.
+
+ * regex.c (re_char): Move typedef ...
+ * regex.h (re_char): ... here.
+ (re_iswctype, re_wctype, re_set_whitespace_regexp): New prototypes.
+
+ * emacs.c (malloc_set_state): Fix return type.
+ (endif): Fix type.
+
+ * lisp.h (fatal): Add argument types.
+
+ * dispextern.h (fatal): Delete prototype.
+
+ * systime.h: (make_time): Prototype moved from ...
+ * editfns.c (make_time): ... here.
+
+ * editfns.c: Move systime.h include after lisp.h.
+ * dired.c:
+ * xsmfns.c:
+ * process.c: Likewise.
+
+ * alloc.c (old_malloc_hook, old_realloc_hook, old_realloc_hook):
+ Add parameter types.
+ (__malloc_hook, __realloc_hook, __free_hook): Fix prototypes.
+ (emacs_blocked_free): Change definition to match __free_hook.
+ (emacs_blocked_malloc): Change definition to match __malloc_hook.
+ (emacs_blocked_realloc): Change definition to match __realloc_hook.
+
+2005-09-30 Romain Francoise <romain@orebokech.com>
+
+ * minibuf.c (Fread_buffer): Follow convention for reading from the
+ minibuffer with a default value. Doc fix.
+
2005-09-29 Juri Linkov <juri@jurta.org>
* editfns.c (Fmessage, Fmessage_box, Fmessage_or_box):
@@ -48,8 +152,8 @@
2005-09-23 Dan Nicolaescu <dann@ics.uci.edu>
- * s/aix4-2.h (BROKEN_GET_CURRENT_DIR_NAME): Define
- BROKEN_GET_CURRENT_DIR_NAME.
+ * s/aix4-2.h (BROKEN_GET_CURRENT_DIR_NAME):
+ Define BROKEN_GET_CURRENT_DIR_NAME.
* sysdep.c (get_current_dir_name): Also define if
BROKEN_GET_CURRENT_DIR_NAME.
diff --git a/src/alloc.c b/src/alloc.c
index 35bdfc8a93a..5d8b1c1a359 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -547,6 +547,21 @@ DEFUN ("memory-full-p", Fmemory_full_p, Smemory_full_p, 0, 0, 0,
return (spare_memory ? Qnil : Qt);
}
+/* If we released our reserve (due to running out of memory),
+ and we have a fair amount free once again,
+ try to set aside another reserve in case we run out once more.
+
+ This is called when a relocatable block is freed in ralloc.c. */
+
+void
+refill_memory_reserve ()
+{
+#ifndef SYSTEM_MALLOC
+ if (spare_memory == 0)
+ spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
+#endif
+}
+
/* Called if we can't allocate relocatable space for a buffer. */
void
@@ -1134,20 +1149,6 @@ allocate_buffer ()
#ifndef SYSTEM_MALLOC
-/* If we released our reserve (due to running out of memory),
- and we have a fair amount free once again,
- try to set aside another reserve in case we run out once more.
-
- This is called when a relocatable block is freed in ralloc.c. */
-
-void
-refill_memory_reserve ()
-{
- if (spare_memory == 0)
- spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
-}
-
-
/* Arranging to disable input signals while we're in malloc.
This only works with GNU malloc. To help out systems which can't
@@ -1161,20 +1162,21 @@ refill_memory_reserve ()
#ifndef SYNC_INPUT
#ifndef DOUG_LEA_MALLOC
-extern void * (*__malloc_hook) P_ ((size_t));
-extern void * (*__realloc_hook) P_ ((void *, size_t));
-extern void (*__free_hook) P_ ((void *));
+extern void * (*__malloc_hook) P_ ((size_t, const void *));
+extern void * (*__realloc_hook) P_ ((void *, size_t, const void *));
+extern void (*__free_hook) P_ ((void *, const void *));
/* Else declared in malloc.h, perhaps with an extra arg. */
#endif /* DOUG_LEA_MALLOC */
-static void * (*old_malloc_hook) ();
-static void * (*old_realloc_hook) ();
-static void (*old_free_hook) ();
+static void * (*old_malloc_hook) P_ ((size_t, const void *));
+static void * (*old_realloc_hook) P_ ((void *, size_t, const void*));
+static void (*old_free_hook) P_ ((void*, const void*));
/* This function is used as the hook for free to call. */
static void
-emacs_blocked_free (ptr)
+emacs_blocked_free (ptr, ptr2)
void *ptr;
+ const void *ptr2;
{
BLOCK_INPUT_ALLOC;
@@ -1221,8 +1223,9 @@ emacs_blocked_free (ptr)
/* This function is the malloc hook that Emacs uses. */
static void *
-emacs_blocked_malloc (size)
+emacs_blocked_malloc (size, ptr)
size_t size;
+ const void *ptr;
{
void *value;
@@ -1268,9 +1271,10 @@ emacs_blocked_malloc (size)
/* This function is the realloc hook that Emacs uses. */
static void *
-emacs_blocked_realloc (ptr, size)
+emacs_blocked_realloc (ptr, size, ptr2)
void *ptr;
size_t size;
+ const void *ptr2;
{
void *value;
diff --git a/src/dired.c b/src/dired.c
index 4725644ee33..eca05cde0db 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -33,7 +33,6 @@ Boston, MA 02110-1301, USA. */
#include <grp.h>
#endif
-#include "systime.h"
#include <errno.h>
#ifdef VMS
@@ -93,6 +92,7 @@ extern struct direct *readdir ();
#endif
#include "lisp.h"
+#include "systime.h"
#include "buffer.h"
#include "commands.h"
#include "character.h"
diff --git a/src/dispextern.h b/src/dispextern.h
index e6e61ac45fb..db9cd53d042 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2940,7 +2940,6 @@ extern void calculate_costs P_ ((struct frame *));
extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
extern void tty_setup_colors P_ ((int));
extern void term_init P_ ((char *));
-extern void fatal P_ ((/* char *, ... */));
void cursor_to P_ ((int, int));
extern int tty_capable_p P_ ((struct frame *, unsigned, unsigned long, unsigned long));
diff --git a/src/editfns.c b/src/editfns.c
index 2fa6ffcca5c..dad41b3d05d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -37,6 +37,8 @@ Boston, MA 02110-1301, USA. */
#include <sys/utsname.h>
#endif
+#include "lisp.h"
+
/* systime.h includes <sys/time.h> which, on some systems, is required
for <sys/resource.h>; thus systime.h must be included before
<sys/resource.h> */
@@ -48,7 +50,6 @@ Boston, MA 02110-1301, USA. */
#include <ctype.h>
-#include "lisp.h"
#include "intervals.h"
#include "buffer.h"
#include "character.h"
@@ -71,7 +72,6 @@ Boston, MA 02110-1301, USA. */
extern char **environ;
#endif
-extern Lisp_Object make_time P_ ((time_t));
extern size_t emacs_strftimeu P_ ((char *, size_t, const char *,
const struct tm *, int));
static int tm_diff P_ ((struct tm *, struct tm *));
diff --git a/src/emacs.c b/src/emacs.c
index c74e729bf6a..a4416354c12 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -148,7 +148,7 @@ void *malloc_state_ptr;
/* From glibc, a routine that returns a copy of the malloc internal state. */
extern void *malloc_get_state ();
/* From glibc, a routine that overwrites the malloc internal state. */
-extern void malloc_set_state ();
+extern int malloc_set_state ();
/* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
dumping. Used to work around a bug in glibc's malloc. */
int malloc_using_checking;
@@ -1001,7 +1001,7 @@ main (argc, argv
&& !getrlimit (RLIMIT_STACK, &rlim))
{
long newlim;
- extern int re_max_failures;
+ extern size_t re_max_failures;
/* Approximate the amount regex.c needs per unit of re_max_failures. */
int ratio = 20 * sizeof (char *);
/* Then add 33% to cover the size of the smaller stacks that regex.c
diff --git a/src/image.c b/src/image.c
index bdc78c2d718..3b6969b0c28 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2178,7 +2178,7 @@ slurp_file (file, size)
if (stat (file, &st) == 0
&& (fp = fopen (file, "rb")) != NULL
- && (buf = (char *) xmalloc (st.st_size),
+ && (buf = (unsigned char *) xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{
*size = st.st_size;
@@ -3029,7 +3029,7 @@ xbm_read_bitmap_data (contents, end, width, height, data)
bytes_per_line = (*width + 7) / 8 + padding_p;
nbytes = bytes_per_line * *height;
- p = *data = (char *) xmalloc (nbytes);
+ p = *data = (unsigned char *) xmalloc (nbytes);
if (v10)
{
diff --git a/src/keyboard.c b/src/keyboard.c
index 3eabf6a5a8a..97d4509eeb6 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5506,13 +5506,23 @@ make_lispy_event (event)
if (CONSP (down)
&& INTEGERP (XCAR (down)) && INTEGERP (XCDR (down)))
{
- xdiff = XFASTINT (event->x) - XFASTINT (XCAR (down));
- ydiff = XFASTINT (event->y) - XFASTINT (XCDR (down));
+ xdiff = XINT (event->x) - XINT (XCAR (down));
+ ydiff = XINT (event->y) - XINT (XCDR (down));
}
if (xdiff < double_click_fuzz && xdiff > - double_click_fuzz
- && ydiff < double_click_fuzz
- && ydiff > - double_click_fuzz)
+ && ydiff < double_click_fuzz && ydiff > - double_click_fuzz
+ /* Maybe the mouse has moved a lot, caused scrolling, and
+ eventually ended up at the same screen position (but
+ not buffer position) in which case it is a drag, not
+ a click. */
+ /* FIXME: OTOH if the buffer position has changed
+ because of a timer or process filter rather than
+ because of mouse movement, it should be considered as
+ a click. But mouse-drag-region completely ignores
+ this case and it hasn't caused any real problem, so
+ it's probably OK to ignore it as well. */
+ && EQ (Fcar (Fcdr (start_pos)), Fcar (Fcdr (position))))
/* Mouse hasn't moved (much). */
event->modifiers |= click_modifier;
else
@@ -10741,11 +10751,6 @@ init_keyboard ()
poll_suppress_count = 1;
start_polling ();
#endif
-
-#ifdef MAC_OSX
- /* At least provide an escape route since C-g doesn't work. */
- signal (SIGINT, interrupt_signal);
-#endif
}
/* This type's only use is in syms_of_keyboard, to initialize the
diff --git a/src/macfns.c b/src/macfns.c
index 9d07dc49049..ecee09189f5 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -2532,6 +2532,10 @@ This function is an internal primitive--use `make-frame' instead. */)
}
/* Try out a font which we hope has bold and italic variations. */
+#if USE_ATSUI
+ if (! STRINGP (font))
+ font = x_new_font (f, "-*-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1");
+#endif
if (! STRINGP (font))
font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
/* If those didn't work, look for something which will at least work. */
@@ -3340,6 +3344,10 @@ start_hourglass ()
EMACS_TIME delay;
int secs, usecs = 0;
+ /* Don't bother for ttys. */
+ if (NILP (Vwindow_system))
+ return;
+
cancel_hourglass ();
if (INTEGERP (Vhourglass_delay)
@@ -3586,7 +3594,7 @@ x_create_tip_frame (dpyinfo, parms, text)
FRAME_FONTSET (f) = -1;
f->icon_name = Qnil;
-#if 0 /* GLYPH_DEBUG TODO: image support. */
+#if GLYPH_DEBUG
image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
@@ -3630,6 +3638,10 @@ x_create_tip_frame (dpyinfo, parms, text)
}
/* Try out a font which we hope has bold and italic variations. */
+#if USE_ATSUI
+ if (! STRINGP (font))
+ font = x_new_font (f, "-*-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1");
+#endif
if (! STRINGP (font))
font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
/* If those didn't work, look for something which will at least work. */
diff --git a/src/macgui.h b/src/macgui.h
index fc777de03ba..378dbcd9e5c 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -103,6 +103,7 @@ typedef struct _XCharStruct
#if 0
unsigned short attributes; /* per char flags (not predefined) */
#endif
+ unsigned valid_p : 1;
} XCharStruct;
#define STORE_XCHARSTRUCT(xcs, w, bds) \
@@ -110,7 +111,8 @@ typedef struct _XCharStruct
(xcs).lbearing = (bds).left, \
(xcs).rbearing = (bds).right, \
(xcs).ascent = -(bds).top, \
- (xcs).descent = (bds).bottom)
+ (xcs).descent = (bds).bottom, \
+ (xcs).valid_p = 1)
struct MacFontStruct {
char *full_name;
@@ -123,19 +125,9 @@ struct MacFontStruct {
#else
short mac_scriptcode; /* Mac OS script code for font used */
#endif
-
-#if 0
- SInt16 mFontNum; /* font number of font used in this window */
- short mScriptCode; /* Mac OS script code for font used */
- int mFontSize; /* size of font */
- Style mFontFace; /* plain, bold, italics, etc. */
- int mHeight; /* height of one line of text in pixels */
- int mWidth; /* width of one character in pixels */
- int mAscent;
- int mDescent;
- int mLeading;
- char mTwoByte; /* true for two-byte font */
-#endif /* 0 */
+#if USE_ATSUI
+ ATSUStyle mac_style; /* NULL if QuickDraw Text is used */
+#endif
/* from Xlib.h */
#if 0
diff --git a/src/macterm.c b/src/macterm.c
index 90d6a886db6..8001678ab92 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -660,6 +660,79 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
#endif
+#if USE_ATSUI
+static OSStatus
+atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
+ ConstUniCharArrayPtr text;
+ UniCharCount text_length;
+ ATSUStyle style;
+ ATSUTextLayout *text_layout;
+{
+ OSStatus err;
+ static ATSUTextLayout saved_text_layout = NULL; /* not reentrant */
+
+ if (saved_text_layout == NULL)
+ {
+ UniCharCount lengths[] = {kATSUToTextEnd};
+ ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag};
+ ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)};
+ static ATSLineLayoutOptions line_layout =
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
+ kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics
+#else
+ kATSLineIsDisplayOnly
+#endif
+ ;
+ ATSUAttributeValuePtr values[] = {&line_layout};
+
+ err = ATSUCreateTextLayoutWithTextPtr (text,
+ kATSUFromTextBeginning,
+ kATSUToTextEnd,
+ text_length,
+ 1, lengths, &style,
+ &saved_text_layout);
+ if (err == noErr)
+ err = ATSUSetLayoutControls (saved_text_layout,
+ sizeof (tags) / sizeof (tags[0]),
+ tags, sizes, values);
+ /* XXX: Should we do this? */
+ if (err == noErr)
+ err = ATSUSetTransientFontMatching (saved_text_layout, true);
+ }
+ else
+ {
+ err = ATSUSetRunStyle (saved_text_layout, style,
+ kATSUFromTextBeginning, kATSUToTextEnd);
+ if (err == noErr)
+ err = ATSUSetTextPointerLocation (saved_text_layout, text,
+ kATSUFromTextBeginning,
+ kATSUToTextEnd,
+ text_length);
+ }
+
+ if (err == noErr)
+ *text_layout = saved_text_layout;
+ return err;
+}
+#endif
+
+static void
+mac_invert_rectangle (display, w, x, y, width, height)
+ Display *display;
+ WindowPtr w;
+ int x, y;
+ unsigned int width, height;
+{
+ Rect r;
+
+ SetPortWindowPort (w);
+
+ SetRect (&r, x, y, x + width, y + height);
+
+ InvertRect (&r);
+}
+
+
static void
mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
bytes_per_char)
@@ -684,6 +757,89 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
if (mode != srcOr)
RGBBackColor (GC_BACK_COLOR (gc));
+#if USE_ATSUI
+ if (GC_FONT (gc)->mac_style)
+ {
+ OSErr err;
+ ATSUTextLayout text_layout;
+
+ xassert (bytes_per_char == 2);
+
+#ifndef WORDS_BIG_ENDIAN
+ {
+ int i;
+ Unichar *text = (Unichar *)buf;
+
+ for (i = 0; i < nchars; i++)
+ text[i] = buf[2*i] << 8 | buf[2*i+1];
+ }
+#endif
+ err = atsu_get_text_layout_with_text_ptr ((ConstUniCharArrayPtr)buf,
+ nchars,
+ GC_FONT (gc)->mac_style,
+ &text_layout);
+ if (err == noErr)
+ {
+#ifdef MAC_OSX
+ if (NILP (Vmac_use_core_graphics))
+ {
+#endif
+ MoveTo (x, y);
+ ATSUDrawText (text_layout,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
+#ifdef MAC_OSX
+ }
+ else
+ {
+ CGrafPtr port;
+ CGContextRef context;
+ Rect rect;
+ RgnHandle region = NewRgn ();
+ float port_height;
+ ATSUAttributeTag tags[] = {kATSUCGContextTag};
+ ByteCount sizes[] = {sizeof (CGContextRef)};
+ ATSUAttributeValuePtr values[] = {&context};
+
+ GetPort (&port);
+ QDBeginCGContext (port, &context);
+ GetPortBounds (port, &rect);
+ port_height = rect.bottom - rect.top;
+ GetClip (region);
+ GetRegionBounds (region, &rect);
+ /* XXX: This is not correct if the clip region is not a
+ simple rectangle. */
+ CGContextClipToRect (context,
+ CGRectMake (rect.left,
+ port_height - rect.bottom,
+ rect.right - rect.left,
+ rect.bottom - rect.top));
+ DisposeRgn (region);
+ CGContextSetRGBFillColor
+ (context,
+ RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
+ GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
+ BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
+ 1.0);
+ err = ATSUSetLayoutControls (text_layout,
+ sizeof (tags) / sizeof (tags[0]),
+ tags, sizes, values);
+ if (err == noErr)
+ ATSUDrawText (text_layout,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ Long2Fix (x), Long2Fix (port_height - y));
+ ATSUClearLayoutControls (text_layout,
+ sizeof (tags) / sizeof (tags[0]),
+ tags);
+ CGContextSynchronize (context);
+ QDEndCGContext (port, &context);
+ }
+#endif
+ }
+ }
+ else
+ {
+#endif
TextFont (GC_FONT (gc)->mac_fontnum);
TextSize (GC_FONT (gc)->mac_fontsize);
TextFace (GC_FONT (gc)->mac_fontface);
@@ -691,6 +847,9 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
MoveTo (x, y);
DrawText (buf, 0, nchars * bytes_per_char);
+#if USE_ATSUI
+ }
+#endif
if (mode != srcOr)
RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
@@ -1552,6 +1711,61 @@ x_per_char_metric (font, char2b)
xassert (font && char2b);
+#if USE_ATSUI
+ if (font->mac_style)
+ {
+ if (char2b->byte1 >= font->min_byte1
+ && char2b->byte1 <= font->max_byte1
+ && char2b->byte2 >= font->min_char_or_byte2
+ && char2b->byte2 <= font->max_char_or_byte2)
+ {
+ pcm = (font->per_char
+ + ((font->max_char_or_byte2 - font->min_char_or_byte2 + 1)
+ * (char2b->byte1 - font->min_byte1))
+ + (char2b->byte2 - font->min_char_or_byte2));
+ }
+
+ if (pcm && !pcm->valid_p)
+ {
+ OSErr err;
+ ATSUTextLayout text_layout;
+ UniChar c;
+ int char_width;
+ ATSTrapezoid glyph_bounds;
+ Rect char_bounds;
+
+ c = (char2b->byte1 << 8) + char2b->byte2;
+ BLOCK_INPUT;
+ err = atsu_get_text_layout_with_text_ptr (&c, 1,
+ font->mac_style,
+ &text_layout);
+ if (err == noErr)
+ err = ATSUMeasureTextImage (text_layout,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ 0, 0, &char_bounds);
+
+ if (err == noErr)
+ err = ATSUGetGlyphBounds (text_layout, 0, 0,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ kATSUseFractionalOrigins, 1,
+ &glyph_bounds, NULL);
+ UNBLOCK_INPUT;
+ if (err != noErr)
+ pcm = NULL;
+ else
+ {
+ xassert (glyph_bounds.lowerRight.x - glyph_bounds.lowerLeft.x
+ == glyph_bounds.upperRight.x - glyph_bounds.upperLeft.x);
+
+ char_width = Fix2Long (glyph_bounds.upperRight.x
+ - glyph_bounds.upperLeft.x);
+ STORE_XCHARSTRUCT (*pcm, char_width, char_bounds);
+ }
+ }
+ }
+ else
+ {
+#endif
if (font->per_char != NULL)
{
if (font->min_byte1 == 0 && font->max_byte1 == 0)
@@ -1603,6 +1817,9 @@ x_per_char_metric (font, char2b)
&& char2b->byte2 <= font->max_char_or_byte2)
pcm = &font->max_bounds;
}
+#if USE_ATSUI
+ }
+#endif
return ((pcm == NULL
|| (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0))
@@ -1930,6 +2147,35 @@ mac_compute_glyph_string_overhangs (s)
Rect r;
MacFontStruct *font = s->font;
+#if USE_ATSUI
+ if (font->mac_style)
+ {
+ OSErr err;
+ ATSUTextLayout text_layout;
+ UniChar *buf;
+ int i;
+
+ SetRect (&r, 0, 0, 0, 0);
+ buf = xmalloc (sizeof (UniChar) * s->nchars);
+ if (buf)
+ {
+ for (i = 0; i < s->nchars; i++)
+ buf[i] = (s->char2b[i].byte1 << 8) + s->char2b[i].byte2;
+
+ err = atsu_get_text_layout_with_text_ptr (buf, s->nchars,
+ font->mac_style,
+ &text_layout);
+ if (err == noErr)
+ err = ATSUMeasureTextImage (text_layout,
+ kATSUFromTextBeginning,
+ kATSUToTextEnd,
+ 0, 0, &r);
+ xfree (buf);
+ }
+ }
+ else
+ {
+#endif
TextFont (font->mac_fontnum);
TextSize (font->mac_fontsize);
TextFace (font->mac_fontface);
@@ -1951,6 +2197,9 @@ mac_compute_glyph_string_overhangs (s)
xfree (buf);
}
}
+#if USE_ATSUI
+ }
+#endif
s->right_overhang = r.right > s->width ? r.right - s->width : 0;
s->left_overhang = r.left < 0 ? -r.left : 0;
@@ -2008,7 +2257,7 @@ x_draw_glyph_string_background (s, force_p)
}
else
#endif
-#ifdef MAC_OS8
+#if defined (MAC_OS8) && !USE_ATSUI
if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
|| s->font_not_found_p
|| s->extends_to_end_of_line_p
@@ -2062,11 +2311,15 @@ x_draw_glyph_string_foreground (s)
boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
/* If we can use 8-bit functions, condense S->char2b. */
- if (!s->two_byte_p)
+ if (!s->two_byte_p
+#if USE_ATSUI
+ && GC_FONT (s->gc)->mac_style == NULL
+#endif
+ )
for (i = 0; i < s->nchars; ++i)
char1b[i] = s->char2b[i].byte2;
-#ifdef MAC_OS8
+#if defined (MAC_OS8) && !USE_ATSUI
/* Draw text with XDrawString if background has already been
filled. Otherwise, use XDrawImageString. (Note that
XDrawImageString is usually faster than XDrawString.) Always
@@ -2077,14 +2330,18 @@ x_draw_glyph_string_foreground (s)
#endif
{
/* Draw characters with 16-bit or 8-bit functions. */
- if (s->two_byte_p)
+ if (s->two_byte_p
+#if USE_ATSUI
+ || GC_FONT (s->gc)->mac_style
+#endif
+ )
XDrawString16 (s->display, s->window, s->gc, x,
s->ybase - boff, s->char2b, s->nchars);
else
XDrawString (s->display, s->window, s->gc, x,
s->ybase - boff, char1b, s->nchars);
}
-#ifdef MAC_OS8
+#if defined (MAC_OS8) && !USE_ATSUI
else
{
if (s->two_byte_p)
@@ -3251,9 +3508,57 @@ void
XTflash (f)
struct frame *f;
{
+ /* Get the height not including a menu bar widget. */
+ int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
+ /* Height of each line to flash. */
+ int flash_height = FRAME_LINE_HEIGHT (f);
+ /* These will be the left and right margins of the rectangles. */
+ int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
+ int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
+
+ int width;
+
+ /* Don't flash the area between a scroll bar and the frame
+ edge it is next to. */
+ switch (FRAME_VERTICAL_SCROLL_BAR_TYPE (f))
+ {
+ case vertical_scroll_bar_left:
+ flash_left += VERTICAL_SCROLL_BAR_WIDTH_TRIM;
+ break;
+
+ case vertical_scroll_bar_right:
+ flash_right -= VERTICAL_SCROLL_BAR_WIDTH_TRIM;
+ break;
+
+ default:
+ break;
+ }
+
+ width = flash_right - flash_left;
+
BLOCK_INPUT;
- FlashMenuBar (0);
+ /* If window is tall, flash top and bottom line. */
+ if (height > 3 * FRAME_LINE_HEIGHT (f))
+ {
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left,
+ (FRAME_INTERNAL_BORDER_WIDTH (f)
+ + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
+ width, flash_height);
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left,
+ (height - flash_height
+ - FRAME_INTERNAL_BORDER_WIDTH (f)),
+ width, flash_height);
+ }
+ else
+ /* If it is short, flash it all. */
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+
+ x_flush (f);
{
struct timeval wakeup;
@@ -3265,24 +3570,49 @@ XTflash (f)
wakeup.tv_sec += (wakeup.tv_usec / 1000000);
wakeup.tv_usec %= 1000000;
- /* Keep waiting until past the time wakeup. */
- while (1)
+ /* Keep waiting until past the time wakeup or any input gets
+ available. */
+ while (! detect_input_pending ())
{
- struct timeval timeout;
+ struct timeval current;
+ struct timeval timeout;
- EMACS_GET_TIME (timeout);
+ EMACS_GET_TIME (current);
- /* In effect, timeout = wakeup - timeout.
- Break if result would be negative. */
- if (timeval_subtract (&timeout, wakeup, timeout))
- break;
+ /* Break if result would be negative. */
+ if (timeval_subtract (&current, wakeup, current))
+ break;
- /* Try to wait that long--but we might wake up sooner. */
- select (0, NULL, NULL, NULL, &timeout);
+ /* How long `select' should wait. */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 10000;
+
+ /* Try to wait that long--but we might wake up sooner. */
+ select (0, NULL, NULL, NULL, &timeout);
}
}
- FlashMenuBar (0);
+ /* If window is tall, flash top and bottom line. */
+ if (height > 3 * FRAME_LINE_HEIGHT (f))
+ {
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left,
+ (FRAME_INTERNAL_BORDER_WIDTH (f)
+ + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
+ width, flash_height);
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left,
+ (height - flash_height
+ - FRAME_INTERNAL_BORDER_WIDTH (f)),
+ width, flash_height);
+ }
+ else
+ /* If it is short, flash it all. */
+ mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+ flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+
+ x_flush (f);
UNBLOCK_INPUT;
}
@@ -6447,6 +6777,10 @@ static char **font_name_table = NULL;
static int font_name_table_size = 0;
static int font_name_count = 0;
+#if USE_ATSUI
+static Lisp_Object atsu_font_id_hash;
+#endif
+
/* Alist linking character set strings to Mac text encoding and Emacs
coding system. */
static Lisp_Object Vmac_charset_info_alist;
@@ -6653,6 +6987,74 @@ init_font_name_table ()
Lisp_Object text_encoding_info_alist;
struct gcpro gcpro1;
+ text_encoding_info_alist = create_text_encoding_info_alist ();
+
+#if USE_ATSUI
+ if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode),
+ text_encoding_info_alist)))
+ {
+ OSErr err;
+ ItemCount nfonts, i;
+ ATSUFontID *font_ids = NULL;
+ Ptr name, prev_name = NULL;
+ ByteCount name_len;
+
+ atsu_font_id_hash =
+ make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
+ make_float (DEFAULT_REHASH_SIZE),
+ make_float (DEFAULT_REHASH_THRESHOLD),
+ Qnil, Qnil, Qnil);;
+ err = ATSUFontCount (&nfonts);
+ if (err == noErr)
+ font_ids = xmalloc (sizeof (ATSUFontID) * nfonts);
+ if (font_ids)
+ err = ATSUGetFontIDs (font_ids, nfonts, NULL);
+ if (err == noErr)
+ for (i = 0; i < nfonts; i++)
+ {
+ err = ATSUFindFontName (font_ids[i], kFontFamilyName,
+ kFontMacintoshPlatform, kFontNoScript,
+ kFontNoLanguage, 0, NULL, &name_len, NULL);
+ if (err != noErr)
+ continue;
+ name = xmalloc (name_len + 1);
+ if (name == NULL)
+ continue;
+ name[name_len] = '\0';
+ err = ATSUFindFontName (font_ids[i], kFontFamilyName,
+ kFontMacintoshPlatform, kFontNoScript,
+ kFontNoLanguage, name_len, name,
+ NULL, NULL);
+ if (err == noErr
+ && *name != '.'
+ && (prev_name == NULL
+ || strcmp (name, prev_name) != 0))
+ {
+ static char *cs = "iso10646-1";
+
+ add_font_name_table_entry (mac_to_x_fontname (name, 0,
+ normal, cs));
+ add_font_name_table_entry (mac_to_x_fontname (name, 0,
+ italic, cs));
+ add_font_name_table_entry (mac_to_x_fontname (name, 0,
+ bold, cs));
+ add_font_name_table_entry (mac_to_x_fontname (name, 0,
+ italic | bold, cs));
+ Fputhash (Fdowncase (make_unibyte_string (name, name_len)),
+ long_to_cons (font_ids[i]), atsu_font_id_hash);
+ xfree (prev_name);
+ prev_name = name;
+ }
+ else
+ xfree (name);
+ }
+ if (prev_name)
+ xfree (prev_name);
+ if (font_ids)
+ xfree (font_ids);
+ }
+#endif
+
/* Create a dummy instance iterator here to avoid creating and
destroying it in the loop. */
if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
@@ -6665,8 +7067,6 @@ init_font_name_table ()
return;
}
- text_encoding_info_alist = create_text_encoding_info_alist ();
-
GCPRO1 (text_encoding_info_alist);
while (FMGetNextFontFamily (&ffi, &ff) == noErr)
@@ -7163,6 +7563,9 @@ XLoadQueryFont (Display *dpy, char *fontname)
Str255 mfontname, mfontname_decoded;
Str31 charset;
SInt16 fontnum;
+#if USE_ATSUI
+ ATSUStyle mac_style = NULL;
+#endif
Style fontface;
#if TARGET_API_MAC_CARBON
TextEncoding encoding;
@@ -7214,6 +7617,48 @@ XLoadQueryFont (Display *dpy, char *fontname)
x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded,
&fontface, charset);
+#if USE_ATSUI
+ if (strcmp (charset, "iso10646-1") == 0) /* XXX */
+ {
+ OSErr err;
+ ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag,
+ kATSUQDBoldfaceTag, kATSUQDItalicTag};
+ ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
+ sizeof (Boolean), sizeof (Boolean)};
+ static ATSUFontID font_id;
+ static Fixed size_fixed;
+ static Boolean bold_p, italic_p;
+ ATSUAttributeValuePtr values[] = {&font_id, &size_fixed,
+ &bold_p, &italic_p};
+ ATSUFontFeatureType types[] = {kAllTypographicFeaturesType};
+ ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector};
+ Lisp_Object font_id_cons;
+
+ font_id_cons = Fgethash (Fdowncase
+ (make_unibyte_string (mfontname,
+ strlen (mfontname))),
+ atsu_font_id_hash, Qnil);
+ if (NILP (font_id_cons))
+ return NULL;
+ font_id = cons_to_long (font_id_cons);
+ size_fixed = Long2Fix (size);
+ bold_p = (fontface & bold) != 0;
+ italic_p = (fontface & italic) != 0;
+ err = ATSUCreateStyle (&mac_style);
+ if (err != noErr)
+ return NULL;
+ err = ATSUSetFontFeatures (mac_style, sizeof (types) / sizeof (types[0]),
+ types, selectors);
+ if (err != noErr)
+ return NULL;
+ err = ATSUSetAttributes (mac_style, sizeof (tags) / sizeof (tags[0]),
+ tags, sizes, values);
+ fontnum = -1;
+ scriptcode = kTextEncodingMacUnicode;
+ }
+ else
+ {
+#endif
c2pstr (mfontname);
#if TARGET_API_MAC_CARBON
fontnum = FMGetFontFamilyFromName (mfontname);
@@ -7227,6 +7672,9 @@ XLoadQueryFont (Display *dpy, char *fontname)
return NULL;
scriptcode = FontToScript (fontnum);
#endif
+#if USE_ATSUI
+ }
+#endif
font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
@@ -7234,6 +7682,9 @@ XLoadQueryFont (Display *dpy, char *fontname)
font->mac_fontsize = size;
font->mac_fontface = fontface;
font->mac_scriptcode = scriptcode;
+#if USE_ATSUI
+ font->mac_style = mac_style;
+#endif
/* Apple Japanese (SJIS) font is listed as both
"*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
@@ -7244,6 +7695,91 @@ XLoadQueryFont (Display *dpy, char *fontname)
font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset);
+#if USE_ATSUI
+ if (font->mac_style)
+ {
+ OSErr err;
+ ATSUTextLayout text_layout;
+ UniChar c = 0x20;
+ Rect char_bounds, min_bounds, max_bounds;
+ int min_width, max_width;
+ ATSTrapezoid glyph_bounds;
+
+ font->per_char = xmalloc (sizeof (XCharStruct) * 0x10000);
+ if (font->per_char == NULL)
+ {
+ mac_unload_font (&one_mac_display_info, font);
+ return NULL;
+ }
+ bzero (font->per_char, sizeof (XCharStruct) * 0x10000);
+
+ err = atsu_get_text_layout_with_text_ptr (&c, 1,
+ font->mac_style,
+ &text_layout);
+ if (err != noErr)
+ {
+ mac_unload_font (&one_mac_display_info, font);
+ return NULL;
+ }
+
+ for (c = 0x20; c <= 0x7e; c++)
+ {
+ err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning);
+ if (err == noErr)
+ err = ATSUMeasureTextImage (text_layout,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ 0, 0, &char_bounds);
+ if (err == noErr)
+ err = ATSUGetGlyphBounds (text_layout, 0, 0,
+ kATSUFromTextBeginning, kATSUToTextEnd,
+ kATSUseFractionalOrigins, 1,
+ &glyph_bounds, NULL);
+ if (err == noErr)
+ {
+ xassert (glyph_bounds.lowerRight.x - glyph_bounds.lowerLeft.x
+ == glyph_bounds.upperRight.x - glyph_bounds.upperLeft.x);
+
+ char_width = Fix2Long (glyph_bounds.upperRight.x
+ - glyph_bounds.upperLeft.x);
+ STORE_XCHARSTRUCT (font->per_char[c],
+ char_width, char_bounds);
+ if (c == 0x20)
+ {
+ min_width = max_width = char_width;
+ min_bounds = max_bounds = char_bounds;
+ font->ascent = -Fix2Long (glyph_bounds.upperLeft.y);
+ font->descent = Fix2Long (glyph_bounds.lowerLeft.y);
+ }
+ else
+ {
+ if (char_width > 0)
+ {
+ min_width = min (min_width, char_width);
+ max_width = max (max_width, char_width);
+ }
+ if (!EmptyRect (&char_bounds))
+ {
+ SetRect (&min_bounds,
+ max (min_bounds.left, char_bounds.left),
+ max (min_bounds.top, char_bounds.top),
+ min (min_bounds.right, char_bounds.right),
+ min (min_bounds.bottom, char_bounds.bottom));
+ UnionRect (&max_bounds, &char_bounds, &max_bounds);
+ }
+ }
+ }
+ }
+ STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
+ STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
+
+ font->min_byte1 = 0;
+ font->max_byte1 = 0xff;
+ font->min_char_or_byte2 = 0;
+ font->max_char_or_byte2 = 0xff;
+ }
+ else
+ {
+#endif
is_two_byte_font = font->mac_scriptcode == smJapanese ||
font->mac_scriptcode == smTradChinese ||
font->mac_scriptcode == smSimpChinese ||
@@ -7258,24 +7794,26 @@ XLoadQueryFont (Display *dpy, char *fontname)
font->ascent = the_fontinfo.ascent;
font->descent = the_fontinfo.descent;
- font->min_byte1 = 0;
- if (is_two_byte_font)
- font->max_byte1 = 1;
- else
- font->max_byte1 = 0;
- font->min_char_or_byte2 = 0x20;
- font->max_char_or_byte2 = 0xff;
-
if (is_two_byte_font)
{
+ font->min_byte1 = 0xa1;
+ font->max_byte1 = 0xfe;
+ font->min_char_or_byte2 = 0xa1;
+ font->max_char_or_byte2 = 0xfe;
+
/* Use the width of an "ideographic space" of that font because
the_fontinfo.widMax returns the wrong width for some fonts. */
switch (font->mac_scriptcode)
{
case smJapanese:
+ font->min_byte1 = 0x81;
+ font->max_byte1 = 0xfc;
+ font->min_char_or_byte2 = 0x40;
+ font->max_char_or_byte2 = 0xfc;
char_width = StringWidth("\p\x81\x40");
break;
case smTradChinese:
+ font->min_char_or_byte2 = 0x40;
char_width = StringWidth("\p\xa1\x40");
break;
case smSimpChinese:
@@ -7287,9 +7825,15 @@ XLoadQueryFont (Display *dpy, char *fontname)
}
}
else
- /* Do this instead of use the_fontinfo.widMax, which incorrectly
- returns 15 for 12-point Monaco! */
- char_width = CharWidth ('m');
+ {
+ font->min_byte1 = font->max_byte1 = 0;
+ font->min_char_or_byte2 = 0x20;
+ font->max_char_or_byte2 = 0xff;
+
+ /* Do this instead of use the_fontinfo.widMax, which incorrectly
+ returns 15 for 12-point Monaco! */
+ char_width = CharWidth ('m');
+ }
if (is_two_byte_font)
{
@@ -7308,55 +7852,56 @@ XLoadQueryFont (Display *dpy, char *fontname)
}
else
{
- font->per_char = (XCharStruct *)
- xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
- {
- int c, min_width, max_width;
- Rect char_bounds, min_bounds, max_bounds;
- char ch;
-
- min_width = max_width = char_width;
- SetRect (&min_bounds, -32767, -32767, 32767, 32767);
- SetRect (&max_bounds, 0, 0, 0, 0);
- for (c = 0x20; c <= 0xff; c++)
- {
- ch = c;
- char_width = CharWidth (ch);
- QDTextBounds (1, &ch, &char_bounds);
- STORE_XCHARSTRUCT (font->per_char[c - 0x20],
- char_width, char_bounds);
- /* Some Japanese fonts (in SJIS encoding) return 0 as the
- character width of 0x7f. */
- if (char_width > 0)
- {
- min_width = min (min_width, char_width);
- max_width = max (max_width, char_width);
- }
- if (!EmptyRect (&char_bounds))
- {
- SetRect (&min_bounds,
- max (min_bounds.left, char_bounds.left),
- max (min_bounds.top, char_bounds.top),
- min (min_bounds.right, char_bounds.right),
- min (min_bounds.bottom, char_bounds.bottom));
- UnionRect (&max_bounds, &char_bounds, &max_bounds);
- }
- }
- STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
- STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
- if (min_width == max_width
- && max_bounds.left >= 0 && max_bounds.right <= max_width)
- {
- /* Fixed width and no overhangs. */
- xfree (font->per_char);
- font->per_char = NULL;
- }
- }
+ int c, min_width, max_width;
+ Rect char_bounds, min_bounds, max_bounds;
+ char ch;
+
+ font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
+
+ min_width = max_width = char_width;
+ SetRect (&min_bounds, -32767, -32767, 32767, 32767);
+ SetRect (&max_bounds, 0, 0, 0, 0);
+ for (c = 0x20; c <= 0xff; c++)
+ {
+ ch = c;
+ char_width = CharWidth (ch);
+ QDTextBounds (1, &ch, &char_bounds);
+ STORE_XCHARSTRUCT (font->per_char[c - 0x20],
+ char_width, char_bounds);
+ /* Some Japanese fonts (in SJIS encoding) return 0 as the
+ character width of 0x7f. */
+ if (char_width > 0)
+ {
+ min_width = min (min_width, char_width);
+ max_width = max (max_width, char_width);
+ }
+ if (!EmptyRect (&char_bounds))
+ {
+ SetRect (&min_bounds,
+ max (min_bounds.left, char_bounds.left),
+ max (min_bounds.top, char_bounds.top),
+ min (min_bounds.right, char_bounds.right),
+ min (min_bounds.bottom, char_bounds.bottom));
+ UnionRect (&max_bounds, &char_bounds, &max_bounds);
+ }
+ }
+ STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
+ STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
+ if (min_width == max_width
+ && max_bounds.left >= 0 && max_bounds.right <= max_width)
+ {
+ /* Fixed width and no overhangs. */
+ xfree (font->per_char);
+ font->per_char = NULL;
+ }
}
TextFont (old_fontnum); /* restore previous font number, size and face */
TextSize (old_fontsize);
TextFace (old_fontface);
+#if USE_ATSUI
+ }
+#endif
return font;
}
@@ -7370,6 +7915,10 @@ mac_unload_font (dpyinfo, font)
xfree (font->full_name);
if (font->per_char)
xfree (font->per_char);
+#if USE_ATSUI
+ if (font->mac_style)
+ ATSUDisposeStyle (font->mac_style);
+#endif
xfree (font);
}
@@ -10214,75 +10763,6 @@ init_quit_char_handler ()
mac_determine_quit_char_modifiers();
}
-
-static Boolean
-quit_char_comp (EventRef inEvent, void *inCompData)
-{
- if (GetEventClass(inEvent) != kEventClassKeyboard)
- return false;
- if (GetEventKind(inEvent) != kEventRawKeyDown)
- return false;
- {
- UInt32 keyCode;
- UInt32 keyModifiers;
- GetEventParameter(inEvent, kEventParamKeyCode,
- typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
- if (keyCode != mac_quit_char_keycode)
- return false;
- GetEventParameter(inEvent, kEventParamKeyModifiers,
- typeUInt32, NULL, sizeof(UInt32), NULL, &keyModifiers);
- if (keyModifiers != mac_quit_char_modifiers)
- return false;
- }
- return true;
-}
-
-void
-mac_check_for_quit_char ()
-{
- EventRef event;
- static EMACS_TIME last_check_time = { 0, 0 };
- static EMACS_TIME one_second = { 1, 0 };
- EMACS_TIME now, t;
-
- /* If windows are not initialized, return immediately (keep it bouncin'). */
- if (!mac_quit_char_modifiers)
- return;
-
- /* Don't check if last check is less than a second ago. */
- EMACS_GET_TIME (now);
- EMACS_SUB_TIME (t, now, last_check_time);
- if (EMACS_TIME_LT (t, one_second))
- return;
- last_check_time = now;
-
- /* Redetermine modifiers because they are based on lisp variables */
- mac_determine_quit_char_modifiers ();
-
- /* Fill the queue with events */
- BLOCK_INPUT;
- ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);
- event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp,
- NULL);
- UNBLOCK_INPUT;
- if (event)
- {
- struct input_event e;
-
- /* Use an input_event to emulate what the interrupt handler does. */
- EVENT_INIT (e);
- e.kind = ASCII_KEYSTROKE_EVENT;
- e.code = quit_char;
- e.arg = Qnil;
- e.modifiers = NULL;
- e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
- XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info));
- /* Remove event from queue to prevent looping. */
- RemoveEventFromQueue (GetMainEventQueue (), event);
- ReleaseEvent (event);
- kbd_buffer_store_event (&e);
- }
-}
#endif /* MAC_OSX */
static void
@@ -10460,6 +10940,11 @@ syms_of_macterm ()
Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
staticpro (&Qmac_ready_for_drag_n_drop);
+#if USE_ATSUI
+ staticpro (&atsu_font_id_hash);
+ atsu_font_id_hash = Qnil;
+#endif
+
DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
doc: /* If not nil, Emacs uses toolkit scroll bars. */);
#ifdef USE_TOOLKIT_SCROLL_BARS
diff --git a/src/minibuf.c b/src/minibuf.c
index c0624bd29b4..b7f9fd4838c 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1132,11 +1132,14 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 3, 0,
Prompt with PROMPT.
Optional second arg DEF is value to return if user enters an empty line.
If optional third arg REQUIRE-MATCH is non-nil,
- only existing buffer names are allowed. */)
+ only existing buffer names are allowed.
+The argument PROMPT should be a string ending with a colon and a space. */)
(prompt, def, require_match)
Lisp_Object prompt, def, require_match;
{
Lisp_Object args[4];
+ unsigned char *s;
+ int len;
if (BUFFERP (def))
def = XBUFFER (def)->name;
@@ -1145,7 +1148,26 @@ If optional third arg REQUIRE-MATCH is non-nil,
{
if (!NILP (def))
{
- args[0] = build_string ("%s(default %s) ");
+ /* A default value was provided: we must change PROMPT,
+ editing the default value in before the colon. To achieve
+ this, we replace PROMPT with a substring that doesn't
+ contain the terminal space and colon (if present). They
+ are then added back using Fformat. */
+
+ if (STRINGP (prompt))
+ {
+ s = SDATA (prompt);
+ len = strlen (s);
+ if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ')
+ len = len - 2;
+ else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' '))
+ len--;
+
+ prompt = make_specified_string (s, -1, len,
+ STRING_MULTIBYTE (prompt));
+ }
+
+ args[0] = build_string ("%s (default %s): ");
args[1] = prompt;
args[2] = def;
prompt = Fformat (3, args);
diff --git a/src/process.c b/src/process.c
index bebced812e8..b66c768c256 100644
--- a/src/process.c
+++ b/src/process.c
@@ -118,10 +118,10 @@ Boston, MA 02110-1301, USA. */
#include <sys/wait.h>
#endif
+#include "lisp.h"
#include "systime.h"
#include "systty.h"
-#include "lisp.h"
#include "window.h"
#include "buffer.h"
#include "character.h"
diff --git a/src/regex.c b/src/regex.c
index bc1ade0bb6e..412fd1d524d 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1290,9 +1290,9 @@ static re_char *whitespace_regexp;
void
re_set_whitespace_regexp (regexp)
- re_char *regexp;
+ const char *regexp;
{
- whitespace_regexp = regexp;
+ whitespace_regexp = (re_char *) regexp;
}
WEAK_ALIAS (__re_set_syntax, re_set_syntax)
diff --git a/src/regex.h b/src/regex.h
index 68db62d34e0..8a669541ff1 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -609,8 +609,13 @@ typedef enum { RECC_ERROR = 0,
RECC_ASCII, RECC_UNIBYTE
} re_wctype_t;
+extern char re_iswctype (int ch, re_wctype_t cc);
+extern re_wctype_t re_wctype (const unsigned char* str);
+
typedef int re_wchar_t;
+extern void re_set_whitespace_regexp (const char *regexp);
+
#endif /* not WIDE_CHAR_SUPPORT */
#endif /* regex.h */
diff --git a/src/systime.h b/src/systime.h
index 1d0022e93d7..9851db4cf33 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -157,6 +157,14 @@ extern int set_file_times __P ((const char *, EMACS_TIME, EMACS_TIME));
/* defined in keyboard.c */
extern void set_waiting_for_input __P ((EMACS_TIME *));
+/* When lisp.h is not included Lisp_Object is not defined (this can
+ happen when this files is used outside the src directory).
+ Use GCPRO1 to determine if lisp.h was included. */
+#ifdef GCPRO1
+/* defined in dired.c */
+extern Lisp_Object make_time __P ((time_t));
+#endif
+
/* Compare times T1 and T2. Value is 0 if T1 and T2 are the same.
Value is < 0 if T1 is less than T2. Value is > 0 otherwise. */
diff --git a/src/unexelf.c b/src/unexelf.c
index ee563b36a97..e33a9a1aeb3 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -412,7 +412,7 @@ temacs:
#include <string.h>
#else
#include <config.h>
-extern void fatal (char *, ...);
+extern void fatal (const char *msgid, ...);
#endif
#include <sys/types.h>
diff --git a/src/window.c b/src/window.c
index 198edd3d6d8..9a0d256cdce 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6225,6 +6225,85 @@ usage: (save-window-excursion BODY ...) */)
return unbind_to (count, val);
}
+
+
+/***********************************************************************
+ Window Split Tree
+ ***********************************************************************/
+
+static Lisp_Object
+window_split_tree (w)
+ struct window *w;
+{
+ Lisp_Object tail = Qnil;
+ Lisp_Object result = Qnil;
+
+ while (w)
+ {
+ Lisp_Object wn;
+
+ XSETWINDOW (wn, w);
+ if (!NILP (w->hchild))
+ wn = Fcons (Qnil, Fcons (Fwindow_edges (wn),
+ window_split_tree (XWINDOW (w->hchild))));
+ else if (!NILP (w->vchild))
+ wn = Fcons (Qt, Fcons (Fwindow_edges (wn),
+ window_split_tree (XWINDOW (w->vchild))));
+
+ if (NILP (result))
+ {
+ result = tail = Fcons (wn, Qnil);
+ }
+ else
+ {
+ XSETCDR (tail, Fcons (wn, Qnil));
+ tail = XCDR (tail);
+ }
+
+ w = NILP (w->next) ? 0 : XWINDOW (w->next);
+ }
+
+ return result;
+}
+
+
+
+DEFUN ("window-split-tree", Fwindow_split_tree, Swindow_split_tree,
+ 0, 1, 0,
+ doc: /* Return the window split tree for frame FRAME.
+
+The return value is a list of the form (ROOT MINI), where ROOT
+represents the window split tree of the frame's root window, and MINI
+is the frame's minibuffer window.
+
+If the root window is not split, ROOT is the root window itself.
+Otherwise, ROOT is a list (DIR EDGES W1 W2 ...) where DIR is nil for a
+horisontal split, and t for a vertical split, EDGES gives the combined
+size and position of the subwindows in the split, and the rest of the
+elements are the subwindows in the split. Each of the subwindows may
+again be a window or a list representing a window split, and so on.
+EDGES is a list \(LEFT TOP RIGHT BOTTOM) as returned by `window-edges'.
+
+If FRAME is nil or omitted, return information on the currently
+selected frame. */)
+ (frame)
+ Lisp_Object frame;
+{
+ Lisp_Object alist;
+ FRAME_PTR f;
+
+ if (NILP (frame))
+ frame = selected_frame;
+
+ CHECK_FRAME (frame);
+ f = XFRAME (frame);
+
+ if (!FRAME_LIVE_P (f))
+ return Qnil;
+
+ return window_split_tree (XWINDOW (FRAME_ROOT_WINDOW (f)));
+}
+
/***********************************************************************
Marginal Areas
@@ -7031,6 +7110,7 @@ The selected frame is the one whose configuration has changed. */);
defsubr (&Sset_window_configuration);
defsubr (&Scurrent_window_configuration);
defsubr (&Ssave_window_excursion);
+ defsubr (&Swindow_split_tree);
defsubr (&Sset_window_margins);
defsubr (&Swindow_margins);
defsubr (&Sset_window_fringes);
diff --git a/src/xdisp.c b/src/xdisp.c
index 27ab728502a..ef125409076 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12943,7 +12943,8 @@ try_window (window, pos, check_margins)
this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
if ((w->cursor.y < this_scroll_margin
- && CHARPOS (pos) > BEGV)
+ && CHARPOS (pos) > BEGV
+ && IT_CHARPOS (it) < ZV)
/* rms: considering make_cursor_line_fully_visible_p here
seems to give wrong results. We don't want to recenter
when the last line is partly visible, we want to allow
diff --git a/src/xfaces.c b/src/xfaces.c
index 34bee3298ba..df8dc15f022 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1475,7 +1475,9 @@ tty_color_name (f, idx)
/* Return non-zero if COLOR_NAME is a shade of gray (or white or
- black) on frame F. The algorithm is taken from 20.2 faces.el. */
+ black) on frame F.
+
+ The criterion implemented here is not a terribly sophisticated one. */
static int
face_color_gray_p (f, color_name)
@@ -1486,12 +1488,15 @@ face_color_gray_p (f, color_name)
int gray_p;
if (defined_color (f, color_name, &color, 0))
- gray_p = ((abs (color.red - color.green)
- < max (color.red, color.green) / 20)
- && (abs (color.green - color.blue)
- < max (color.green, color.blue) / 20)
- && (abs (color.blue - color.red)
- < max (color.blue, color.red) / 20));
+ gray_p = (/* Any color sufficiently close to black counts as grey. */
+ (color.red < 5000 && color.green < 5000 && color.blue < 5000)
+ ||
+ ((abs (color.red - color.green)
+ < max (color.red, color.green) / 20)
+ && (abs (color.green - color.blue)
+ < max (color.green, color.blue) / 20)
+ && (abs (color.blue - color.red)
+ < max (color.blue, color.red) / 20)));
else
gray_p = 0;
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 0215d562548..e7f3e6fa3e5 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -45,9 +45,9 @@ Boston, MA 02110-1301, USA. */
#include <sys/param.h>
#include <stdio.h>
+#include "lisp.h"
#include "systime.h"
#include "sysselect.h"
-#include "lisp.h"
#include "termhooks.h"
#include "termopts.h"
#include "xterm.h"
diff --git a/src/xterm.c b/src/xterm.c
index 3b94e3b871c..5b7d45fe228 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6237,7 +6237,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
if (status_return == XBufferOverflow)
{
copy_bufsiz = nbytes + 1;
- copy_bufptr = (char *) alloca (copy_bufsiz);
+ copy_bufptr = (unsigned char *) alloca (copy_bufsiz);
nbytes = XmbLookupString (FRAME_XIC (f),
&event.xkey, copy_bufptr,
copy_bufsiz, &keysym,
@@ -6255,7 +6255,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
if (status_return == XBufferOverflow)
{
copy_bufsiz = nbytes + 1;
- copy_bufptr = (char *) alloca (copy_bufsiz);
+ copy_bufptr = (unsigned char *) alloca (copy_bufsiz);
nbytes = Xutf8LookupString (FRAME_XIC (f),
&event.xkey,
copy_bufptr,