merging Emacs.app (NeXTstep port)
[bpt/emacs.git] / src / dispextern.h
index 086d2bf..180820d 100644 (file)
@@ -1,13 +1,14 @@
 /* Interface definitions for display code.
    Copyright (C) 1985, 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
-                 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+                 2003, 2004, 2005, 2006, 2007, 2008
+                 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* New redisplay written by Gerd Moellmann <gerd@gnu.org>.  */
 
@@ -70,6 +69,14 @@ typedef Pixmap XImagePtr;
 typedef XImagePtr XImagePtr_or_DC;
 #endif
 
+#ifdef HAVE_NS
+#include "nsgui.h"
+/* following typedef needed to accomodate the MSDOS port, believe it or not */
+typedef struct ns_display_info Display_Info;
+typedef Pixmap XImagePtr;
+typedef XImagePtr XImagePtr_or_DC;
+#endif
+
 #ifndef NativeRectangle
 #define NativeRectangle int
 #endif
@@ -350,13 +357,16 @@ struct glyph
      glyphs above or below it.  */
   unsigned overlaps_vertically_p : 1;
 
-  /* 1 means glyph is a padding glyph.  Padding glyphs are used for
-     characters whose visual shape consists of more than one glyph
-     (e.g. Asian characters).  All but the first glyph of such a glyph
-     sequence have the padding_p flag set.  Only used for terminal
-     frames, and there only to minimize code changes.  A better way
-     would probably be to use the width field of glyphs to express
-     padding. */
+  /* For terminal frames, 1 means glyph is a padding glyph.  Padding
+     glyphs are used for characters whose visual shape consists of
+     more than one glyph (e.g. Asian characters).  All but the first
+     glyph of such a glyph sequence have the padding_p flag set.  This
+     flag is used only to minimize code changes.  A better way would
+     probably be to use the width field of glyphs to express padding.
+
+     For graphic frames, 1 means the pixel width of the glyph in a
+     font is 0, but 1-pixel is padded on displaying for correct cursor
+     displaying.  The member `pixel_width' above is set to 1.  */
   unsigned padding_p : 1;
 
   /* 1 means the actual glyph is not available, draw a box instead.
@@ -364,7 +374,11 @@ struct glyph
      doesn't have a glyph in a font.  */
   unsigned glyph_not_available_p : 1;
 
-#define FACE_ID_BITS   21
+  /* Non-zero means don't display cursor here.  */
+  unsigned avoid_cursor_p : 1;
+
+#define FACE_ID_BITS   20
 
   /* Face of the glyph.  This is a realized face ID,
      an index in the face cache of the frame.  */
@@ -414,7 +428,7 @@ struct glyph
 /* Is GLYPH a space?  */
 
 #define CHAR_GLYPH_SPACE_P(GLYPH) \
