Document sun change.
[bpt/emacs.git] / src / indent.c
index 3f3745a..44e3f14 100644 (file)
@@ -22,7 +22,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "lisp.h"
 #include "buffer.h"
 #include "indent.h"
-#include "screen.h"
+#include "frame.h"
 #include "window.h"
 #include "termchar.h"
 #include "termopts.h"
@@ -70,8 +70,8 @@ This is calculated by adding together the widths of all the displayed\n\
 representations of the character between the start of the previous line\n\
 and point.  (eg control characters will have a width of 2 or 4, tabs\n\
 will have a variable width)\n\
-Ignores finite width of screen, which means that this function may return\n\
-values greater than (screen-width).\n\
+Ignores finite width of frame, which means that this function may return\n\
+values greater than (frame-width).\n\
 Whether the line is visible (if `selective-display' is t) has no effect;\n\
 however, ^M is treated as end of line when `selective-display' is t.")
   ()
@@ -116,7 +116,7 @@ current_column ()
   else
     stop = GAP_END_ADDR;
 
-  if (tab_width <= 0 || tab_width > 20) tab_width = 8;
+  if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
 
   col = 0, tab_seen = 0, post_tab = 0;
 
@@ -137,7 +137,7 @@ current_column ()
 
       c = *--ptr;
       if (c >= 040 && c < 0177
-         && (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String))
+         && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector))
        {
          col++;
        }
@@ -154,8 +154,8 @@ current_column ()
          col = 0;
          tab_seen = 1;
        }
-      else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String)
-       col += XSTRING (DISP_CHAR_ROPE (dp, c))->size / sizeof (GLYPH);
+      else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector)
+       col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
       else
        col += (ctl_arrow && c < 0200) ? 2 : 4;
     }
@@ -197,7 +197,7 @@ even if that goes past COLUMN; by default, MIN is zero.")
   if (fromcol == mincol)
     return make_number (mincol);
 
-  if (tab_width <= 0 || tab_width > 20) tab_width = 8;
+  if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
 
   if (indent_tabs_mode)
     {
@@ -243,7 +243,7 @@ position_indentation (pos)
   register unsigned char *p;
   register unsigned char *stop;
   
-  if (tab_width <= 0 || tab_width > 20) tab_width = 8;
+  if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
   
   stop = &FETCH_CHAR (BUFFER_CEILING_OF (pos)) + 1;
   p = &FETCH_CHAR (pos);
@@ -277,7 +277,8 @@ The column of a character is calculated by adding together the widths\n\
 as displayed of the previous characters in the line.\n\
 This function ignores line-continuation;\n\
 there is no upper limit on the column number a character can have\n\
-and horizontal scrolling has no effect.\n\n\
+and horizontal scrolling has no effect.\n\
+\n\
 If specified column is within a character, point goes after that character.\n\
 If it's past end of line, point goes to end of line.\n\n\
 A non-nil second (optional) argument FORCE means, if the line\n\
@@ -298,7 +299,7 @@ and if COLUMN is in the middle of a tab character, change it to spaces.")
   int prev_col;
   int c;
 
-  if (tab_width <= 0 || tab_width > 20) tab_width = 8;
+  if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
   CHECK_NATNUM (column, 0);
   goal = XINT (column);
 
@@ -328,8 +329,8 @@ and if COLUMN is in the middle of a tab character, change it to spaces.")
          col += tab_width;
          col = col / tab_width * tab_width;
        }
-      else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String)
-       col += XSTRING (DISP_CHAR_ROPE (dp, c))->size / sizeof (GLYPH);
+      else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector)
+       col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
       else if (ctl_arrow && (c < 040 || c == 0177))
         col++;
       else if (c < 040 || c >= 0177)
@@ -355,7 +356,7 @@ and if COLUMN is in the middle of a tab character, change it to spaces.")
 
   /* If line ends prematurely, add space to the end.  */
   if (col < goal && !NILP (force))
-    Findent_to (make_number (col = goal));
+    Findent_to (make_number (col = goal), Qnil);
 
   last_known_column = col;
   last_known_column_point = point;
@@ -395,15 +396,23 @@ struct position val_compute_motion;
    When displaying in window w, a typical formula for WIDTH is:
 
        window_width - 1
-        - (window_width + window_left != screen_width)
+        - (has_vertical_scroll_bars
+           ? VERTICAL_SCROLL_BAR_WIDTH
+           : (window_width + window_left != frame_width))
 
        where
          window_width is XFASTINT (w->width),
          window_left is XFASTINT (w->left),
-         and screen_width = SCREEN_WIDTH (XSCREEN (window->screen))    
+         has_vertical_scroll_bars is
+           FRAME_HAS_VERTICAL_SCROLL_BARS (XFRAME (WINDOW_FRAME (window)))
+         and frame_width = FRAME_WIDTH (XFRAME (window->frame))
 
-   This accounts for the continuation-line backslashes, and the window
-   borders if the window is split vertically.  */
+       Or,
+         window_internal_width (w) - 1
+
+   The `-1' accounts for the continuation-line backslashes; the rest
+   accounts for window borders if the window is split vertically, and
+   the scroll bars if the frame supports them.  */
 
 struct position *
 compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, tab_offset)
@@ -425,10 +434,10 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
        : !NILP (current_buffer->selective_display) ? -1 : 0;
   int prev_vpos, prev_hpos;
   int selective_rlen
-    = (selective && dp && XTYPE (DISP_INVIS_ROPE (dp)) == Lisp_String
-       ? XSTRING (DISP_INVIS_ROPE (dp))->size / sizeof (GLYPH) : 0);
+    = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector
+       ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0);
 
-  if (tab_width <= 0 || tab_width > 20) tab_width = 8;
+  if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
   for (pos = from; pos < to; pos++)
     {
       /* Stop if past the target screen position.  */
@@ -441,7 +450,7 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
 
       c = FETCH_CHAR (pos);
       if (c >= 040 && c < 0177
-         && (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String))
+         && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector))
        hpos++;
       else if (c == '\t')
        {
@@ -497,8 +506,8 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
                hpos = width;
            }
        }
-      else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String)
-       hpos += XSTRING (DISP_CHAR_ROPE (dp, c))->size / sizeof (GLYPH);
+      else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector)
+       hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
       else
        hpos += (ctl_arrow && c < 0200) ? 2 : 4;
 
@@ -513,7 +522,7 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
            break;
          if (hscroll
              || (truncate_partial_width_windows
-                 && width + 1 < SCREEN_WIDTH (selected_screen))
+                 && width + 1 < FRAME_WIDTH (selected_frame))
              || !NILP (current_buffer->truncate_lines))
            {
              /* Truncating: skip to newline.  */
@@ -559,9 +568,7 @@ pos_tab_offset (w, pos)
 {
   int opoint = point;
   int col;
-  int width = XFASTINT (w->width) - 1
-    - (XFASTINT (w->width) + XFASTINT (w->left)
-       != SCREEN_WIDTH (XSCREEN (w->screen)));
+  int width = window_internal_width (w) - 1;
 
   if (pos == BEGV || FETCH_CHAR (pos - 1) == '\n')
     return 0;
@@ -676,9 +683,7 @@ Returns number of lines moved; may be closer to zero than LINES\n\
 {
   struct position pos;
   register struct window *w = XWINDOW (selected_window);
-  int width = XFASTINT (w->width) - 1
-    - (XFASTINT (w->width) + XFASTINT (w->left)
-       != SCREEN_WIDTH (XSCREEN (w->screen)));
+  int width = window_internal_width (w) - 1;
 
   CHECK_NUMBER (lines, 0);