(translate_char): Accept list of translation tables.
[bpt/emacs.git] / src / dispextern.h
index a19e096..03eda50 100644 (file)
@@ -58,9 +58,38 @@ typedef struct x_display_info Display_Info;
 typedef struct w32_display_info Display_Info;
 #endif
 
-#ifdef MAC_OS
+#ifdef HAVE_CARBON
 #include "macgui.h"
 typedef struct mac_display_info Display_Info;
+
+/* Include Carbon.h to define Cursor and Rect.  */
+#undef mktime
+#undef DEBUG
+#undef Z
+#undef free
+#undef malloc
+#undef realloc
+/* Macros max and min defined in lisp.h conflict with those in
+   precompiled header Carbon.h.  */
+#undef max
+#undef min
+#undef init_process
+#include <Carbon/Carbon.h>
+#undef Z
+#define Z (current_buffer->text->z)
+#undef free
+#define free unexec_free
+#undef malloc
+#define malloc unexec_malloc
+#undef realloc
+#define realloc unexec_realloc
+#undef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#undef init_process
+#define init_process emacs_init_process
+
 #endif
 
 
@@ -521,12 +550,14 @@ struct glyph_matrix
   int matrix_w, matrix_h;
 
   /* If this structure describes a window matrix of window W,
-     window_left_x is the value of W->left, window_top_y the value of
-     W->top, window_height and window_width are width and height of W,
-     as returned by window_box, and window_vscroll is the value of
-     W->vscroll at the time the matrix was last adjusted.  Only set
-     for window-based redisplay.  */
-  int window_left_x, window_top_y, window_height, window_width, window_vscroll;
+     window_left_col is the value of W->left_col, window_top_line the
+     value of W->top_line, window_height and window_width are width and
+     height of W, as returned by window_box, and window_vscroll is the
+     value of W->vscroll at the time the matrix was last adjusted.
+     Only set for window-based redisplay.  */
+  int window_left_col, window_top_line;
+  int window_height, window_width;
+  int window_vscroll;
 
   /* Number of glyphs reserved for left and right marginal areas when
      the matrix was last adjusted.  */
@@ -837,13 +868,13 @@ struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int));
 
 #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P(W, ROW)          \
      (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                   \
-      && (ROW)->y < WINDOW_DISPLAY_HEADER_LINE_HEIGHT ((W)))
+      && (ROW)->y < WINDOW_HEADER_LINE_HEIGHT ((W)))
 
 /* Non-zero if ROW is partially visible at the bottom of window W.  */
 
 #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P(W, ROW)                     \
      (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                                 \
-      && (ROW)->y + (ROW)->height > WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE ((W)))
+      && (ROW)->y + (ROW)->height > WINDOW_BOX_HEIGHT_NO_MODE_LINE ((W)))
 
 /* Return the bottom Y + 1 of ROW.   */
 
@@ -1168,156 +1199,6 @@ struct glyph_string
 #define DESIRED_HEADER_LINE_HEIGHT(W) \
      MATRIX_HEADER_LINE_HEIGHT ((W)->desired_matrix)
 
