static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
static void select_window_1 (Lisp_Object, bool);
+static struct window *set_window_fringes (struct window *, Lisp_Object,
+ Lisp_Object, Lisp_Object);
+static struct window *set_window_margins (struct window *, Lisp_Object,
+ Lisp_Object);
+static struct window *set_window_scroll_bars (struct window *, Lisp_Object,
+ Lisp_Object, Lisp_Object);
+static void apply_window_adjustment (struct window *);
+
/* This is the window in which the terminal's cursor should
be left when nothing is being done with it. This must
always be a leaf window, and its buffer is selected by
w->pointm = val;
}
static void
-wset_scroll_bar_width (struct window *w, Lisp_Object val)
-{
- w->scroll_bar_width = val;
-}
-static void
wset_start (struct window *w, Lisp_Object val)
{
w->start = val;
than one window. It also matters when
redisplay_window has altered point after scrolling,
because it makes the change only in the window. */
- {
- register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm);
- if (new_point < BEGV)
- SET_PT (BEGV);
- else if (new_point > ZV)
- SET_PT (ZV);
- else
- SET_PT (new_point);
- }
+ set_point_from_marker (XWINDOW (window)->pointm);
}
DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
set_buffer_internal (old_buffer);
}
else
- XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos));
+ XSETINT (value, BUF_Z (b) - w->window_end_pos);
return value;
}
n->desired_matrix = n->current_matrix = 0;
n->vscroll = 0;
memset (&n->cursor, 0, sizeof (n->cursor));
- memset (&n->last_cursor, 0, sizeof (n->last_cursor));
memset (&n->phys_cursor, 0, sizeof (n->phys_cursor));
+ n->last_cursor_vpos = 0;
n->phys_cursor_type = -1;
n->phys_cursor_width = -1;
n->must_be_updated_p = 0;
n->pseudo_window_p = 0;
- wset_window_end_vpos (n, make_number (0));
- wset_window_end_pos (n, make_number (0));
+ n->window_end_vpos = 0;
+ n->window_end_pos = 0;
n->window_end_valid = 0;
}
block_input ();
if (!FRAME_INITIAL_P (f))
{
- Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+ Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
/* We are going to free the glyph matrices of WINDOW, and with
that we might lose any information about glyph rows that have
frame's up-to-date hook that mouse highlight was overwritten,
so that it will arrange for redisplaying the highlight. */
if (EQ (hlinfo->mouse_face_window, window))
- {
- hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
- hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
- hlinfo->mouse_face_window = Qnil;
- }
+ reset_mouse_highlight (hlinfo);
}
free_window_matrices (r);
bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1));
bset_display_time (b, Fcurrent_time ());
- wset_window_end_pos (w, make_number (0));
- wset_window_end_vpos (w, make_number (0));
- memset (&w->last_cursor, 0, sizeof w->last_cursor);
+ w->window_end_pos = 0;
+ w->window_end_vpos = 0;
+ w->last_cursor_vpos = 0;
if (!(keep_margins_p && samebuf))
{ /* If we're not actually changing the buffer, don't reset hscroll and
if (!keep_margins_p)
{
/* Set left and right marginal area width etc. from buffer. */
-
- /* This may call adjust_window_margins three times, so
- temporarily disable window margins. */
- int save_left = w->left_margin_cols;
- int save_right = w->right_margin_cols;
-
- w->left_margin_cols = 0;
- w->right_margin_cols = 0;
-
- Fset_window_fringes (window,
- BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
- BVAR (b, fringes_outside_margins));
-
- Fset_window_scroll_bars (window,
- BVAR (b, scroll_bar_width),
- BVAR (b, vertical_scroll_bar_type), Qnil);
-
- w->left_margin_cols = save_left;
- w->right_margin_cols = save_right;
-
- Fset_window_margins (window,
- BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
+ set_window_fringes (w, BVAR (b, left_fringe_width),
+ BVAR (b, right_fringe_width),
+ BVAR (b, fringes_outside_margins));
+ set_window_scroll_bars (w, BVAR (b, scroll_bar_width),
+ BVAR (b, vertical_scroll_bar_type), Qnil);
+ set_window_margins (w, BVAR (b, left_margin_cols),
+ BVAR (b, right_margin_cols));
+ apply_window_adjustment (w);
}
if (run_hooks_p)
if (!NILP (Vtemp_buffer_show_function))
call1 (Vtemp_buffer_show_function, buf);
- else
+ else if (WINDOW_LIVE_P (window = display_buffer (buf, Qnil, Qnil)))
{
- window = display_buffer (buf, Qnil, Qnil);
-
if (!EQ (XWINDOW (window)->frame, selected_frame))
Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
Vminibuf_scroll_window = window;
wset_start (w, Fmake_marker ());
wset_pointm (w, Fmake_marker ());
wset_vertical_scroll_bar_type (w, Qt);
- wset_window_end_pos (w, make_number (0));
- wset_window_end_vpos (w, make_number (0));
/* These Lisp fields are marked specially so they're not set to nil by
allocate_window. */
wset_prev_buffers (w, Qnil);
w->left_fringe_width = w->right_fringe_width = -1;
w->phys_cursor_type = -1;
w->phys_cursor_width = -1;
+ w->scroll_bar_width = -1;
w->column_number_displayed = -1;
/* Reset window_list. */
}
n->window_end_valid = 0;
- memset (&n->last_cursor, 0, sizeof n->last_cursor);
+ n->last_cursor_vpos = 0;
/* Get special geometry settings from reference window. */
n->left_margin_cols = r->left_margin_cols;
n->left_fringe_width = r->left_fringe_width;
n->right_fringe_width = r->right_fringe_width;
n->fringes_outside_margins = r->fringes_outside_margins;
- wset_scroll_bar_width (n, r->scroll_bar_width);
+ n->scroll_bar_width = r->scroll_bar_width;
wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type);
/* Directly assign orthogonal coordinates and sizes. */
Lisp_Object saved_windows;
/* All fields above are traced by the GC.
- From `fame-cols' down, the fields are ignored by the GC. */
+ From `frame-cols' down, the fields are ignored by the GC. */
int frame_cols, frame_lines, frame_menu_bar_lines;
int frame_tool_bar_lines;
w->left_fringe_width = XINT (p->left_fringe_width);
w->right_fringe_width = XINT (p->right_fringe_width);
w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
- wset_scroll_bar_width (w, p->scroll_bar_width);
+ w->scroll_bar_width = XINT (p->scroll_bar_width);
wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type);
wset_dedicated (w, p->dedicated);
wset_combination_limit (w, p->combination_limit);
p->left_fringe_width = make_number (w->left_fringe_width);
p->right_fringe_width = make_number (w->right_fringe_width);
p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
- p->scroll_bar_width = w->scroll_bar_width;
+ p->scroll_bar_width = make_number (w->scroll_bar_width);
p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
p->dedicated = w->dedicated;
p->combination_limit = w->combination_limit;
XSETWINDOW_CONFIGURATION (tem, data);
return (tem);
}
+
+/* Called after W's margins, fringes or scroll bars was adjusted. */
+
+static void
+apply_window_adjustment (struct window *w)
+{
+ eassert (w);
+ adjust_window_margins (w);
+ clear_glyph_matrix (w->current_matrix);
+ w->window_end_valid = 0;
+ windows_or_buffers_changed++;
+ adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
+}
+
\f
/***********************************************************************
Marginal Areas
***********************************************************************/
-DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins,
- 2, 3, 0,
- doc: /* Set width of marginal areas of window WINDOW.
-WINDOW must be a live window and defaults to the selected one.
-
-Second arg LEFT-WIDTH specifies the number of character cells to
-reserve for the left marginal area. Optional third arg RIGHT-WIDTH
-does the same for the right marginal area. A nil width parameter
-means no margin.
-
-Return t if any margin was actually changed and nil otherwise. */)
- (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
+static struct window *
+set_window_margins (struct window *w, Lisp_Object left_width,
+ Lisp_Object right_width)
{
- struct window *w = decode_live_window (window);
int left, right;
/* FIXME: what about margins that are too wide? */
-
left = (NILP (left_width) ? 0
: (CHECK_NATNUM (left_width), XINT (left_width)));
right = (NILP (right_width) ? 0
{
w->left_margin_cols = left;
w->right_margin_cols = right;
+ return w;
+ }
+ return NULL;
+}
- adjust_window_margins (w);
+DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins,
+ 2, 3, 0,
+ doc: /* Set width of marginal areas of window WINDOW.
+WINDOW must be a live window and defaults to the selected one.
- ++windows_or_buffers_changed;
- adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
- return Qt;
- }
+Second arg LEFT-WIDTH specifies the number of character cells to
+reserve for the left marginal area. Optional third arg RIGHT-WIDTH
+does the same for the right marginal area. A nil width parameter
+means no margin.
- return Qnil;
+Return t if any margin was actually changed and nil otherwise. */)
+ (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
+{
+ struct window *w = set_window_margins (decode_live_window (window),
+ left_width, right_width);
+ return w ? (apply_window_adjustment (w), Qt) : Qnil;
}
Fringes
***********************************************************************/
-DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
- 2, 4, 0,
- doc: /* Set the fringe widths of window WINDOW.
-WINDOW must be a live window and defaults to the selected one.
-
-Second arg LEFT-WIDTH specifies the number of pixels to reserve for
-the left fringe. Optional third arg RIGHT-WIDTH specifies the right
-fringe width. If a fringe width arg is nil, that means to use the
-frame's default fringe width. Default fringe widths can be set with
-the command `set-fringe-style'.
-If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
-outside of the display margins. By default, fringes are drawn between
-display marginal areas and the text area.
-
-Return t if any fringe was actually changed and nil otherwise. */)
- (Lisp_Object window, Lisp_Object left_width,
- Lisp_Object right_width, Lisp_Object outside_margins)
+static struct window *
+set_window_fringes (struct window *w, Lisp_Object left_width,
+ Lisp_Object right_width, Lisp_Object outside_margins)
{
- struct window *w = decode_live_window (window);
int left, right, outside = !NILP (outside_margins);
left = (NILP (left_width) ? -1
w->left_fringe_width = left;
w->right_fringe_width = right;
w->fringes_outside_margins = outside;
+ return w;
+ }
+ return NULL;
+}
- adjust_window_margins (w);
-
- clear_glyph_matrix (w->current_matrix);
- w->window_end_valid = 0;
+DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
+ 2, 4, 0,
+ doc: /* Set the fringe widths of window WINDOW.
+WINDOW must be a live window and defaults to the selected one.
- ++windows_or_buffers_changed;
- adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
- return Qt;
- }
+Second arg LEFT-WIDTH specifies the number of pixels to reserve for
+the left fringe. Optional third arg RIGHT-WIDTH specifies the right
+fringe width. If a fringe width arg is nil, that means to use the
+frame's default fringe width. Default fringe widths can be set with
+the command `set-fringe-style'.
+If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
+outside of the display margins. By default, fringes are drawn between
+display marginal areas and the text area.
- return Qnil;
+Return t if any fringe was actually changed and nil otherwise. */)
+ (Lisp_Object window, Lisp_Object left_width,
+ Lisp_Object right_width, Lisp_Object outside_margins)
+{
+ struct window *w
+ = set_window_fringes (decode_live_window (window),
+ left_width, right_width, outside_margins);
+ return w ? (apply_window_adjustment (w), Qt) : Qnil;
}
Scroll bars
***********************************************************************/
-DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars,
- Sset_window_scroll_bars, 2, 4, 0,
- doc: /* Set width and type of scroll bars of window WINDOW.
-WINDOW must be a live window and defaults to the selected one.
-
-Second parameter WIDTH specifies the pixel width for the scroll bar;
-this is automatically adjusted to a multiple of the frame column width.
-Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
-bar: left, right, or nil.
-If WIDTH is nil, use the frame's scroll-bar width.
-If VERTICAL-TYPE is t, use the frame's scroll-bar type.
-Fourth parameter HORIZONTAL-TYPE is currently unused. */)
- (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type)
+static struct window *
+set_window_scroll_bars (struct window *w, Lisp_Object width,
+ Lisp_Object vertical_type, Lisp_Object horizontal_type)
{
- struct window *w = decode_live_window (window);
-
- if (!NILP (width))
- {
- CHECK_RANGED_INTEGER (width, 0, INT_MAX);
+ int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width)));
- if (XINT (width) == 0)
- vertical_type = Qnil;
- }
+ if (iwidth == 0)
+ vertical_type = Qnil;
if (!(NILP (vertical_type)
|| EQ (vertical_type, Qleft)
|| EQ (vertical_type, Qt)))
error ("Invalid type of vertical scroll bar");
- if (!EQ (w->scroll_bar_width, width)
+ if (w->scroll_bar_width != iwidth
|| !EQ (w->vertical_scroll_bar_type, vertical_type))
{
- wset_scroll_bar_width (w, width);
+ w->scroll_bar_width = iwidth;
wset_vertical_scroll_bar_type (w, vertical_type);
+ return w;
+ }
+ return NULL;
+}
- adjust_window_margins (w);
-
- clear_glyph_matrix (w->current_matrix);
- w->window_end_valid = 0;
+DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars,
+ Sset_window_scroll_bars, 2, 4, 0,
+ doc: /* Set width and type of scroll bars of window WINDOW.
+WINDOW must be a live window and defaults to the selected one.
- ++windows_or_buffers_changed;
- adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
- }
+Second parameter WIDTH specifies the pixel width for the scroll bar;
+this is automatically adjusted to a multiple of the frame column width.
+Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
+bar: left, right, or nil.
+If WIDTH is nil, use the frame's scroll-bar width.
+If VERTICAL-TYPE is t, use the frame's scroll-bar type.
+Fourth parameter HORIZONTAL-TYPE is currently unused.
- return Qnil;
+Return t if scroll bars was actually changed and nil otherwise. */)
+ (Lisp_Object window, Lisp_Object width,
+ Lisp_Object vertical_type, Lisp_Object horizontal_type)
+{
+ struct window *w
+ = set_window_scroll_bars (decode_live_window (window),
+ width, vertical_type, horizontal_type);
+ return w ? (apply_window_adjustment (w), Qt) : Qnil;
}