diff src/move.c @ 532:7052f11a3dc9

updated for version 7.0150
author vimboss
date Sun, 25 Sep 2005 22:16:38 +0000
parents 8b0ee9d57d7f
children 614e9af68eaa
line wrap: on
line diff
--- a/src/move.c
+++ b/src/move.c
@@ -20,6 +20,7 @@
 #include "vim.h"
 
 static void comp_botline __ARGS((win_T *wp));
+static int scrolljump_value __ARGS((void));
 static int check_top_offset __ARGS((void));
 static void curs_rows __ARGS((win_T *wp, int do_botline));
 static void validate_botline_win __ARGS((win_T *wp));
@@ -249,7 +250,7 @@ update_topline()
 		scroll_cursor_halfway(FALSE);
 	    else
 	    {
-		scroll_cursor_top((int)p_sj, FALSE);
+		scroll_cursor_top(scrolljump_value(), FALSE);
 		check_botline = TRUE;
 	    }
 	}
@@ -341,7 +342,7 @@ update_topline()
 		    line_count = curwin->w_cursor.lnum - curwin->w_botline
 								   + 1 + p_so;
 		if (line_count <= curwin->w_height + 1)
-		    scroll_cursor_bot((int)p_sj, FALSE);
+		    scroll_cursor_bot(scrolljump_value(), FALSE);
 		else
 		    scroll_cursor_halfway(FALSE);
 	    }
@@ -377,6 +378,19 @@ update_topline()
 }
 
 /*
+ * Return the scrolljump value to use for the current window.
+ * When 'scrolljump' is positive use it as-is.
+ * When 'scrolljump' is negative use it as a percentage of the window height.
+ */
+    static int
+scrolljump_value()
+{
+    if (p_sj >= 0)
+	return (int)p_sj;
+    return (curwin->w_height * -p_sj) / 100;
+}
+
+/*
  * Return TRUE when there are not 'scrolloff' lines above the cursor for the
  * current window.
  */