-/* Like FRAME_INTERNAL_BORDER_WIDTH but checks whether frame F is a
-   window-system frame.  */
-
-#define FRAME_INTERNAL_BORDER_WIDTH_SAFE(F) \
-     (FRAME_WINDOW_P (F) ? FRAME_INTERNAL_BORDER_WIDTH (F) : 0)
-
-/* Width of display region of window W.  For terminal frames, this
-   equals the width of W since there are no vertical scroll bars.  For
-   window system frames, the value has to be corrected by the pixel
-   width of vertical scroll bars, and fringes.  */
-
-#define WINDOW_DISPLAY_PIXEL_WIDTH(W)                                  \
-     (((XFASTINT ((W)->width)                                          \
-        - FRAME_SCROLL_BAR_WIDTH (XFRAME (WINDOW_FRAME ((W))))         \
-       - FRAME_FRINGE_COLS (XFRAME (WINDOW_FRAME ((W)))))              \
-       * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
-
-/* Height of the display region of W, including a mode line, if any.  */
-
-#define WINDOW_DISPLAY_PIXEL_HEIGHT(W)                                 \
-     (XFASTINT ((W)->height)                                           \
-      * CANON_Y_UNIT (XFRAME (WINDOW_FRAME ((W)))))
-
-/* Height in pixels of the mode line.  May be zero if W doesn't have a
-   mode line.  */
-
-#define WINDOW_DISPLAY_MODE_LINE_HEIGHT(W)     \
-     (WINDOW_WANTS_MODELINE_P ((W))            \
-      ? CURRENT_MODE_LINE_HEIGHT (W)           \
-      : 0)
-
-/* Height in pixels of the header line.  Zero if W doesn't have a header
-   line.  */
-
-#define WINDOW_DISPLAY_HEADER_LINE_HEIGHT(W)   \
-     (WINDOW_WANTS_HEADER_LINE_P ((W))         \
-      ? CURRENT_HEADER_LINE_HEIGHT (W)         \
-      : 0)
-
-/* Pixel height of window W without mode line.  */
-
-#define WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE(W)  \
-     (WINDOW_DISPLAY_PIXEL_HEIGHT ((W))                \
-      - WINDOW_DISPLAY_MODE_LINE_HEIGHT ((W)))
-
-/* Pixel height of window W without mode and header line.  */
-
-#define WINDOW_DISPLAY_TEXT_HEIGHT(W)          \
-     (WINDOW_DISPLAY_PIXEL_HEIGHT ((W))                \
-      - WINDOW_DISPLAY_MODE_LINE_HEIGHT ((W))  \
-      - WINDOW_DISPLAY_HEADER_LINE_HEIGHT ((W)))
-
-/* Left edge of W in pixels relative to its frame.  */
-
-#define WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X(W)                            \
-     (FRAME_INTERNAL_BORDER_WIDTH_SAFE (XFRAME (WINDOW_FRAME ((W))))   \
-      + (WINDOW_LEFT_MARGIN ((W))                                      \
-         * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W)))))                 \
-      + FRAME_LEFT_FRINGE_WIDTH (XFRAME (WINDOW_FRAME ((W)))))
-
-/* Right edge of window W in pixels, relative to its frame.  */
-
-#define WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X(W)           \
-     (WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W))           \
-      + WINDOW_DISPLAY_PIXEL_WIDTH ((W)))
-
-/* Top edge of W in pixels relative to its frame.  */
-
-#define WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y(W)                             \
-     (FRAME_INTERNAL_BORDER_WIDTH_SAFE (XFRAME (WINDOW_FRAME ((W))))   \
-      + (XFASTINT ((W)->top)                                           \
-         * CANON_Y_UNIT (XFRAME (WINDOW_FRAME ((W))))))
-
-/* Bottom edge of window W relative to its frame.  */
-
-#define WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y(W)          \
-     (WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W))            \
-      + WINDOW_DISPLAY_PIXEL_HEIGHT ((W)))
-
-/* Convert window W relative pixel X to frame pixel coordinates.  */
-
-#define WINDOW_TO_FRAME_PIXEL_X(W, X) \
-     ((X) + WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W)))
-
-/* Convert window W relative pixel Y to frame pixel coordinates.  */
-
-#define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
-     ((Y) + WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W)))
-
-/* Convert frame relative pixel X to window relative pixel X.  */
-
-#define FRAME_TO_WINDOW_PIXEL_X(W, X) \
-     ((X) - WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W)))
-
-/* Convert frame relative pixel Y to window relative pixel Y.  */
-
-#define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
-     ((Y) - WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W)))
-
-/* Width of left margin area in pixels.  */
-
-#define WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH(W)                \
-     (NILP ((W)->left_margin_width)                    \
-      ? 0                                              \
-      : (XINT ((W)->left_margin_width)                 \
-        * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
-
-/* Width of right marginal area in pixels.  */
-
-#define WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH(W)       \
-     (NILP ((W)->right_margin_width)                   \
-      ? 0                                              \
-      : (XINT ((W)->right_margin_width)                        \
-        * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
-
-/* Width of text area in pixels.  */
-
-#define WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH(W)                \
-     (WINDOW_DISPLAY_PIXEL_WIDTH ((W))                 \
-      - WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))     \
-      - WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH ((W)))
-
-/* Convert a text area relative x-position in window W to frame X
-   pixel coordinates.  */
-
-#define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)             \
-     (WINDOW_TO_FRAME_PIXEL_X ((W), (X))               \
-      + WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W)))
-
-/* Translate an x-position relative to AREA in window W to frame pixel
-   coordinates.  */
-
-#define WINDOW_AREA_TO_FRAME_PIXEL_X(W, AREA, X)       \
-     (WINDOW_TO_FRAME_PIXEL_X ((W), (X))               \
-      + (((AREA) > LEFT_MARGIN_AREA)                   \
-        ? WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))   \
-        : 0)                                           \
-      + (((AREA) > TEXT_AREA)                          \
-        ? WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH ((W))   \
-        : 0))
-
-/* Return the pixel width of AREA in W.  */
-
-#define WINDOW_AREA_PIXEL_WIDTH(W, AREA)               \
-     (((AREA) == TEXT_AREA)                            \
-      ? WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH ((W))     \
-      : (((AREA) == LEFT_MARGIN_AREA)                  \
-        ? WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))   \
-        : WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH ((W))))
-
 /* Value is non-zero if window W wants a mode line.  */
 
 #define WINDOW_WANTS_MODELINE_P(W)                                     \