-     (GLYPH_FROM_CHAR_GLYPH ((GLYPH)) == SPACEGLYPH)
+  ((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID)
 
 /* Are glyph slices of glyphs *X and *Y equal */
 
@@ -461,18 +475,25 @@ struct glyph
 
 #define SET_CHAR_GLYPH_FROM_GLYPH(GLYPH, FROM)                 \
      SET_CHAR_GLYPH ((GLYPH),                                  \
-                    FAST_GLYPH_CHAR ((FROM)),                  \
-                    FAST_GLYPH_FACE ((FROM)),                  \
+                    GLYPH_CHAR ((FROM)),                       \
+                    GLYPH_FACE ((FROM)),                       \
                     0)
 
 /* Construct a glyph code from a character glyph GLYPH.  If the
    character is multibyte, return -1 as we can't use glyph table for a
    multibyte character.  */
 
-#define GLYPH_FROM_CHAR_GLYPH(GLYPH)                           \
-  ((GLYPH).u.ch < 256                                          \
-   ? ((GLYPH).u.ch | ((GLYPH).face_id << CHARACTERBITS))       \
-   : -1)
+#define SET_GLYPH_FROM_CHAR_GLYPH(G, GLYPH)                    \
+  do                                                           \
+    {                                                          \
+      if ((GLYPH).u.ch < 256)                                  \
+       SET_GLYPH ((G), (GLYPH).u.ch, ((GLYPH).face_id));       \
+      else                                                     \
+       SET_GLYPH ((G), -1, 0);                                 \
+    }                                                          \
+  while (0)
+
+#define GLYPH_INVALID_P(GLYPH) (GLYPH_CHAR (GLYPH) < 0)
 
 /* Is GLYPH a padding glyph?  */
 
@@ -1150,10 +1171,7 @@ struct glyph_string
   struct face *face;
 
   /* Font in which this string is to be drawn.  */
-  XFontStruct *font;
-
-  /* Font info for this string.  */
-  struct font_info *font_info;
+  struct font *font;
 
   /* Non-null means this string describes (part of) a composition.
      All characters from char2b are drawn composed.  */
@@ -1196,6 +1214,11 @@ struct glyph_string
      respectively.  */
   unsigned for_overlaps : 3;
 
+  /* 1 means that all glyphs in this glyph string has the flag
+     padding_p set, and thus must be drawn one by one to have 1-pixel
+     width even though the logical width in the font is zero.  */
+  unsigned padding_p : 1;
+
   /* The GC to use for drawing this glyph string.  */
 #if defined(HAVE_X_WINDOWS) || defined(MAC_OS)
   GC gc;
@@ -1221,13 +1244,15 @@ struct glyph_string
      *clip_tail, not including their overhangs.  */
   struct glyph_string *clip_head, *clip_tail;
 
-#ifdef USE_FONT_BACKEND
   /* The current clipping areas.  */
   NativeRectangle clip[2];
 
   /* Number of clipping areas. */
   int num_clips;
-#endif /* USE_FONT_BACKEND */
+
+  int underline_position;
+
+  int underline_thickness;
 
   struct glyph_string *next, *prev;
 };
@@ -1385,6 +1410,7 @@ struct glyph_string
 enum lface_attribute_index
 {
   LFACE_FAMILY_INDEX = 1,
+  LFACE_FOUNDRY_INDEX,
   LFACE_SWIDTH_INDEX,
   LFACE_HEIGHT_INDEX,
   LFACE_WEIGHT_INDEX,
@@ -1399,7 +1425,6 @@ enum lface_attribute_index
   LFACE_BOX_INDEX,
   LFACE_FONT_INDEX,
   LFACE_INHERIT_INDEX,
-  LFACE_AVGWIDTH_INDEX,
   LFACE_FONTSET_INDEX,
   LFACE_VECTOR_SIZE
 };
@@ -1442,12 +1467,6 @@ struct face
      drawing the characters in this face.  */
   GC gc;
 
-  /* Font used for this face, or null if the font could not be loaded
-     for some reason.  This points to a `font' slot of a struct
-     font_info, and we should not call XFreeFont on it because the
-     font may still be used somewhere else.  */
-  XFontStruct *font;
-
   /* Background stipple or bitmap used for this face.  This is
      an id as returned from load_pixmap.  */
   int stipple;
@@ -1475,19 +1494,7 @@ struct face
   unsigned long strike_through_color;
   unsigned long box_color;
 
-  /* The font's name.  This points to a `name' of a font_info, and it
-     must not be freed.  */
-  char *font_name;
-
-  /* Font info ID for this face's font.  An ID is stored here because
-     pointers to font_info structures may change.  The reason is that
-     they are pointers into a font table vector that is itself
-     reallocated.  */
-  int font_info_id;
-
-#ifdef USE_FONT_BACKEND
-  struct font_info *font_info;
-#endif /* USE_FONT_BACKEND */
+  struct font *font;
 
   /* Fontset ID if for this face's fontset.  Non-ASCII faces derived
      from the same ASCII face have the same fontset.  */
@@ -1564,6 +1571,13 @@ 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
+
   /* Next and previous face in hash collision list of face cache.  */
   struct face *next, *prev;
 
@@ -1572,10 +1586,8 @@ struct face
      attributes except the font.  */
   struct face *ascii_face;
 
-#ifdef USE_FONT_BACKEND
   /* Extra member that a font-driver uses privately.  */
   void *extra;
