]> git.deb.at Git - pkg/abook.git/commitdiff
mouse: improve to new scrolling method implemented in 775cf2c
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Thu, 18 Apr 2013 15:03:24 +0000 (17:03 +0200)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Thu, 18 Apr 2013 15:03:24 +0000 (17:03 +0200)
If the viewport reaches the top/bottom list limit, then further
scroll makes the cursor to move instead of the viewport.

list.c

diff --git a/list.c b/list.c
index 735746733777f07c854c438c3e929f1739b69000..1f0af7942c8fa4515c57ebaeacaec3a37cbed883 100644 (file)
--- a/list.c
+++ b/list.c
@@ -357,8 +357,13 @@ scroll_down()
 void
 scroll_list_up()
 {
-       if(first_list_item <= 0)
+       if(first_list_item <= 0) {
+               if(curitem != 0) {
+                       curitem--;
+                       refresh_list();
+               }
                return;
+       }
 
        first_list_item -= scroll_speed;
        if(first_list_item < 0) {
@@ -374,12 +379,17 @@ scroll_list_up()
 void
 scroll_list_down()
 {
-       if(first_list_item > db_n_items() - 2)
+       if(LAST_LIST_ITEM > db_n_items() - 2) {
+               if(curitem < LAST_LIST_ITEM) {
+                       curitem++;
+                       refresh_list();
+               }
                return;
+       }
 
        first_list_item += scroll_speed;
-       if(first_list_item >= db_n_items()) {
-               first_list_item = db_n_items() - 1;
+       if(LAST_LIST_ITEM > db_n_items() - 1) {
+               first_list_item = db_n_items() - LIST_LINES;
        }
        if(curitem < first_list_item) {
                curitem = first_list_item;