#include "nsterm.h"
#endif
+/* Horizontal scrolling has problems with large scroll amounts.
+ It's too slow with long lines, and even with small lines the
+ display can be messed up. Impose a reasonable maximum. */
+enum { HSCROLL_MAX = 100000 };
+
Lisp_Object Qwindowp, Qwindow_live_p;
static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
return make_number (decode_window (window)->hscroll);
}
+/* Set W's horizontal scroll amount to HSCROLL clipped to a reasonable
+ range, returning the new amount as a fixnum. */
+static Lisp_Object
+set_window_hscroll (struct window *w, EMACS_INT hscroll)
+{
+ int new_hscroll = clip_to_bounds (0, hscroll, HSCROLL_MAX);
+
+ /* Prevent redisplay shortcuts when changing the hscroll. */
+ if (w->hscroll != new_hscroll)
+ XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
+
+ w->hscroll = new_hscroll;
+ return make_number (new_hscroll);
+}
+
DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0,
doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
If WINDOW is nil, the selected window is used.
-Return NCOL. NCOL should be zero or positive.
+Clip the number to a reasonable value if out of range.
+Return the new number. NCOL should be zero or positive.
Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
window so that the location of point moves off-window. */)
(Lisp_Object window, Lisp_Object ncol)
{
struct window *w = decode_window (window);
- ptrdiff_t hscroll;
CHECK_NUMBER (ncol);
- hscroll = clip_to_bounds (0, XINT (ncol), PTRDIFF_MAX);
-
- /* Prevent redisplay shortcuts when changing the hscroll. */
- if (w->hscroll != hscroll)
- XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
-
- w->hscroll = hscroll;
- return ncol;
+ return set_window_hscroll (w, XINT (ncol));
}
DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger,
return 1;
}
\f
-static Lisp_Object Fset_window_margins (Lisp_Object, Lisp_Object, Lisp_Object);
-static Lisp_Object Fset_window_fringes (Lisp_Object, Lisp_Object, Lisp_Object,
- Lisp_Object);
-static Lisp_Object Fset_window_scroll_bars (Lisp_Object, Lisp_Object,
- Lisp_Object, Lisp_Object);
-static Lisp_Object Fset_window_vscroll (Lisp_Object, Lisp_Object, Lisp_Object);
-
/* The following three routines are needed for running a window's
configuration change hook. */
static void
o = XWINDOW (window);
p = allocate_window ();
- memcpy ((char *) p + sizeof (struct vectorlike_header),
+ memcpy ((char *) p + sizeof (struct vectorlike_header),
(char *) o + sizeof (struct vectorlike_header),
sizeof (Lisp_Object) * VECSIZE (struct window));
XSETWINDOW (parent, p);
by this function. This happens in an interactive call. */)
(register Lisp_Object arg, Lisp_Object set_minimum)
{
- Lisp_Object result;
- ptrdiff_t hscroll;
struct window *w = XWINDOW (selected_window);
-
- if (NILP (arg))
- XSETFASTINT (arg, window_body_cols (w) - 2);
- else
- arg = Fprefix_numeric_value (arg);
-
- hscroll = w->hscroll + XINT (arg);
- result = Fset_window_hscroll (selected_window, make_number (hscroll));
+ EMACS_INT requested_arg = (NILP (arg)
+ ? window_body_cols (w) - 2
+ : XINT (Fprefix_numeric_value (arg)));
+ Lisp_Object result = set_window_hscroll (w, w->hscroll + requested_arg);
if (!NILP (set_minimum))
w->min_hscroll = w->hscroll;
by this function. This happens in an interactive call. */)
(register Lisp_Object arg, Lisp_Object set_minimum)
{
- Lisp_Object result;
- ptrdiff_t hscroll;
struct window *w = XWINDOW (selected_window);
-
- if (NILP (arg))
- XSETFASTINT (arg, window_body_cols (w) - 2);
- else
- arg = Fprefix_numeric_value (arg);
-
- hscroll = w->hscroll - XINT (arg);
- result = Fset_window_hscroll (selected_window, make_number (hscroll));
+ EMACS_INT requested_arg = (NILP (arg)
+ ? window_body_cols (w) - 2
+ : XINT (Fprefix_numeric_value (arg)));
+ Lisp_Object result = set_window_hscroll (w, w->hscroll - requested_arg);
if (!NILP (set_minimum))
w->min_hscroll = w->hscroll;
w->right_margin_cols = p->right_margin_cols;
w->left_fringe_width = p->left_fringe_width;
w->right_fringe_width = p->right_fringe_width;
- w->fringes_outside_margins = p->fringes_outside_margins;
+ w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
w->scroll_bar_width = p->scroll_bar_width;
w->vertical_scroll_bar_type = p->vertical_scroll_bar_type;
w->dedicated = p->dedicated;
p->right_margin_cols = w->right_margin_cols;
p->left_fringe_width = w->left_fringe_width;
p->right_fringe_width = w->right_fringe_width;
- p->fringes_outside_margins = w->fringes_outside_margins;
+ p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
p->scroll_bar_width = w->scroll_bar_width;
p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
p->dedicated = w->dedicated;
(Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins)
{
struct window *w = decode_window (window);
+ int outside = !NILP (outside_margins);
if (!NILP (left_width))
CHECK_NATNUM (left_width);
if (FRAME_WINDOW_P (WINDOW_XFRAME (w))
&& (!EQ (w->left_fringe_width, left_width)
|| !EQ (w->right_fringe_width, right_width)
- || !EQ (w->fringes_outside_margins, outside_margins)))
+ || w->fringes_outside_margins != outside))
{
w->left_fringe_width = left_width;
w->right_fringe_width = right_width;
- w->fringes_outside_margins = outside_margins;
+ w->fringes_outside_margins = outside;
adjust_window_margins (w);
if (!NILP (width))
{
- CHECK_RANGED_INTEGER (0, width, INT_MAX);
+ CHECK_RANGED_INTEGER (width, 0, INT_MAX);
if (XINT (width) == 0)
vertical_type = Qnil;