-#endif /* USE_FONT_BACKEND */
 };
 
 
@@ -1811,6 +1823,14 @@ enum prop_idx
   LAST_PROP_IDX
 };
 
+/* An enumerator for the method of wrapping long lines.  */
+
+enum line_wrap_method
+{
+  TRUNCATE,
+  WORD_WRAP,
+  WINDOW_WRAP
+};
 
 struct it_slice
 {
@@ -1886,6 +1906,9 @@ struct it
      this is 1 if we're doing an ellipsis.  Otherwise meaningless.  */
   unsigned ellipsis_p : 1;
 
+  /* True means cursor shouldn't be displayed here.  */
+  unsigned avoid_cursor_p : 1;
+
   /* Display table in effect or null for none.  */
   struct Lisp_Char_Table *dp;
 
@@ -1986,6 +2009,7 @@ struct it
     unsigned multibyte_p : 1;
     unsigned string_from_display_prop_p : 1;
     unsigned display_ellipsis_p : 1;
+    unsigned avoid_cursor_p : 1;
 
     /* properties from display property that are reset by another display property. */
     Lisp_Object space_width;
@@ -2015,8 +2039,7 @@ struct it
      where the `^' can be replaced by a display table entry.  */
   unsigned ctl_arrow_p : 1;
 
-  /* 1 means lines are truncated.  */
-  unsigned truncate_lines_p : 1;
+  enum line_wrap_method line_wrap;
 
   /* Non-zero means that the current face has a box.  */
   unsigned face_box_p : 1;
@@ -2341,19 +2364,6 @@ struct redisplay_interface
                                    int h, int wd));
   void (*destroy_fringe_bitmap) P_ ((int which));
 
-/* Get metrics of character CHAR2B in FONT of type FONT_TYPE.
-   Value is null if CHAR2B is not contained in the font.  */
-  XCharStruct * (*per_char_metric) P_ ((XFontStruct *font, XChar2b *char2b,
-                                       int font_type));
-
-/* Encode CHAR2B using encoding information from FONT_INFO.  CHAR2B is
-   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,
-                         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. */
   void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s));
@@ -2492,6 +2502,11 @@ struct image
   /* Lisp specification of this image.  */
   Lisp_Object spec;
 
+  /* List of "references" followed to build the image.
+     Typically will just contain the name of the image file.
+     Used to allow fine-grained cache flushing.  */
+  Lisp_Object dependencies;
+
   /* Relief to draw around the image.  */
   int relief;
 
@@ -2552,8 +2567,8 @@ struct image_cache
    no image with that id exists.  */
 
 #define IMAGE_FROM_ID(F, ID)                                   \
-     (((ID) >= 0 && (ID) < (FRAME_X_IMAGE_CACHE (F)->used))    \
-      ? FRAME_X_IMAGE_CACHE (F)->images[ID]                    \
+     (((ID) >= 0 && (ID) < (FRAME_IMAGE_CACHE (F)->used))      \
+      ? FRAME_IMAGE_CACHE (F)->images[ID]                      \
       : NULL)
 
 /* Size of bucket vector of image caches.  Should be prime.  */
@@ -2701,6 +2716,9 @@ void move_it_vertically P_ ((struct it *, int));
 void move_it_vertically_backward P_ ((struct it *, int));
 void move_it_by_lines P_ ((struct it *, int, int));
 void move_it_past_eol P_ ((struct it *));
+void move_it_in_display_line (struct it *it,
+                             EMACS_INT to_charpos, int to_x,
+                             enum move_operation_enum op);
 int in_display_vector_p P_ ((struct it *));
 int frame_mode_line_height P_ ((struct frame *));
 void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *));
@@ -2718,11 +2736,12 @@ extern struct frame *last_mouse_frame;
 extern int last_tool_bar_item;
 extern Lisp_Object Vmouse_autoselect_window;
 extern int unibyte_display_via_language_environment;
+extern EMACS_INT underline_minimum_offset;
 
 extern void reseat_at_previous_visible_line_start P_ ((struct it *));
 
 extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object,
-                                          /* XFontStruct */ void *, int, int *));
+                                          struct font *, int, int *));
 
 #ifdef HAVE_WINDOW_SYSTEM
 
@@ -2791,7 +2810,7 @@ int draw_window_fringes P_ ((struct window *, int));
 int update_window_fringes P_ ((struct window *, int));
 void compute_fringe_widths P_ ((struct frame *, int));
 
-#ifdef WINDOWS_NT
+#ifdef WINDOWSNT
 void w32_init_fringe P_ ((struct redisplay_interface *));
 void w32_reset_fringes P_ ((void));
 #endif
@@ -2823,9 +2842,8 @@ extern Lisp_Object x_find_image_file P_ ((Lisp_Object));
 void x_kill_gs_process P_ ((Pixmap, struct frame *));
 struct image_cache *make_image_cache P_ ((void));
 void free_image_cache P_ ((struct frame *));
-void clear_image_cache P_ ((struct frame *, int));
-void forall_images_in_image_cache P_ ((struct frame *,
-                                      void (*) P_ ((struct image *))));
+void clear_image_caches P_ ((Lisp_Object));
+void mark_image_cache P_ ((struct image_cache *));
 int valid_image_p P_ ((Lisp_Object));
 void prepare_image_for_display P_ ((struct frame *, struct image *));
 int lookup_image P_ ((struct frame *, Lisp_Object));
@@ -2865,23 +2883,28 @@ 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 xstrcasecmp P_ ((const unsigned char *, const unsigned char *));
 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));
+int lookup_basic_face P_ ((struct frame *, int));
 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));
 void init_frame_faces P_ ((struct frame *));
 void free_frame_faces P_ ((struct frame *));
 void recompute_basic_faces P_ ((struct frame *));
-int face_at_buffer_position P_ ((struct window *, int, int, int, int *,
-                                int, int));
-int face_for_overlay_string P_ ((struct window *, int, int,
-                                int, int *,
-                                int, int, Lisp_Object));
-int face_at_string_position P_ ((struct window *, Lisp_Object, int, int, int,
-                                int, int *, enum face_id, int));
+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 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,
+                                int mouse, Lisp_Object overlay));
+int face_at_string_position P_ ((struct window *w, Lisp_Object string,
+                                EMACS_INT pos, EMACS_INT bufpos,
+                                EMACS_INT region_beg, EMACS_INT region_end,
+                                EMACS_INT *endptr, enum face_id, int mouse));
 int merge_faces P_ ((struct frame *, Lisp_Object, int, int));
 int compute_char_face P_ ((struct frame *, int, Lisp_Object));
 void free_all_realized_faces P_ ((Lisp_Object));
@@ -2889,8 +2912,8 @@ void free_realized_face P_ ((struct frame *, struct face *));
 extern Lisp_Object Qforeground_color, Qbackground_color;
 extern Lisp_Object Qframe_set_background_mode;
 extern char unspecified_fg[], unspecified_bg[];
-extern Lisp_Object split_font_name_into_vector P_ ((Lisp_Object));
-extern Lisp_Object build_font_name_from_vector P_ ((Lisp_Object));
+
+extern Lisp_Object Vface_remapping_alist;
 
 /* Defined in xfns.c  */
 
@@ -2917,6 +2940,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.  PENDING: 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
@@ -3005,7 +3037,7 @@ void bitch_at_user P_ ((void));
 void init_display P_ ((void));
 void syms_of_display P_ ((void));
 extern Lisp_Object Qredisplay_dont_pause;
-GLYPH spec_glyph_lookup_face P_ ((struct window *, GLYPH));
+void spec_glyph_lookup_face P_ ((struct window *, GLYPH *));
 
 /* Defined in terminal.c */
 
@@ -3038,7 +3070,7 @@ extern void calculate_costs P_ ((struct frame *));
 extern void produce_glyphs P_ ((struct it *));
 extern void produce_special_glyphs P_ ((struct it *, enum display_element_type));
 extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
-extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
+extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
 extern struct terminal *get_tty_terminal P_ ((Lisp_Object, int));
 extern struct terminal *get_named_tty P_ ((char *));
 EXFUN (Ftty_type, 1);