/* Updating of data structures for redisplay.
-Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc.
+Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
+Inc.
This file is part of GNU Emacs.
struct window *);
static void build_frame_matrix_from_leaf_window (struct glyph_matrix *,
struct window *);
-static void adjust_frame_message_buffer (struct frame *);
static void adjust_decode_mode_spec_buffer (struct frame *);
static void fill_up_glyph_row_with_spaces (struct glyph_row *);
static void clear_window_matrices (struct window *, bool);
static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
-\f
-/* Redisplay preemption timers. */
-
-static EMACS_TIME preemption_period;
-static EMACS_TIME preemption_next_check;
-
/* True upon entry to redisplay means do not assume anything about
current contents of actual terminal frame; clear and redraw it. */
"%"pMu": window %p (`%s')%s\n%s",
history_tick++,
w,
- ((BUFFERP (w->buffer)
- && STRINGP (BVAR (XBUFFER (w->buffer), name)))
- ? SSDATA (BVAR (XBUFFER (w->buffer), name))
+ ((BUFFERP (w->contents)
+ && STRINGP (BVAR (XBUFFER (w->contents), name)))
+ ? SSDATA (BVAR (XBUFFER (w->contents), name))
: "???"),
paused_p ? " ***paused***" : "",
msg);
if (NUMBERP (margin))
{
- int width = XFASTINT (w->total_cols);
+ int width = w->total_cols;
double d = max (0, XFLOATINT (margin));
d = min (width / 2 - 1, d);
n = (int) ((double) total_glyphs / width * d);
are invalidated below. */
if (INTEGERP (w->window_end_vpos)
&& XFASTINT (w->window_end_vpos) >= i)
- wset_window_end_valid (w, Qnil);
+ w->window_end_valid = 0;
while (i < matrix->nrows)
matrix->rows[i++].enabled_p = 0;
if (f->current_matrix)
clear_glyph_matrix (f->current_matrix);
+#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
/* Clear the matrix of the menu bar window, if such a window exists.
The menu bar window is currently used to display menus on X when
no toolkit support is compiled in. */
if (WINDOWP (f->menu_bar_window))
clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
+#endif
/* Clear the matrix of the tool-bar window, if any. */
if (WINDOWP (f->tool_bar_window))
if (f->desired_matrix)
clear_glyph_matrix (f->desired_matrix);
+#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
if (WINDOWP (f->menu_bar_window))
clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix);
+#endif
if (WINDOWP (f->tool_bar_window))
clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix);
{
while (w)
{
- if (!NILP (w->hchild))
- {
- eassert (WINDOWP (w->hchild));
- clear_window_matrices (XWINDOW (w->hchild), desired_p);
- }
- else if (!NILP (w->vchild))
- {
- eassert (WINDOWP (w->vchild));
- clear_window_matrices (XWINDOW (w->vchild), desired_p);
- }
+ if (WINDOWP (w->contents))
+ clear_window_matrices (XWINDOW (w->contents), desired_p);
else
{
if (desired_p)
else
{
clear_glyph_matrix (w->current_matrix);
- wset_window_end_valid (w, Qnil);
+ w->window_end_valid = 0;
}
}
struct glyph_row *row = matrix->rows;
struct glyph_row *last_text_row = NULL;
struct buffer *saved = current_buffer;
- struct buffer *buffer = XBUFFER (w->buffer);
+ struct buffer *buffer = XBUFFER (w->contents);
int c;
/* This can sometimes happen for a fresh window. */
vertically below other windows. */
in_horz_combination_p
= (!NILP (XWINDOW (window)->parent)
- && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild));
+ && WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (XWINDOW (window)->parent)));
/* For WINDOW and all windows on the same level. */
do
/* Get the dimension of the window sub-matrix for W, depending
on whether this is a combination or a leaf window. */
- if (!NILP (w->hchild))
- dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y,
- dim_only_p,
- window_change_flags);
- else if (!NILP (w->vchild))
- dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y,
+ if (WINDOWP (w->contents))
+ dim = allocate_matrices_for_frame_redisplay (w->contents, x, y,
dim_only_p,
window_change_flags);
else
}
#endif /* HAVE_WINDOW_SYSTEM */
- return XINT (w->total_cols);
+ return w->total_cols;
}
{
while (w)
{
- if (!NILP (w->vchild))
- allocate_matrices_for_window_redisplay (XWINDOW (w->vchild));
- else if (!NILP (w->hchild))
- allocate_matrices_for_window_redisplay (XWINDOW (w->hchild));
+ if (WINDOWP (w->contents))
+ allocate_matrices_for_window_redisplay (XWINDOW (w->contents));
else
{
/* W is a leaf window. */
else
adjust_frame_glyphs_for_frame_redisplay (f);
- /* Don't forget the message buffer and the buffer for
- decode_mode_spec. */
- adjust_frame_message_buffer (f);
+ /* Don't forget the buffer for decode_mode_spec. */
adjust_decode_mode_spec_buffer (f);
f->glyphs_initialized_p = 1;
{
while (w)
{
- if (!NILP (w->hchild))
+ if (WINDOWP (w->contents))
{
- if (showing_window_margins_p (XWINDOW (w->hchild)))
+ if (showing_window_margins_p (XWINDOW (w->contents)))
return 1;
}
- else if (!NILP (w->vchild))
- {
- if (showing_window_margins_p (XWINDOW (w->vchild)))
- return 1;
- }
- else if (!NILP (w->left_margin_cols)
- || !NILP (w->right_margin_cols))
+ else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols))
return 1;
w = NILP (w->next) ? 0 : XWINDOW (w->next);
{
w = XWINDOW (window);
- if (!NILP (w->hchild))
- fake_current_matrices (w->hchild);
- else if (!NILP (w->vchild))
- fake_current_matrices (w->vchild);
+ if (WINDOWP (w->contents))
+ fake_current_matrices (w->contents);
else
{
int i;
/* Set window dimensions to frame dimensions and allocate or
adjust glyph matrices of W. */
- wset_top_line (w, make_number (0));
- wset_left_col (w, make_number (0));
- wset_total_lines (w, make_number (FRAME_MENU_BAR_LINES (f)));
- wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f)));
+ w->top_line = 0;
+ w->left_col = 0;
+ w->total_lines = FRAME_MENU_BAR_LINES (f);
+ w->total_cols = FRAME_TOTAL_COLS (f);
allocate_matrices_for_window_redisplay (w);
}
#endif /* not USE_X_TOOLKIT && not USE_GTK */
else
w = XWINDOW (f->tool_bar_window);
- wset_top_line (w, make_number (FRAME_MENU_BAR_LINES (f)));
- wset_left_col (w, make_number (0));
- wset_total_lines (w, make_number (FRAME_TOOL_BAR_LINES (f)));
- wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f)));
+ w->top_line = FRAME_MENU_BAR_LINES (f);
+ w->left_col = 0;
+ w->total_lines = FRAME_TOOL_BAR_LINES (f);
+ w->total_cols = FRAME_TOTAL_COLS (f);
allocate_matrices_for_window_redisplay (w);
}
#endif
}
-/* Adjust/ allocate message buffer of frame F.
-
- Note that the message buffer is never freed. Since I could not
- find a free in 19.34, I assume that freeing it would be
- problematic in some way and don't do it either.
-
- (Implementation note: It should be checked if we can free it
- eventually without causing trouble). */
-
-static void
-adjust_frame_message_buffer (struct frame *f)
-{
- FRAME_MESSAGE_BUF (f) = xrealloc (FRAME_MESSAGE_BUF (f),
- FRAME_MESSAGE_BUF_SIZE (f) + 1);
-}
-
-
/* Re-allocate buffer for decode_mode_spec on frame F. */
static void
if (!NILP (f->root_window))
free_window_matrices (XWINDOW (f->root_window));
+#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
/* Free the dummy window for menu bars without X toolkit and its
glyph matrices. */
if (!NILP (f->menu_bar_window))
w->desired_matrix = w->current_matrix = NULL;
fset_menu_bar_window (f, Qnil);
}
+#endif
/* Free the tool bar window and its glyph matrices. */
if (!NILP (f->tool_bar_window))
{
while (w)
{
- if (!NILP (w->hchild))
- free_window_matrices (XWINDOW (w->hchild));
- else if (!NILP (w->vchild))
- free_window_matrices (XWINDOW (w->vchild));
+ if (WINDOWP (w->contents))
+ free_window_matrices (XWINDOW (w->contents));
else
{
/* This is a leaf window. Free its memory and reset fields
{
while (w)
{
- if (!NILP (w->hchild))
- build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild));
- else if (!NILP (w->vchild))
- build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild));
+ if (WINDOWP (w->contents))
+ build_frame_matrix_from_window_tree (matrix, XWINDOW (w->contents));
else
build_frame_matrix_from_leaf_window (matrix, w);
{
while (w)
{
- if (!NILP (w->hchild))
- mirror_make_current (XWINDOW (w->hchild), frame_row);
- else if (!NILP (w->vchild))
- mirror_make_current (XWINDOW (w->vchild), frame_row);
+ if (WINDOWP (w->contents))
+ mirror_make_current (XWINDOW (w->contents), frame_row);
else
{
/* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS
struct glyph_row *window_row, *window_row_end, *frame_row;
int left, right, x, width;
- /* Preconditions: W must be a leaf window on a tty frame. */
- eassert (NILP (w->hchild) && NILP (w->vchild));
+ /* Preconditions: W must be a live window on a tty frame. */
+ eassert (BUFFERP (w->contents));
eassert (!FRAME_WINDOW_P (f));
left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols);
while (w && !found)
{
- if (!NILP (w->hchild))
- found = frame_row_to_window (XWINDOW (w->hchild), row);
- else if (!NILP (w->vchild))
- found = frame_row_to_window (XWINDOW (w->vchild), row);
+ if (WINDOWP (w->contents))
+ found = frame_row_to_window (XWINDOW (w->contents), row);
else if (row >= WINDOW_TOP_EDGE_LINE (w)
&& row < WINDOW_BOTTOM_EDGE_LINE (w))
found = w;
{
while (w)
{
- if (!NILP (w->hchild))
- mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top,
- nlines, copy_from, retained_p);
- else if (!NILP (w->vchild))
- mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top,
+ if (WINDOWP (w->contents))
+ mirror_line_dance (XWINDOW (w->contents), unchanged_at_top,
nlines, copy_from, retained_p);
else
{
{
while (w)
{
- if (!NILP (w->hchild))
- check_window_matrix_pointers (XWINDOW (w->hchild));
- else if (!NILP (w->vchild))
- check_window_matrix_pointers (XWINDOW (w->vchild));
+ if (WINDOWP (w->contents))
+ check_window_matrix_pointers (XWINDOW (w->contents));
else
{
struct frame *f = XFRAME (w->frame);
if (redisplay_dont_pause)
force_p = 1;
- else if (NILP (Vredisplay_preemption_period))
- force_p = 1;
- else if (!force_p && NUMBERP (Vredisplay_preemption_period))
+ else if (!force_p && detect_input_pending_ignore_squeezables ())
{
- double p = XFLOATINT (Vredisplay_preemption_period);
-
- if (detect_input_pending_ignore_squeezables ())
- {
- paused_p = 1;
- goto do_pause;
- }
-
- preemption_period = EMACS_TIME_FROM_DOUBLE (p);
- preemption_next_check = add_emacs_time (current_emacs_time (),
- preemption_period);
+ paused_p = 1;
+ goto do_pause;
}
if (FRAME_WINDOW_P (f))
when pending input is detected. */
update_begin (f);
+#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
/* Update the menu bar on X frames that don't have toolkit
support. */
if (WINDOWP (f->menu_bar_window))
update_window (XWINDOW (f->menu_bar_window), 1);
+#endif
/* Update the tool-bar window, if present. */
if (WINDOWP (f->tool_bar_window))
while (w && !paused_p)
{
- if (!NILP (w->hchild))
- paused_p |= update_window_tree (XWINDOW (w->hchild), force_p);
- else if (!NILP (w->vchild))
- paused_p |= update_window_tree (XWINDOW (w->vchild), force_p);
+ if (WINDOWP (w->contents))
+ paused_p |= update_window_tree (XWINDOW (w->contents), force_p);
else if (w->must_be_updated_p)
paused_p |= update_window (w, force_p);
if (redisplay_dont_pause)
force_p = 1;
- else if (NILP (Vredisplay_preemption_period))
- force_p = 1;
- else if (!force_p && NUMBERP (Vredisplay_preemption_period))
- {
- double p = XFLOATINT (Vredisplay_preemption_period);
- preemption_period = EMACS_TIME_FROM_DOUBLE (p);
- preemption_next_check = add_emacs_time (current_emacs_time (),
- preemption_period);
- }
/* Update W. */
update_begin (f);
{
struct glyph_matrix *desired_matrix = w->desired_matrix;
bool paused_p;
-#if !PERIODIC_PREEMPTION_CHECKING
int preempt_count = baud_rate / 2400 + 1;
-#endif
struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
#ifdef GLYPH_DEBUG
/* Check that W's frame doesn't have glyph matrices. */
#endif
/* Check pending input the first time so that we can quickly return. */
-#if !PERIODIC_PREEMPTION_CHECKING
if (!force_p)
detect_input_pending_ignore_squeezables ();
-#endif
/* If forced to complete the update, or if no input is pending, do
the update. */
struct glyph_row *header_line_row;
int yb;
bool changed_p = 0, mouse_face_overwritten_p = 0;
-#if ! PERIODIC_PREEMPTION_CHECKING
int n_updated = 0;
-#endif
rif->update_window_begin_hook (w);
yb = window_text_bottom_y (w);
- row = desired_matrix->rows;
- end = row + desired_matrix->nrows - 1;
+ row = MATRIX_ROW (desired_matrix, 0);
+ end = MATRIX_MODE_LINE_ROW (desired_matrix);
/* Take note of the header line, if there is one. We will
update it below, after updating all of the window's lines. */
detect_input_pending. If it's done too often,
scrolling large windows with repeated scroll-up
commands will too quickly pause redisplay. */
-#if PERIODIC_PREEMPTION_CHECKING
- if (!force_p)
- {
- EMACS_TIME tm = current_emacs_time ();
- if (EMACS_TIME_LT (preemption_next_check, tm))
- {
- preemption_next_check = add_emacs_time (tm,
- preemption_period);
- if (detect_input_pending_ignore_squeezables ())
- break;
- }
- }
-#else
if (!force_p && ++n_updated % preempt_count == 0)
detect_input_pending_ignore_squeezables ();
-#endif
changed_p |= update_window_line (w, vpos,
&mouse_face_overwritten_p);
vpos = w->cursor.vpos;
}
- /* Window cursor can be out of sync for horizontally split windows. */
- hpos = max (-1, hpos); /* -1 is for when cursor is on the left fringe */
- hpos = min (w->current_matrix->matrix_w - 1, hpos);
- vpos = max (0, vpos);
- vpos = min (w->current_matrix->nrows - 1, vpos);
+ /* Window cursor can be out of sync for horizontally split windows.
+ Horizontal position is -1 when cursor is on the left fringe. */
+ hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1);
+ vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1);
rif->cursor_to (vpos, hpos, cy, cx);
}
{
while (w)
{
- if (!NILP (w->hchild))
- set_window_update_flags (XWINDOW (w->hchild), on_p);
- else if (!NILP (w->vchild))
- set_window_update_flags (XWINDOW (w->vchild), on_p);
+ if (WINDOWP (w->contents))
+ set_window_update_flags (XWINDOW (w->contents), on_p);
else
w->must_be_updated_p = on_p;
row_table[row_entry_pool[i].bucket] = NULL;
/* Value is 1 to indicate that we scrolled the display. */
- return 0 < nruns;
+ return nruns > 0;
}
if (preempt_count <= 0)
preempt_count = 1;
-#if !PERIODIC_PREEMPTION_CHECKING
if (!force_p && detect_input_pending_ignore_squeezables ())
{
pause_p = 1;
goto do_pause;
}
-#endif
/* If we cannot insert/delete lines, it's no use trying it. */
if (!FRAME_LINE_INS_DEL_OK (f))
}
}
-#if PERIODIC_PREEMPTION_CHECKING
- if (!force_p)
- {
- EMACS_TIME tm = current_emacs_time ();
- if (EMACS_TIME_LT (preemption_next_check, tm))
- {
- preemption_next_check = add_emacs_time (tm, preemption_period);
- if (detect_input_pending_ignore_squeezables ())
- break;
- }
- }
-#else
if (!force_p && (i - 1) % preempt_count == 0)
detect_input_pending_ignore_squeezables ();
-#endif
update_frame_line (f, i);
}
}
- lint_assume (0 <= FRAME_LINES (f));
+ lint_assume (FRAME_LINES (f) >= 0);
pause_p = 0 < i && i < FRAME_LINES (f) - 1;
/* Now just clean up termcap drivers and set cursor, etc. */
}
}
-#if !PERIODIC_PREEMPTION_CHECKING
do_pause:
-#endif
clear_desired_matrices (f);
return pause_p;
/* We used to set current_buffer directly here, but that does the
wrong thing with `face-remapping-alist' (bug#2044). */
- Fset_buffer (w->buffer);
+ Fset_buffer (w->contents);
itdata = bidi_shelve_cache ();
SET_TEXT_POS_FROM_MARKER (startp, w->start);
CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
*dx = x0 + it.first_visible_x - it.current_x;
*dy = *y - it.current_y;
- string = w->buffer;
+ string = w->contents;
if (STRINGP (it.string))
string = it.string;
*pos = it.current;
if (STRINGP (it.string))
BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
else
- BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer),
+ BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->contents),
CHARPOS (pos->pos));
}
FrameCols (FRAME_TTY (f)) = newwidth;
if (WINDOWP (f->tool_bar_window))
- wset_total_cols (XWINDOW (f->tool_bar_window), make_number (newwidth));
+ XWINDOW (f->tool_bar_window)->total_cols = newwidth;
}
FRAME_LINES (f) = newheight;
if (noninteractive)
putchar (07);
else if (!INTERACTIVE) /* Stop executing a keyboard macro. */
- error ("Keyboard macro terminated by a command ringing the bell");
+ {
+ const char *msg
+ = "Keyboard macro terminated by a command ringing the bell";
+ Fsignal (Quser_error, Fcons (build_string (msg), Qnil));
+ }
else
ring_bell (XFRAME (selected_frame));
}
duration += XINT (milliseconds) / 1000.0;
}
- if (0 < duration)
+ if (duration > 0)
{
EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration);
wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX),
if (INTEGERP (timeout))
{
sec = XINT (timeout);
- if (! (0 < sec))
+ if (sec <= 0)
return Qt;
nsec = 0;
}
else if (FLOATP (timeout))
{
double seconds = XFLOAT_DATA (timeout);
- if (! (0 < seconds))
+ if (seconds <= 0)
return Qt;
else
{
inverse_video = 0;
cursor_in_echo_area = 0;
- terminal_type = (char *) 0;
/* Now is the time to initialize this; it's used by init_sys_modes
during startup. */
/* If no window system has been specified, try to use the terminal. */
if (! isatty (0))
- {
- fatal ("standard input is not a tty");
- exit (1);
- }
+ fatal ("standard input is not a tty");
#ifdef WINDOWSNT
terminal_type = "w32console";
#else
- /* Look at the TERM variable. */
- terminal_type = (char *) getenv ("TERM");
+ terminal_type = getenv ("TERM");
#endif
if (!terminal_type)
{
doc: /* Non-nil means display update isn't paused when input is detected. */);
redisplay_dont_pause = 1;
-#if PERIODIC_PREEMPTION_CHECKING
- DEFVAR_LISP ("redisplay-preemption-period", Vredisplay_preemption_period,
- doc: /* Period in seconds between checking for input during redisplay.
-This has an effect only if `redisplay-dont-pause' is nil; in that
-case, arriving input preempts redisplay until the input is processed.
-If the value is nil, redisplay is never preempted. */);
- Vredisplay_preemption_period = make_float (0.10);
-#endif
-
#ifdef CANNOT_DUMP
if (noninteractive)
#endif