diff src/popupmenu.c @ 610:cd3689efd90a v7.0173

updated for version 7.0173
author vimboss
date Sun, 18 Dec 2005 22:10:00 +0000
parents 7a10f094c6bb
children 2392a6da4aa4
line wrap: on
line diff
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -237,12 +237,28 @@ pum_set_selected(n)
 
     if (pum_selected >= 0)
     {
-	if (pum_first > pum_selected)
-	    /* scroll down */
-	    pum_first = pum_selected;
-	else if (pum_first < pum_selected - pum_height + 1)
-	    /* scroll up */
-	    pum_first = pum_selected - pum_height + 1;
+	if (pum_first > pum_selected - 4)
+	{
+	    /* scroll down; when we did a jump it's probably a PageUp then
+	     * scroll to put the selected entry at the bottom */
+	    if (pum_first > pum_selected - 2)
+	    {
+		pum_first = pum_selected - pum_height + 1;
+		if (pum_first < 0)
+		    pum_first = 0;
+	    }
+	    else
+		pum_first = pum_selected;
+	}
+	else if (pum_first < pum_selected - pum_height + 5)
+	{
+	    /* scroll up; when we did a jump it's probably a PageDown then
+	     * scroll to put the selected entry at the top */
+	    if (pum_first < pum_selected - pum_height + 1 + 2)
+		pum_first = pum_selected;
+	    else
+		pum_first = pum_selected - pum_height + 1;
+	}
 
 	if (pum_height > 6)
 	{
@@ -298,4 +314,14 @@ pum_visible()
     return pum_array != NULL;
 }
 
+/*
+ * Return the height of the popup menu, the number of entries visible.
+ * Only valid when pum_visible() returns TRUE!
+ */
+    int
+pum_get_height()
+{
+    return pum_height;
+}
+
 #endif