/* Interface definitions for display code.
-Copyright (C) 1985, 1993-1994, 1997-2012 Free Software Foundation, Inc.
+Copyright (C) 1985, 1993-1994, 1997-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#ifndef DISPEXTERN_H_INCLUDED
#define DISPEXTERN_H_INCLUDED
+#include "character.h"
+
#ifdef HAVE_X_WINDOWS
#include <X11/Xlib.h>
Glyphs
***********************************************************************/
+/* The glyph datatype, used to represent characters on the display.
+ It consists of a char code and a face id. */
+
+typedef struct {
+ int ch;
+ int face_id;
+} GLYPH;
+
+/* Return a glyph's character code. */
+DISPEXTERN_INLINE int GLYPH_CHAR (GLYPH glyph) { return glyph.ch; }
+
+/* Return a glyph's face ID. */
+DISPEXTERN_INLINE int GLYPH_FACE (GLYPH glyph) { return glyph.face_id; }
+
+#define SET_GLYPH_CHAR(glyph, char) ((glyph).ch = (char))
+#define SET_GLYPH_FACE(glyph, face) ((glyph).face_id = (face))
+#define SET_GLYPH(glyph, char, face) \
+ ((glyph).ch = (char), (glyph).face_id = (face))
+
+/* The following are valid only if GLYPH_CODE_P (gc). */
+
+DISPEXTERN_INLINE int
+GLYPH_CODE_CHAR (Lisp_Object gc)
+{
+ return (CONSP (gc)
+ ? XINT (XCAR (gc))
+ : XINT (gc) & MAX_CHAR);
+}
+
+DISPEXTERN_INLINE int
+GLYPH_CODE_FACE (Lisp_Object gc)
+{
+ return CONSP (gc) ? XINT (XCDR (gc)) : XINT (gc) >> CHARACTERBITS;
+}
+
+#define SET_GLYPH_FROM_GLYPH_CODE(glyph, gc) \
+ do \
+ { \
+ if (CONSP (gc)) \
+ SET_GLYPH (glyph, XINT (XCAR (gc)), XINT (XCDR (gc))); \
+ else \
+ SET_GLYPH (glyph, (XINT (gc) & ((1 << CHARACTERBITS)-1)), \
+ (XINT (gc) >> CHARACTERBITS)); \
+ } \
+ while (0)
+
+/* The ID of the mode line highlighting face. */
+enum { GLYPH_MODE_LINE_FACE = 1 };
+
/* Enumeration of glyph types. Glyph structures contain a type field
containing one of the enumerators defined here. */
struct glyph
{
/* Position from which this glyph was drawn. If `object' below is a
- Lisp string, this is a position in that string. If it is a
- 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. */
+ Lisp string, this is an index into that string. If it is a
+ buffer, this is a position in that buffer. In addition, some
+ special glyphs have special values for this:
+
+ glyph standing for newline at end of line 0
+ empty space after the end of the line -1
+ overlay arrow on a TTY -1
+ glyph at EOB that ends in a newline -1
+ left truncation glyphs: -1
+ right truncation/continuation glyphs next buffer position
+ glyph standing for newline of an empty line buffer position of newline
+ stretch glyph at left edge of R2L lines buffer position of newline */
ptrdiff_t charpos;
- /* Lisp object source of this glyph. Currently either a buffer or
- a string, if the glyph was produced from characters which came from
- a buffer or a string; or 0 if the glyph was inserted by redisplay
- for its own purposes such as padding. */
+ /* Lisp object source of this glyph. Currently either a buffer or a
+ string, if the glyph was produced from characters which came from
+ a buffer or a string; or Lisp integer zero (a.k.a. "null object")
+ if the glyph was inserted by redisplay for its own purposes, such
+ as padding or truncation/continuation glyphs, or the
+ overlay-arrow glyphs on TTYs. */
Lisp_Object object;
/* Width in pixels. */
2. Window glyph matrices on frames having frame glyph matrices.
Such matrices are sub-matrices of their corresponding frame matrix,
- i.e. frame glyph matrices and window glyph matrices share the same
- glyph memory which is allocated in form of a glyph_pool structure.
+ i.e., frame glyph matrices and window glyph matrices share the same
+ glyph memory, which is allocated in the form of a glyph_pool structure.
Glyph rows in such a window matrix are slices of frame matrix rows.
2. Free-standing window glyph matrices managing their own glyph
? current_mode_line_height \
: (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
- : estimate_mode_line_height (XFRAME (W->frame), \
+ : estimate_mode_line_height (XFRAME ((W)->frame), \
CURRENT_MODE_LINE_FACE_ID (W))))
/* Return the current height of the header line of window W. If not
? current_header_line_height \
: (MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
? MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
- : estimate_mode_line_height (XFRAME (W->frame),\
+ : estimate_mode_line_height (XFRAME ((W)->frame), \
HEADER_LINE_FACE_ID)))
/* Return the height of the desired mode line of window W. */
/* Value is non-zero if window W wants a mode line. */
-#define WINDOW_WANTS_MODELINE_P(W) \
- (!MINI_WINDOW_P ((W)) \
- && !(W)->pseudo_window_p \
- && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
- && BUFFERP (W->buffer) \
- && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \
- && WINDOW_TOTAL_LINES (W) > 1)
+#define WINDOW_WANTS_MODELINE_P(W) \
+ (!MINI_WINDOW_P ((W)) \
+ && !(W)->pseudo_window_p \
+ && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
+ && BUFFERP ((W)->contents) \
+ && !NILP (BVAR (XBUFFER ((W)->contents), mode_line_format)) \
+ && WINDOW_TOTAL_LINES (W) > 1)
/* Value is true if window W wants a header line. */
#define WINDOW_WANTS_HEADER_LINE_P(W) \
- (!MINI_WINDOW_P ((W)) \
+ (BUFFERP ((W)->contents) \
+ ? (!MINI_WINDOW_P ((W)) \
&& !(W)->pseudo_window_p \
&& FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
- && BUFFERP (W->buffer) \
- && !NILP (BVAR (XBUFFER (W->buffer), header_line_format)) \
- && WINDOW_TOTAL_LINES (W) > 1 \
- + !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)))
-
+ && !NILP (BVAR (XBUFFER ((W)->contents), header_line_format)) \
+ && WINDOW_TOTAL_LINES (W) > \
+ (1 + !NILP (BVAR (XBUFFER ((W)->contents), mode_line_format)))) \
+ : 0)
/* Return proper value to be used as baseline offset of font that has
ASCENT and DESCENT to draw characters by the font at the vertical
/* Pixmap width and height. */
unsigned int pixmap_w, pixmap_h;
- /* Non-zero means characters in this face have a box that thickness
- around them. If it is negative, the absolute value indicates the
- thickness, and the horizontal lines of box (top and bottom) are
- drawn inside of characters glyph area. The vertical lines of box
- (left and right) are drawn as the same way as the case that this
- value is positive. */
+ /* Non-zero means characters in this face have a box of that
+ thickness around them. If this value is negative, its absolute
+ value indicates the thickness, and the horizontal (top and
+ bottom) borders of box are drawn inside of the character glyphs'
+ area. The vertical (left and right) borders of the box are drawn
+ in the same way as when this value is positive. */
int box_line_width;
/* Type of box drawn. A value of FACE_NO_BOX means no box is drawn
shadow colors derived from the background color of the face. */
enum face_box_type box;
+ /* Style of underlining. */
+ enum face_underline_type underline_type;
+
/* If `box' above specifies a 3D type, 1 means use box_color for
drawing shadows. */
unsigned use_box_color_for_shadows_p : 1;
- /* Style of underlining. */
- enum face_underline_type underline_type;
-
/* Non-zero if text in this face should be underlined, overlined,
strike-through or have a box drawn around it. */
unsigned underline_p : 1;
#endif /* not HAVE_WINDOW_SYSTEM */
+/* Return true if G contains a valid character code. */
+DISPEXTERN_INLINE bool
+GLYPH_CHAR_VALID_P (GLYPH g)
+{
+ return CHAR_VALID_P (GLYPH_CHAR (g));
+}
+
+/* The glyph code from a display vector may either be an integer which
+ encodes a char code in the lower CHARACTERBITS bits and a (very small)
+ face-id in the upper bits, or it may be a cons (CHAR . FACE-ID). */
+
+DISPEXTERN_INLINE bool
+GLYPH_CODE_P (Lisp_Object gc)
+{
+ return (CONSP (gc)
+ ? (CHARACTERP (XCAR (gc))
+ && RANGED_INTEGERP (0, XCDR (gc), MAX_FACE_ID))
+ : (RANGED_INTEGERP
+ (0, gc,
+ (MAX_FACE_ID < TYPE_MAXIMUM (EMACS_INT) >> CHARACTERBITS
+ ? ((EMACS_INT) MAX_FACE_ID << CHARACTERBITS) | MAX_CHAR
+ : TYPE_MAXIMUM (EMACS_INT)))));
+}
+
/* Non-zero means face attributes have been changed since the last
redisplay. Used in redisplay_internal. */
stuff that is not part of the bidi iterator's state! */
struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */
struct bidi_string_data string; /* string to reorder */
+ struct window *w; /* the window being displayed */
bidi_dir_t paragraph_dir; /* current paragraph direction */
ptrdiff_t separator_limit; /* where paragraph separator should end */
unsigned prev_was_pdf : 1; /* if non-zero, previous char was PDF */
/* Pixmaps of the image. */
Pixmap pixmap, mask;
+#ifdef HAVE_X_WINDOWS
+ /* X images of the image, corresponding to the above Pixmaps.
+ Non-NULL means it and its Pixmap counterpart may be out of sync
+ and the latter is outdated. NULL means the X image has been
+ synchronized to Pixmap. */
+ XImagePtr ximg, mask_img;
+#endif
+
/* Colors allocated for this image, if any. Allocated via xmalloc. */
unsigned long *colors;
int ncolors;
struct glyph_row *,
struct glyph_row *, int);
int line_bottom_y (struct it *);
+int default_line_pixel_height (struct window *);
int display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t);
void resize_echo_area_exactly (void);
int resize_mini_window (struct window *, int);
extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
extern ptrdiff_t compute_display_string_pos (struct text_pos *,
struct bidi_string_data *,
- int, int *);
+ struct window *, int, int *);
extern ptrdiff_t compute_display_string_end (ptrdiff_t,
struct bidi_string_data *);
extern void produce_stretch_glyph (struct it *);
void prepare_image_for_display (struct frame *, struct image *);
ptrdiff_t lookup_image (struct frame *, Lisp_Object);
-unsigned long image_background (struct image *, struct frame *,
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
+#define RGB_PIXEL_COLOR unsigned long
+#endif
+
+#ifdef HAVE_NTGUI
+#define RGB_PIXEL_COLOR COLORREF
+#endif
+
+RGB_PIXEL_COLOR image_background (struct image *, struct frame *,
XImagePtr_or_DC ximg);
int image_background_transparent (struct image *, struct frame *,
XImagePtr_or_DC mask);
void get_tty_size (int, int *, int *);
void request_sigio (void);
void unrequest_sigio (void);
-int tabs_safe_p (int);
+bool tabs_safe_p (int);
void init_baud_rate (int);
void init_sigio (int);
void ignore_sigio (void);
extern int per_line_cost (const char *);
extern void calculate_costs (struct frame *);
extern void produce_glyphs (struct it *);
-extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, unsigned long);
+extern bool tty_capable_p (struct tty_display_info *, unsigned,
+ unsigned long, unsigned long);
extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
extern struct terminal *get_named_tty (const char *);
extern void create_tty_output (struct frame *);
-extern struct terminal *init_tty (const char *, const char *, int);
+extern struct terminal *init_tty (const char *, const char *, bool);
extern void tty_append_glyph (struct it *);