Pay attention to buffer relocation on encoding (Bug#9318; backport from trunk).
[bpt/emacs.git] / src / dispextern.h
index 041d54f..682e1ae 100644 (file)
@@ -1,6 +1,6 @@
 /* Interface definitions for display code.
    Copyright (C) 1985, 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
-                 2003, 2004, 2005, 2006, 2007, 2008
+                 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -61,10 +61,10 @@ typedef XImage *XImagePtr;
 typedef HDC XImagePtr_or_DC;
 #endif
 
-#ifdef MAC_OS
-#include "macgui.h"
-typedef struct mac_display_info Display_Info;
-/* Mac equivalent of XImage.  */
+#ifdef HAVE_NS
+#include "nsgui.h"
+/* Following typedef needed to accommodate the MSDOS port, believe it or not.  */
+typedef struct ns_display_info Display_Info;
 typedef Pixmap XImagePtr;
 typedef XImagePtr XImagePtr_or_DC;
 #endif
@@ -105,6 +105,8 @@ enum window_part
 /* Number of bits allocated to store fringe bitmap numbers.  */
 #define FRINGE_ID_BITS  16
 
+/* Number of bits allocated to store fringe bitmap height.  */
+#define FRINGE_HEIGHT_BITS 8
 
 \f
 /***********************************************************************
@@ -173,10 +175,10 @@ extern int trace_redisplay_p;
 struct text_pos
 {
   /* Character position.  */
-  int charpos;
+  EMACS_INT charpos;
 
   /* Corresponding byte position.  */
-  int bytepos;
+  EMACS_INT bytepos;
 };
 
 /* Access character and byte position of POS in a functional form.  */
@@ -274,7 +276,7 @@ enum glyph_type
   /* Glyph describes a character.  */
   CHAR_GLYPH,
 
-  /* Glyph describes a composition sequence.  */
+  /* Glyph describes a static composition.  */
   COMPOSITE_GLYPH,
 
   /* Glyph describes an image.  */
@@ -311,7 +313,7 @@ struct glyph
      buffer, this is a position in that buffer.  A value of -1
      together with a null object means glyph is a truncation glyph at
      the start of a row.  */
-  int charpos;
+  EMACS_INT charpos;
 
   /* Lisp object source of this glyph.  Currently either a buffer or
      a string, if the glyph was produced from characters which came from
@@ -366,7 +368,7 @@ struct glyph
      doesn't have a glyph in a font.  */
   unsigned glyph_not_available_p : 1;
 
+
   /* Non-zero means don't display cursor here.  */
   unsigned avoid_cursor_p : 1;
 
@@ -390,8 +392,17 @@ struct glyph
     /* Character code for character glyphs (type == CHAR_GLYPH).  */
     unsigned ch;
 
-    /* Composition ID for composition glyphs (type == COMPOSITION_GLYPH)  */
-    unsigned cmp_id;
+    /* Sub-structures for type == COMPOSITION_GLYPH.  */
+    struct
+    {
+      /* Flag to tell if the composition is automatic or not.  */
+      unsigned automatic : 1;
+      /* ID of the composition.  */
+      unsigned id    : 23;
+      /* Start and end indices of glyphs of the composition.  */
+      unsigned from : 4;
+      unsigned to : 4;
+    } cmp;
 
     /* Image ID for image glyphs (type == IMAGE_GLYPH).  */
     unsigned img_id;
@@ -769,6 +780,16 @@ struct glyph_row
   /* Face of the right fringe glyph.  */
   unsigned right_fringe_face_id : FACE_ID_BITS;
 
+  /* Vertical offset of the left fringe bitmap.  */
+  signed left_fringe_offset : FRINGE_HEIGHT_BITS;
+
+  /* Vertical offset of the right fringe bitmap.  */
+  signed right_fringe_offset : FRINGE_HEIGHT_BITS;
+
+  /* 1 means that at least one of the left and right fringe bitmaps is
+     periodic and thus depends on the y-position of the row.  */
+  unsigned fringe_bitmap_periodic_p : 1;
+
   /* 1 means that we must draw the bitmaps of this row.  */
   unsigned redraw_fringe_bitmaps_p : 1;
 
@@ -1165,14 +1186,15 @@ struct glyph_string
   /* Font in which this string is to be drawn.  */
   struct font *font;
 
-  /* Non-null means this string describes (part of) a composition.
-     All characters from char2b are drawn composed.  */
+  /* Non-null means this string describes (part of) a static
+     composition.  */
   struct composition *cmp;
 