@@ -1326,7 +1207,7 @@ struct glyph_string
       && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))          \
       && BUFFERP ((W)->buffer)                                         \
       && !NILP (XBUFFER ((W)->buffer)->mode_line_format)               \
-      && XFASTINT ((W)->height) > 1)
+      && WINDOW_TOTAL_LINES (W) > 1)
 
 /* Value is non-zero if window W wants a header line.  */
 
@@ -1336,7 +1217,7 @@ struct glyph_string
       && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))          \
       && BUFFERP ((W)->buffer)                                         \
       && !NILP (XBUFFER ((W)->buffer)->header_line_format)             \
-      && XFASTINT ((W)->height) > 1 + !NILP (XBUFFER ((W)->buffer)->mode_line_format))
+      && WINDOW_TOTAL_LINES (W) > 1 + !NILP (XBUFFER ((W)->buffer)->mode_line_format))
 
 
 /* Return proper value to be used as baseline offset of font that has
@@ -1362,7 +1243,7 @@ struct glyph_string
        BOFF = DESCENT +  (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
        DESCENT = FONT->descent
        HEIGHT = FONT_HEIGHT (FONT)
-       F_DESCENT = (F->output_data.x->font->descent
+       F_DESCENT = (FRAME_FONT (F)->descent
                     - F->output_data.x->baseline_offset)
        F_HEIGHT = FRAME_LINE_HEIGHT (F)
 */
@@ -1399,6 +1280,7 @@ enum lface_attribute_index
   LFACE_FONT_INDEX,
   LFACE_INHERIT_INDEX,
   LFACE_AVGWIDTH_INDEX,
+  LFACE_FONTSET_INDEX,
   LFACE_VECTOR_SIZE
 };
 
@@ -1483,10 +1365,8 @@ struct face
      reallocated.  */
   int font_info_id;
 
-  /* Fontset ID if this face uses a fontset, or -1.  This is only >= 0
-     if the face was realized for a composition sequence.
-     Otherwise, a specific font is loaded from the set of fonts
-     specified by the fontset given by the family attribute of the face.  */
+  /* Fontset ID if for this face's fontset.  Non-ASCII faces derived
+     from the same ASCII face have the same fontset.  */
   int fontset;
 
   /* Pixmap width and height.  */
@@ -1518,13 +1398,6 @@ struct face
   /* The hash value of this face.  */
   unsigned hash;
 
