GNU Info

Info Node: (elisp)Horizontal Scrolling

(elisp)Horizontal Scrolling


Next: Size of Window Prev: Vertical Scrolling Up: Windows
Enter node , (file) or (file)node

Horizontal Scrolling
====================

   "Horizontal scrolling" means shifting the image in the window left
or right by a specified multiple of the normal character width.  Each
window has a "vertical scroll position", which is a number, never less
than zero.  It specifies how far to shift the contents left.  Shifting
the window contents left generally makes all or part of some characters
disappear off the left, and all or part of some other characters appear
at the right.  The usual value is zero.

   The horizontal scroll position is measured in units of the normal
character width, which is the width of space in the default font.  Thus,
if the value is 5, that means the window contents are scrolled left by 5
times the normal character width.  How many characters actually
disappear off to the left depends on their width, and could vary from
line to line.

   Because we read from side to side in the "inner loop", and from top
to bottom in the "outer loop", the effect of horizontal scrolling is
not like that of textual or vertical scrolling.  Textual scrolling
involves selection of a portion of text to display, and vertical
scrolling moves the window contents contiguously; but horizontal
scrolling causes part of _each line_ to go off screen.

   Usually, no horizontal scrolling is in effect; then the leftmost
column is at the left edge of the window.  In this state, scrolling to
the right is meaningless, since there is no data to the left of the edge
to be revealed by it; so this is not allowed.  Scrolling to the left is
allowed; it scrolls the first columns of text off the edge of the window
and can reveal additional columns on the right that were truncated
before.  Once a window has a nonzero amount of leftward horizontal
scrolling, you can scroll it back to the right, but only so far as to
reduce the net horizontal scroll to zero.  There is no limit to how far
left you can scroll, but eventually all the text will disappear off the
left edge.

   In Emacs 21, redisplay automatically alters the horizontal scrolling
of a window as necessary to ensure that point is always visible, if
`automatic-hscrolling' is set.  However, you can still set the
horizontal scrolling value explicitly.  The value you specify serves as
a lower bound for automatic scrolling, i.e. automatic scrolling will
not scroll a window to a column less than the specified one.

 - Command: scroll-left &optional count
     This function scrolls the selected window COUNT columns to the
     left (or to the right if COUNT is negative).  The default for
     COUNT is the window width, minus 2.

     The return value is the total amount of leftward horizontal
     scrolling in effect after the change--just like the value returned
     by `window-hscroll' (below).

 - Command: scroll-right &optional count
     This function scrolls the selected window COUNT columns to the
     right (or to the left if COUNT is negative).  The default for
     COUNT is the window width, minus 2.

     The return value is the total amount of leftward horizontal
     scrolling in effect after the change--just like the value returned
     by `window-hscroll' (below).

     Once you scroll a window as far right as it can go, back to its
     normal position where the total leftward scrolling is zero,
     attempts to scroll any farther right have no effect.

 - Function: window-hscroll &optional window
     This function returns the total leftward horizontal scrolling of
     WINDOW--the number of columns by which the text in WINDOW is
     scrolled left past the left margin.

     The value is never negative.  It is zero when no horizontal
     scrolling has been done in WINDOW (which is usually the case).

     If WINDOW is `nil', the selected window is used.

          (window-hscroll)
               => 0
          (scroll-left 5)
               => 5
          (window-hscroll)
               => 5

 - Function: set-window-hscroll window columns
     This function sets the number of columns from the left margin that
     WINDOW is scrolled from the value of COLUMNS.  The argument
     COLUMNS should be zero or positive; if not, it is taken as zero.
     Fractional values of COLUMNS are not supported at present.

     The value returned is COLUMNS.

          (set-window-hscroll (selected-window) 10)
               => 10

   Here is how you can determine whether a given position POSITION is
off the screen due to horizontal scrolling:

     (defun hscroll-on-screen (window position)
       (save-excursion
         (goto-char position)
         (and
          (>= (- (current-column) (window-hscroll window)) 0)
          (< (- (current-column) (window-hscroll window))
             (window-width window)))))


automatically generated by info2www version 1.2.2.9