X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=list.c;h=1f0af7942c8fa4515c57ebaeacaec3a37cbed883;hb=5840fceb1f91b066a4c4361b0599c417aa111386;hp=9eb4edeb83add05ea4b7257437afd25b482ab7eb;hpb=42ef9a789644980d33e1731aa44055edb66f2388;p=pkg%2Fabook.git diff --git a/list.c b/list.c index 9eb4ede..1f0af79 100644 --- a/list.c +++ b/list.c @@ -24,6 +24,7 @@ int curitem = -1; int first_list_item = -1; +int scroll_speed = 2; char *selected = NULL; extern abook_field_list *fields_list; @@ -130,6 +131,7 @@ init_list() { list = newwin(LIST_LINES, LIST_COLS, LIST_TOP, 0); scrollok(list, TRUE); + scroll_speed = abs(opt_get_int(INT_SCROLL_SPEED)); } void @@ -352,6 +354,49 @@ scroll_down() refresh_list(); } +void +scroll_list_up() +{ + if(first_list_item <= 0) { + if(curitem != 0) { + curitem--; + refresh_list(); + } + return; + } + + first_list_item -= scroll_speed; + if(first_list_item < 0) { + first_list_item = 0; + } + if(curitem > LAST_LIST_ITEM) { + curitem = LAST_LIST_ITEM; + } + + refresh_list(); +} + +void +scroll_list_down() +{ + if(LAST_LIST_ITEM > db_n_items() - 2) { + if(curitem < LAST_LIST_ITEM) { + curitem++; + refresh_list(); + } + return; + } + + first_list_item += scroll_speed; + 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; + } + + refresh_list(); +} void page_up() @@ -498,6 +543,12 @@ list_get_curitem() return curitem; } +int +list_get_firstitem() +{ + return first_list_item; +} + void list_set_curitem(int i) {