-  /* The charset for which this face was realized if it was realized
-     for use in multibyte text.  If fontset >= 0, this is the charset
-     of the first character of the composition sequence.  A value of
-     charset < 0 means the face was realized for use in unibyte text
-     where the idea of Emacs charsets isn't applicable.  */
-  int charset;
-
   /* Non-zero if text in this face should be underlined, overlined,
      strike-through or have a box drawn around it.  */
   unsigned underline_p : 1;
@@ -1570,8 +1443,9 @@ struct face
   /* Next and previous face in hash collision list of face cache.  */
   struct face *next, *prev;
 
-  /* If this face is for ASCII characters, this points this face
-     itself.  Otherwise, this points a face for ASCII characters.  */
+  /* If this face is an ASCII face, this points to this face itself.
+     Otherwise, this points to an ASCII face that has the same
+     attributes except the font.  */
   struct face *ascii_face;
 };
 
@@ -1658,7 +1532,7 @@ struct face_cache
 /* Non-zero if FACE is suitable for displaying character CHAR.  */
 
 #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR)   \
-  (SINGLE_BYTE_CHAR_P (CHAR)                   \
+  (ASCII_CHAR_P (CHAR)                         \
    ? (FACE) == (FACE)->ascii_face              \
    : face_suitable_for_char_p ((FACE), (CHAR)))
 
@@ -1666,15 +1540,15 @@ struct face_cache
    with id ID but is suitable for displaying character CHAR.
    This macro is only meaningful for multibyte character CHAR.  */
 
-#define FACE_FOR_CHAR(F, FACE, CHAR)   \
-  (SINGLE_BYTE_CHAR_P (CHAR)           \
-   ? (FACE)->ascii_face->id            \
-   : face_for_char ((F), (FACE), (CHAR)))
+#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT)      \
+  (ASCII_CHAR_P (CHAR)                                 \
+   ? (FACE)->ascii_face->id                            \
+   : face_for_char ((F), (FACE), (CHAR), (POS), (OBJECT)))
 
 #else /* not HAVE_WINDOW_SYSTEM */
 
 #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR) 1
-#define FACE_FOR_CHAR(F, FACE, CHAR) ((FACE)->id)
+#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) ((FACE)->id)
 
 #endif /* not HAVE_WINDOW_SYSTEM */
 
@@ -1809,6 +1683,7 @@ enum display_element_type
 
 enum prop_idx
 {
+  AUTO_COMPOSED_PROP_IDX,
   FONTIFIED_PROP_IDX,
   FACE_PROP_IDX,
   INVISIBLE_PROP_IDX,
@@ -2036,7 +1911,7 @@ struct it
   short truncation_pixel_width, continuation_pixel_width;
 
   /* First and last visible x-position in the display area.  If window
-     is hscrolled by n columns, first_visible_x == n * CANON_X_UNIT
+     is hscrolled by n columns, first_visible_x == n * FRAME_COLUMN_WIDTH
      (f), and last_visible_x == pixel width of W + first_visible_x.  */
   int first_visible_x, last_visible_x;
 
@@ -2166,11 +2041,19 @@ struct run
 };
 
 
+/* Handlers for setting frame parameters.  */
+
+typedef void (*frame_parm_handler) P_ ((struct frame *, Lisp_Object, Lisp_Object));
+
+
 /* Structure holding system-dependent interface functions needed
    for window-based redisplay.  */
 
 struct redisplay_interface
 {
+  /* Handlers for setting frame parameters.  */
+  frame_parm_handler *frame_parm_handlers;
+
   /* Produce glyphs/get display metrics for the display element IT is
      loaded with.  */
   void (*produce_glyphs) P_ ((struct it *it));
@@ -2247,7 +2130,9 @@ struct redisplay_interface
    the two-byte form of C.  Encoding is returned in *CHAR2B.  If
    TWO_BYTE_P is non-null, return non-zero there if font is two-byte.  */
   int (*encode_char) P_ ((int c, XChar2b *char2b,
-                         struct font_info *font_into, int *two_byte_p));
+                         struct font_info *font_into,
+                         struct charset *charset,
+                         int *two_byte_p));
 
 /* Compute left and right overhang of glyph string S.  
    A NULL pointer if platform does not support this. */
