#include "systime.h"
#include <errno.h>
-/* To get the prototype for `sleep'. */
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
/* Get number of chars of output now in the buffer of a stdio stream.
This ought to be built in in stdio, but it isn't. Some s- files
override this because their stdio internals differ. */
DEFUN ("dump-redisplay-history", Fdump_redisplay_history,
Sdump_redisplay_history, 0, 0, "",
doc: /* Dump redisplay history to stderr. */)
- ()
+ (void)
{
int i;
#endif /* GLYPH_DEBUG == 0 */
-#ifdef PROFILING
+#if defined PROFILING && !HAVE___EXECUTABLE_START
/* FIXME: only used to find text start for profiling. */
void
DELTA_BYTES. */
void
-increment_matrix_positions (struct glyph_matrix *matrix, int start, int end, int delta, int delta_bytes)
+increment_matrix_positions (struct glyph_matrix *matrix, int start, int end,
+ EMACS_INT delta, EMACS_INT delta_bytes)
{
/* Check that START and END are reasonable values. */
xassert (start >= 0 && start <= matrix->nrows);
ends. */
void
-increment_row_positions (struct glyph_row *row, int delta, int delta_bytes)
+increment_row_positions (struct glyph_row *row,
+ EMACS_INT delta, EMACS_INT delta_bytes)
{
int area, i;
/* Copy glyph row structure FROM to glyph row structure TO, except
that glyph pointers in the structures are left unchanged. */
-INLINE void
+static INLINE void
copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
{
struct glyph *pointers[1 + LAST_AREA];
positions in row TO by DELTA/ DELTA_BYTES. */
void
-copy_glyph_row_contents (struct glyph_row *to, struct glyph_row *from, int delta, int delta_bytes)
+copy_glyph_row_contents (struct glyph_row *to, struct glyph_row *from,
+ EMACS_INT delta, EMACS_INT delta_bytes)
{
int area;
int size = needed * sizeof (struct glyph);
if (pool->glyphs)
- pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+ {
+ pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+ memset (pool->glyphs + pool->nglyphs, 0,
+ size - pool->nglyphs * sizeof (struct glyph));
+ }
else
{
pool->glyphs = (struct glyph *) xmalloc (size);
#define CHANGED_LEAF_MATRIX (1 << 1)
static struct dim
-allocate_matrices_for_frame_redisplay (window, x, y, dim_only_p,
- window_change_flags)
- Lisp_Object window;
- int x, y;
- int dim_only_p;
- int *window_change_flags;
+allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
+ int dim_only_p, int *window_change_flags)
{
struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
int x0 = x, y0 = y;
else
swap_glyph_pointers (desired_row, current_row);
current_row->enabled_p = 1;
+
+ /* Set the Y coordinate of the mode/header line's row.
+ It is needed in draw_row_with_mouse_face to find the
+ screen coordinates. (Window-based redisplay sets
+ this in update_window, but no one seems to do that
+ for frame-based redisplay.) */
+ if (current_row->mode_line_p)
+ current_row->y = row;
}
}
This function is called from do_scrolling and do_direct_scrolling. */
void
-mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from,
- retained_p)
- struct glyph_matrix *matrix;
- int unchanged_at_top, nlines;
- int *copy_from;
- char *retained_p;
+mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlines,
+ int *copy_from, char *retained_p)
{
/* A copy of original rows. */
struct glyph_row *old_rows;
DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
doc: /* Clear frame FRAME and output again what is supposed to appear on it. */)
- (frame)
- Lisp_Object frame;
+ (Lisp_Object frame)
{
struct frame *f;
DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
doc: /* Clear and redisplay all visible frames. */)
- ()
+ (void)
{
Lisp_Object tail, frame;
#if !PERIODIC_PREEMPTION_CHECKING
int preempt_count = baud_rate / 2400 + 1;
#endif
- extern int input_pending;
- extern Lisp_Object do_mouse_tracking;
struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
#if GLYPH_DEBUG
/* Check that W's frame doesn't have glyph matrices. */
int i;
int pause;
int preempt_count = baud_rate / 2400 + 1;
- extern int input_pending;
xassert (current_matrix && desired_matrix);
/* Char insertion/deletion cost vector, from term.c */
-extern int *char_ins_del_vector;
#define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_TOTAL_COLS((f))])
***********************************************************************/
/* Determine what's under window-relative pixel position (*X, *Y).
- Return the object (string or buffer) that's there.
+ Return the OBJECT (string or buffer) that's there.
Return in *POS the position in that object.
- Adjust *X and *Y to character positions. */
+ Adjust *X and *Y to character positions.
+ Return in *DX and *DY the pixel coordinates of the click,
+ relative to the top left corner of OBJECT, or relative to
+ the top left corner of the character glyph at (*X, *Y)
+ if OBJECT is nil.
+ Return WIDTH and HEIGHT of the object at (*X, *Y), or zero
+ if the coordinates point to an empty area of the display. */
Lisp_Object
buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *pos, Lisp_Object *object, int *dx, int *dy, int *width, int *height)
#ifdef HAVE_WINDOW_SYSTEM
struct image *img = 0;
#endif
- int x0, x1;
+ int x0, x1, to_x;
/* We used to set current_buffer directly here, but that does the
wrong thing with `face-remapping-alist' (bug#2044). */
BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
start_display (&it, w, startp);
- x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w);
- move_it_to (&it, -1, x0 + it.first_visible_x, *y, -1,
- MOVE_TO_X | MOVE_TO_Y);
+ x0 = *x;
+
+ /* First, move to the beginning of the row corresponding to *Y. We
+ need to be in that row to get the correct value of base paragraph
+ direction for the text at (*X, *Y). */
+ move_it_to (&it, -1, 0, *y, -1, MOVE_TO_X | MOVE_TO_Y);
+
+ /* TO_X is the pixel position that the iterator will compute for the
+ glyph at *X. We add it.first_visible_x because iterator
+ positions include the hscroll. */
+ to_x = x0 + it.first_visible_x;
+ if (it.bidi_it.paragraph_dir == R2L)
+ /* For lines in an R2L paragraph, we need to mirror TO_X wrt the
+ text area. This is because the iterator, even in R2L
+ paragraphs, delivers glyphs as if they started at the left
+ margin of the window. (When we actually produce glyphs for
+ display, we reverse their order in PRODUCE_GLYPHS, but the
+ iterator doesn't know about that.) The following line adjusts
+ the pixel position to the iterator geometry, which is what
+ move_it_* routines use. (The -1 is because in a window whose
+ text-area width is W, the rightmost pixel position is W-1, and
+ it should be mirrored into zero pixel position.) */
+ to_x = window_box_width (w, TEXT_AREA) - to_x - 1;
+
+ /* Now move horizontally in the row to the glyph under *X. Second
+ argument is ZV to prevent move_it_in_display_line from matching
+ based on buffer positions. */
+ move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X);
Fset_buffer (old_current_buffer);
if (STRINGP (it.string))
string = it.string;
*pos = it.current;
+ if (it.what == IT_COMPOSITION
+ && it.cmp_it.nchars > 1
+ && it.cmp_it.reversed_p)
+ {
+ /* The current display element is a grapheme cluster in a
+ composition. In that case, we need the position of the first
+ character of the cluster. But, as it.cmp_it.reversed_p is 1,
+ it.current points to the last character of the cluster, thus
+ we must move back to the first character of the same
+ cluster. */
+ CHARPOS (pos->pos) -= it.cmp_it.nchars - 1;
+ if (STRINGP (it.string))
+ BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
+ else
+ BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos));
+ }
#ifdef HAVE_WINDOW_SYSTEM
if (it.what == IT_IMAGE)
if (img)
{
*dy -= row->ascent - glyph->ascent;
- *dx += glyph->slice.x;
- *dy += glyph->slice.y;
+ *dx += glyph->slice.img.x;
+ *dy += glyph->slice.img.y;
/* Image slices positions are still relative to the entire image */
*width = img->width;
*height = img->height;
*CHARPOS is set to the position in the string returned. */
Lisp_Object
-mode_line_string (struct window *w, enum window_part part, int *x, int *y, int *charpos, Lisp_Object *object, int *dx, int *dy, int *width, int *height)
+mode_line_string (struct window *w, enum window_part part,
+ int *x, int *y, EMACS_INT *charpos, Lisp_Object *object,
+ int *dx, int *dy, int *width, int *height)
{
struct glyph_row *row;
struct glyph *glyph, *end;
the string returned. */
Lisp_Object
-marginal_area_string (struct window *w, enum window_part part, int *x, int *y, int *charpos, Lisp_Object *object, int *dx, int *dy, int *width, int *height)
+marginal_area_string (struct window *w, enum window_part part,
+ int *x, int *y, EMACS_INT *charpos, Lisp_Object *object,
+ int *dx, int *dy, int *width, int *height)
{
struct glyph_row *row = w->current_matrix->rows;
struct glyph *glyph, *end;
if (img != NULL)
*object = img->spec;
y0 -= row->ascent - glyph->ascent;
- x0 += glyph->slice.x;
- y0 += glyph->slice.y;
+ x0 += glyph->slice.img.x;
+ y0 += glyph->slice.img.y;
}
#endif
}
1, 1, "FOpen termscript file: ",
doc: /* Start writing all terminal output to FILE as well as the terminal.
FILE = nil means just close any termscript file currently open. */)
- (file)
- Lisp_Object file;
+ (Lisp_Object file)
{
struct tty_display_info *tty;
It may be a terminal object, a frame, or nil for the terminal used by
the currently selected frame. In batch mode, STRING is sent to stdout
when TERMINAL is nil. */)
- (string, terminal)
- Lisp_Object string;
- Lisp_Object terminal;
+ (Lisp_Object string, Lisp_Object terminal)
{
struct terminal *t = get_terminal (terminal, 1);
FILE *out;
doc: /* Beep, or flash the screen.
Also, unless an argument is given,
terminate any keyboard macro currently executing. */)
- (arg)
- Lisp_Object arg;
+ (Lisp_Object arg)
{
if (!NILP (arg))
{
additional wait period, in milliseconds; this may be useful if your
Emacs was built without floating point support.
\(Not all operating systems support waiting for a fraction of a second.) */)
- (seconds, milliseconds)
- Lisp_Object seconds, milliseconds;
+ (Lisp_Object seconds, Lisp_Object milliseconds)
{
int sec, usec;
If optional arg FORCE is non-nil or `redisplay-dont-pause' is non-nil,
perform a full redisplay even if input is available.
Return t if redisplay was performed, nil otherwise. */)
- (force)
- Lisp_Object force;
+ (Lisp_Object force)
{
int count;
If VARIABLE is nil, an internal variable is used. Users should not
pass nil for VARIABLE. */)
- (variable)
- Lisp_Object variable;
+ (Lisp_Object variable)
{
Lisp_Object state, tail, frame, buf;
Lisp_Object *vecp, *end;
{
char *terminal_type;
-#ifdef HAVE_X_WINDOWS
- extern int display_arg;
-#endif
-
/* Construct the space glyph. */
space_glyph.type = CHAR_GLYPH;
SET_CHAR_GLYPH (space_glyph, ' ', DEFAULT_FACE_ID, 0);
f->terminal = t;
t->reference_count++;
+#ifdef MSDOS
+ f->output_data.tty->display_info = &the_only_display_info;
+#else
+ if (f->output_method == output_termcap)
+ create_tty_output (f);
+#endif
t->display_info.tty->top_frame = selected_frame;
change_frame_size (XFRAME (selected_frame),
FrameRows (t->display_info.tty),
WINDOW nil means use the selected window. SHOW non-nil means
show a cursor in WINDOW in the next redisplay. SHOW nil means
don't show a cursor. */)
- (window, show)
- Lisp_Object window, show;
+ (Lisp_Object window, Lisp_Object show)
{
/* Don't change cursor state while redisplaying. This could confuse
output routines. */
Sinternal_show_cursor_p, 0, 1, 0,
doc: /* Value is non-nil if next redisplay will display a cursor in WINDOW.
WINDOW nil or omitted means report on the selected window. */)
- (window)
- Lisp_Object window;
+ (Lisp_Object window)
{
struct window *w;
DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
Slast_nonminibuf_frame, 0, 0, 0,
doc: /* Value is last nonminibuffer frame. */)
- ()
+ (void)
{
Lisp_Object frame = Qnil;
DEFVAR_LISP ("initial-window-system", &Vinitial_window_system,
doc: /* Name of the window system that Emacs uses for the first frame.
-The value is a symbol--for instance, `x' for X windows.
-The value is nil if Emacs is using a text-only terminal. */);
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+Use of this variable as a boolean is deprecated. Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities. */);
DEFVAR_KBOARD ("window-system", Vwindow_system,
doc: /* Name of window system through which the selected frame is displayed.
-The value is a symbol--for instance, `x' for X windows.
-The value is nil if the selected frame is on a text-only-terminal. */);
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+Use of this variable as a boolean is deprecated. Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities. */);
DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
doc: /* The version number of the window system in use.