-  /* Index of this glyph string's first character in the glyph
-     definition of CMP.  If this is zero, this glyph string describes
-     the first character of a composition.  */
-  int gidx;
+  /* If not negative, this string describes a compos.  */
+  int cmp_id;
+
+  /* Start and end glyph indices in a glyph-string.  */
+  int cmp_from, cmp_to;
 
   /* 1 means this glyph strings face has to be drawn to the right end
      of the window's drawing area.  */
@@ -1212,7 +1234,7 @@ struct glyph_string
   unsigned padding_p : 1;
 
   /* The GC to use for drawing this glyph string.  */
-#if defined(HAVE_X_WINDOWS) || defined(MAC_OS)
+#if defined(HAVE_X_WINDOWS)
   GC gc;
 #endif
 #if defined(HAVE_NTGUI)
@@ -1514,13 +1536,6 @@ struct face
      drawing shadows.  */
   unsigned use_box_color_for_shadows_p : 1;
 
-  /* The Lisp face attributes this face realizes.  All attributes
-     in this vector are non-nil.  */
-  Lisp_Object lface[LFACE_VECTOR_SIZE];
-
-  /* The hash value of this face.  */
-  unsigned hash;
-
   /* Non-zero if text in this face should be underlined, overlined,
      strike-through or have a box drawn around it.  */
   unsigned underline_p : 1;
@@ -1563,6 +1578,20 @@ struct face
   /* If non-zero, use overstrike (to simulate bold-face).  */
   unsigned overstrike : 1;
 
+/* NOTE: this is not used yet, but eventually this impl should be done
+         similarly to overstrike */
+#ifdef HAVE_NS
+  /* If non-zero, use geometric rotation (to simulate italic).  */
+  unsigned synth_ital : 1;
+#endif
+
+  /* The Lisp face attributes this face realizes.  All attributes
+     in this vector are non-nil.  */
+  Lisp_Object lface[LFACE_VECTOR_SIZE];
+
+  /* The hash value of this face.  */
+  unsigned hash;
+
   /* Next and previous face in hash collision list of face cache.  */
   struct face *next, *prev;
 
@@ -1669,7 +1698,7 @@ struct face_cache
    This macro is only meaningful for multibyte character CHAR.  */
 
 #define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT)      \