@@ -2677,15 +2562,17 @@ void clear_face_cache P_ ((int));
 unsigned long load_color P_ ((struct frame *, struct face *, Lisp_Object,
                              enum lface_attribute_index));
 void unload_color P_ ((struct frame *, unsigned long));
-int frame_update_line_height P_ ((struct frame *));
+char *choose_face_font P_ ((struct frame *, Lisp_Object *, Lisp_Object,
+                           int *));
 int ascii_face_of_lisp_face P_ ((struct frame *, int));
 void prepare_face_for_display P_ ((struct frame *, struct face *));
 int xstricmp P_ ((const unsigned char *, const unsigned char *));
-int lookup_face P_ ((struct frame *, Lisp_Object *, int, struct face *));
-int lookup_named_face P_ ((struct frame *, Lisp_Object, int));
+int lookup_face P_ ((struct frame *, Lisp_Object *));
+int lookup_non_ascii_face P_ ((struct frame *, int, struct face *));
+int lookup_named_face P_ ((struct frame *, Lisp_Object));
 int smaller_face P_ ((struct frame *, int, int));
 int face_with_height P_ ((struct frame *, int, int));
-int lookup_derived_face P_ ((struct frame *, Lisp_Object, int, int));
+int lookup_derived_face P_ ((struct frame *, Lisp_Object, int));
 void init_frame_faces P_ ((struct frame *));
 void free_frame_faces P_ ((struct frame *));
 void recompute_basic_faces P_ ((struct frame *));
@@ -2695,9 +2582,11 @@ int face_at_string_position P_ ((struct window *, Lisp_Object, int, int, int,
                                 int, int *, enum face_id, int));
 int compute_char_face P_ ((struct frame *, int, Lisp_Object));
 void free_all_realized_faces P_ ((Lisp_Object));
+void free_realized_face P_ ((struct frame *, struct face *));
 extern Lisp_Object Qforeground_color, Qbackground_color;
 extern char unspecified_fg[], unspecified_bg[];
-void free_realized_multibyte_face P_ ((struct frame *, int));
+extern Lisp_Object split_font_name_into_vector P_ ((Lisp_Object));
+extern Lisp_Object build_font_name_from_vector P_ ((Lisp_Object));
 
 /* Defined in xfns.c  */
 
@@ -2858,4 +2747,35 @@ extern void do_line_insertion_deletion_costs P_ ((struct frame *, char *,
 void scrolling_1 P_ ((struct frame *, int, int, int, int *, int *, int *,
                      int *, int));
 
+/* Defined in frame.c */
+
+#ifdef HAVE_WINDOW_SYSTEM
+
+/* Types we might convert a resource string into.  */
+enum resource_types
+{
+  RES_TYPE_NUMBER,
+  RES_TYPE_FLOAT,
+  RES_TYPE_BOOLEAN,
+  RES_TYPE_STRING,
+  RES_TYPE_SYMBOL
+};
+
+extern Lisp_Object x_get_arg P_ ((Display_Info *, Lisp_Object,
+                                 Lisp_Object, char *, char *class,
+                                 enum resource_types));
+extern Lisp_Object x_frame_get_arg P_ ((struct frame *, Lisp_Object,
+                                       Lisp_Object, char *, char *,
+                                       enum resource_types));
+extern Lisp_Object x_frame_get_and_record_arg P_ ((
+                                       struct frame *, Lisp_Object,
+                                       Lisp_Object, char *, char *,
+                                       enum resource_types));
+extern Lisp_Object x_default_parameter P_ ((struct frame *, Lisp_Object,
+                                           Lisp_Object, Lisp_Object,
+                                           char *, char *,
+                                           enum resource_types));
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
 #endif /* not DISPEXTERN_H_INCLUDED */