/* We tell the scroll list that we want pos to be the first shown info We assume that all infos might have changed and update the windows */ void scroll_list_start(scroll_list *sl, int pos){ sl->first_shown_pos = max(0,pos); // pos below 0 makes no sense sl->range_set(pos, pos + sl->num_windows - 1); select(sl, 0); scroll_list_changed(sl); };
/* The position of the currently selected info is decremented, i. e. the selected window is moved up towards the top of the screen If we are already at the top of the window list, we must move the text lines down! */ void scroll_list_up(scroll_list *sl){ if (sl->sel_win > 0) sel_win_up(sl); else { // We want to scroll past the upper end of the window list if ( info_pos(sl, 0) > sl->first_pos){ // valid pos sl->first_shown_pos--; sl->range_set(sl->first_shown_pos, last_shown_pos(sl) ); scroll_list_changed(sl); }; }; };
/* set the total length of the given scroll list -1 means unknown 0 is the empty list. We simply pretend to have one element, otherwise it would make no sense to display the list */ void scroll_list_total_len(scroll_list *sl, int length){ if (length <= 0) sl->last_pos = length; else sl->last_pos = length -1; // We should not have our starting value outside of the limit if ( (sl->last_pos >= 0) && (sl->first_shown_pos > sl->last_pos) ) scroll_list_start(sl, sl->last_pos); // this will call scroll_list_changed(sl) else scroll_list_changed(sl); };
/* We want to show a completely new "page" of infos, i.e. the scroll list first position is decremented by the number of windows in it */ void scroll_list_back(scroll_list *sl){ int new_first; // This will be our new first shown position new_first = sl->first_shown_pos - sl->num_windows; // Maybe it is too low (before start of information) if (new_first < sl->first_pos){ new_first = sl->first_pos; select(sl, 0); // visual clue to the user that we are at top of list }; sl->first_shown_pos = new_first; sl->range_set(sl->first_shown_pos, last_shown_pos(sl) ); scroll_list_changed(sl); };
/* The position of the currently selected info is incremented, i. e. the selected window is moved down towards the bottom of the screen If we are already at the bottom of the window list, we must move the text lines up! */ void scroll_list_down(scroll_list *sl){ if (sl->sel_win < (sl->num_windows - 1)) { // here we must check if we have reached the absolute end of the infos if ( (sl->last_pos < 0) || (scroll_list_selected(sl) < sl->last_pos) ) sel_win_down(sl); } else { // We want to scroll past the lower end of the window list // here we must check if we have reached the absolute end of the infos if ( (sl->last_pos < 0) || (scroll_list_selected(sl) < sl->last_pos) ){ sl->first_shown_pos++; sl->range_set(sl->first_shown_pos, last_shown_pos(sl) ); scroll_list_changed(sl); } }; };
/* We want to show a completely new "page" of infos, i.e. the scroll list first position is incremented by the number of windows in it */ void scroll_list_fwd(scroll_list *sl){ int new_first; // This will be our new first shown position new_first = sl->first_shown_pos+sl->num_windows; // Maybe it is too high (past total end of information) if (sl->last_pos >= 0){ if (new_first > sl->last_pos) return; }; sl->first_shown_pos = new_first; sl->range_set(sl->first_shown_pos, last_shown_pos(sl) ); // Now maybe our selected window is too high if (sl->last_pos >= 0){ if (scroll_list_selected(sl) > sl->last_pos) select(sl, (sl->last_pos - sl->first_shown_pos)); } scroll_list_changed(sl); };
void view_resultnames_changed(){ scroll_list_changed(&result_list); };