-  (ASCII_CHAR_P (CHAR)                                 \
+  ((ASCII_CHAR_P (CHAR) || CHAR_BYTE8_P (CHAR))                \
    ? (FACE)->ascii_face->id                            \
    : face_for_char ((F), (FACE), (CHAR), (POS), (OBJECT)))
 
@@ -1767,7 +1796,7 @@ enum display_element_type
   /* A normal character.  */
   IT_CHARACTER,
 
-  /* A composition sequence.  */
+  /* A composition (static and automatic).  */
   IT_COMPOSITION,
 
   /* An image.  */
@@ -1794,7 +1823,6 @@ enum display_element_type
 
 enum prop_idx
 {
-  AUTO_COMPOSED_PROP_IDX,
   FONTIFIED_PROP_IDX,
   FACE_PROP_IDX,
   INVISIBLE_PROP_IDX,
@@ -1831,7 +1859,6 @@ struct it_slice
 enum it_method {
   GET_FROM_BUFFER = 0,
   GET_FROM_DISPLAY_VECTOR,
-  GET_FROM_COMPOSITION,
   GET_FROM_STRING,
   GET_FROM_C_STRING,
   GET_FROM_IMAGE,
@@ -1841,6 +1868,36 @@ enum it_method {
 
 #define IT_STACK_SIZE 4
 
+/* Iterator for composition (both for static and automatic).  */
+struct composition_it
+{
+  /* Next position at which to check the composition.  */
+  EMACS_INT stop_pos;
+  /* ID number of the composition or glyph-string.  If negative, we
+     are not iterating over a composition now.  */
+  int id;
+  /* If non-negative, character that triggers the automatic
+     composition at `stop_pos', and this is an automatic composition.
+     If negative, this is a static composition.  This is set to -2
+     temporarily if searching of composition reach a limit or a
+     newline.  */
+  int ch;
+  /* If this an automatic composition, how many characters to look back
+     from the position where a character triggering the composition
+     exists.  */
+  int lookback;
+  /* If non-negative, number of glyphs of the glyph-string.  */
+  int nglyphs;
+  /* Number of characters and bytes of the current grapheme cluster.  */
+  int nchars, nbytes;
+  /* Indices of the glyphs for the current grapheme cluster.  */
+  int from, to;
+  /* Width of the current grapheme cluster in units of pixels on a
+     graphic display and in units of canonical characters on a
+     terminal display.  */
+  int width;
+};
+
 struct it
 {
   /* The window in which we iterate over current_buffer (or a string).  */
@@ -1855,11 +1912,11 @@ struct it
 
   /* The next position at which to check for face changes, invisible
      text, overlay strings, end of text etc., which see.  */
-  int stop_charpos;
+  EMACS_INT stop_charpos;
 
   /* Maximum string or buffer position + 1.  ZV when iterating over
      current_buffer.  */
-  int end_charpos;
+  EMACS_INT end_charpos;
 
   /* C string to iterate over.  Non-null means get characters from
      this string, otherwise characters are read from current_buffer
@@ -1872,10 +1929,10 @@ struct it
 
   /* Start and end of a visible region; -1 if the region is not
      visible in the window.  */
-  int region_beg_charpos, region_end_charpos;
+  EMACS_INT region_beg_charpos, region_end_charpos;
 
   /* Position at which redisplay end trigger functions should be run.  */
-  int redisplay_end_trigger_charpos;
+  EMACS_INT redisplay_end_trigger_charpos;
 
   /* 1 means multibyte characters are enabled.  */
   unsigned multibyte_p : 1;
@@ -1936,6 +1993,12 @@ struct it
      OVERLAY_STRING_CHUNK_SIZE.  */
   int n_overlay_strings;
 
+  /* The charpos where n_overlay_strings was calculated.  This should
+     be set at the same time as n_overlay_strings.  It is needed
+     because we show before-strings at the start of invisible text;
+     see handle_invisible_prop in xdisp.c.  */
+  int overlay_strings_charpos;
+
   /* Vector of overlays to process.  Overlay strings are processed
      OVERLAY_STRING_CHUNK_SIZE at a time.  */
 #define OVERLAY_STRING_CHUNK_SIZE 16
@@ -1961,8 +2024,9 @@ struct it
   {
     Lisp_Object string;
     int string_nchars;
-    int end_charpos;
-    int stop_charpos;
+    EMACS_INT end_charpos;
+    EMACS_INT stop_charpos;
+    struct composition_it cmp_it;
     int face_id;
 
     /* Save values specific to a given method.  */
@@ -1976,8 +2040,6 @@ struct it
       /* method == GET_FROM_COMPOSITION */
       struct {
        Lisp_Object object;
-       int c, len;
-       int cmp_id, cmp_len;
       } comp;
       /* method == GET_FROM_STRETCH */
       struct {
@@ -1995,11 +2057,12 @@ struct it
     unsigned string_from_display_prop_p : 1;
     unsigned display_ellipsis_p : 1;
     unsigned avoid_cursor_p : 1;
+    enum line_wrap_method line_wrap;
 
     /* properties from display property that are reset by another display property. */
+    short voffset;
     Lisp_Object space_width;
     Lisp_Object font_height;
-    short voffset;
   }
   stack[IT_STACK_SIZE];
 
@@ -2024,8 +2087,6 @@ struct it
      where the `^' can be replaced by a display table entry.  */
   unsigned ctl_arrow_p : 1;
 
-  enum line_wrap_method line_wrap;
-
   /* Non-zero means that the current face has a box.  */
   unsigned face_box_p : 1;
 
@@ -2061,6 +2122,8 @@ struct it
      descent/ascent (line-height property).  Reset after this glyph.  */
   unsigned constrain_row_ascent_descent_p : 1;
 
+  enum line_wrap_method line_wrap;
+
   /* The ID of the default face to use.  One of DEFAULT_FACE_ID,
      MODE_LINE_FACE_ID, etc, depending on what we are displaying.  */
   int base_face_id;
@@ -2074,13 +2137,15 @@ struct it
      and length in bytes of the composition.  */
   int c, len;
 
-  /* If what == IT_COMPOSITION, identification number and length in
-     chars of a composition.  */
-  int cmp_id, cmp_len;
+  /* If what == IT_COMPOSITION, iterator substructure for the
+     composition.  */
+  struct composition_it cmp_it;
 
-  /* The character to display, possibly translated to multibyte
-     if unibyte_display_via_language_environment is set.  This
-     is set after produce_glyphs has been called.  */
+  /* The character to display, possibly translated to multibyte if
+     multibyte_p is zero or unibyte_display_via_language_environment
+     is set.  This is set after get_next_display_element has been
+     called.  If we are setting it->C directly before calling
+     PRODUCE_GLYPHS, this should be set beforehand too.  */
   int char_to_display;
 
   /* If what == IT_IMAGE, the id of the image to display.  */
@@ -2095,6 +2160,9 @@ struct it
   /* Computed from the value of the `raise' property.  */
   short voffset;
 
+  /* Number of columns per \t.  */
+  short tab_width;
+
   /* Value of the `height' property, if any; nil if none.  */
   Lisp_Object font_height;
 
@@ -2105,9 +2173,6 @@ struct it
   Lisp_Object object;
   struct text_pos position;
 
-  /* Number of columns per \t.  */
-  short tab_width;
-
   /* Width in pixels of truncation and continuation glyphs.  */
   short truncation_pixel_width, continuation_pixel_width;
 
@@ -2212,8 +2277,8 @@ struct it
       && ((IT)->c == '\n'                              \
          || ((IT)->c == '\r' && (IT)->selective)))
 
-/* Call produce_glyphs or produce_glyphs_hook, if set.  Shortcut to
-   avoid the function call overhead.  */
+/* Call produce_glyphs or FRAME_RIF->produce_glyphs, if set.  Shortcut
+   to avoid the function call overhead.  */
 
 #define PRODUCE_GLYPHS(IT)                              \
   do {                                                  \
@@ -2786,6 +2851,10 @@ extern int x_intersect_rectangles P_ ((XRectangle *, XRectangle *,
                                       XRectangle *));
 #endif
 
+/* Flags passed to try_window.  */
+#define TRY_WINDOW_CHECK_MARGINS       (1 << 0)
+#define TRY_WINDOW_IGNORE_FONTS_CHANGE (1 << 1)
+
 /* Defined in fringe.c */
 
 int lookup_fringe_bitmap (Lisp_Object);
@@ -2799,10 +2868,6 @@ void compute_fringe_widths P_ ((struct frame *, int));
 void w32_init_fringe P_ ((struct redisplay_interface *));
 void w32_reset_fringes P_ ((void));
 #endif
-#ifdef MAC_OS
-void mac_init_fringe P_ ((struct redisplay_interface *));
-#endif
-
 /* Defined in image.c */
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -2881,7 +2946,7 @@ void recompute_basic_faces P_ ((struct frame *));
 int face_at_buffer_position P_ ((struct window *w, EMACS_INT pos,
                                 EMACS_INT region_beg, EMACS_INT region_end,
                                 EMACS_INT *endptr, EMACS_INT limit,
-                                int mouse));
+                                int mouse, int base_face_id));
 int face_for_overlay_string P_ ((struct window *w, EMACS_INT pos,
                                 EMACS_INT region_beg, EMACS_INT region_end,
                                 EMACS_INT *endptr, EMACS_INT limit,
@@ -2908,9 +2973,6 @@ void gamma_correct P_ ((struct frame *, XColor *));
 #ifdef WINDOWSNT
 void gamma_correct P_ ((struct frame *, COLORREF *));
 #endif
-#ifdef MAC_OS
-void gamma_correct P_ ((struct frame *, unsigned long *));
-#endif
 
 #ifdef HAVE_WINDOW_SYSTEM
 
@@ -2925,6 +2987,15 @@ extern void start_hourglass P_ ((void));
 extern void cancel_hourglass P_ ((void));
 extern int hourglass_started P_ ((void));
 extern int display_hourglass_p;
+extern int hourglass_shown_p;
+struct atimer;                 /* Defined in atimer.h.  */
+/* If non-null, an asynchronous timer that, when it expires, displays
+   an hourglass cursor on all frames.  */
+extern struct atimer *hourglass_atimer;
+
+/* Each GUI implements these.  FIXME: move into RIF. */
+extern void show_hourglass P_ ((struct atimer *));
+extern void hide_hourglass P_ ((void));
 
 /* Returns the background color of IMG, calculating one heuristically if
    necessary.  If non-zero, XIMG is an existing XImage object to use for
@@ -3075,7 +3146,8 @@ enum resource_types
   RES_TYPE_FLOAT,
   RES_TYPE_BOOLEAN,
   RES_TYPE_STRING,
-  RES_TYPE_SYMBOL
+  RES_TYPE_SYMBOL,
+  RES_TYPE_BOOLEAN_NUMBER
 };
 
 extern Lisp_Object x_get_arg P_ ((Display_Info *, Lisp_Object,