/* event loop */
int stop = 0;
int mode = 0;
- char *search[2] = {0};
+ char *search[MAXPANELS] = {0};
while (!stop) {
int len = 0;
elem_t *current = NULL;
/* display panel */
if ((mode) && (search[i])) {
- int n = (list[i]->nb + windir[i]->nbcols - 1) / windir[i]->nbcols;
- jumpto (list[i], n, windir[i]->ysize, search[i], index_x + i, index_y + i, page + i);
+ jumpto (list[i], windir[i]->nbcols, windir[i]->ysize, search[i], &index_x[i], &index_y[i], &page[i], 0);
}
displaywindow (windir[i], list[i], page[i], &index_x[i], &index_y[i], &index_f[i], search[i]);
helpwindow (help1, (width - strmaxlen (help0, '\n')) / 2, 3 * yoffset);
break;
case ALT_N:
+ jumpto (list[panel], windir[panel]->nbcols, windir[panel]->ysize, search[panel], &index_x[panel], &index_y[panel], &page[panel], 1);
break;
case ALT_P:
+ jumpto (list[panel], windir[panel]->nbcols, windir[panel]->ysize, search[panel], &index_x[panel], &index_y[panel], &page[panel], -1);
break;
case ALT_Q:
mode = 0;
return -1;
}
-void jumpto (list_t *list, int height, int pageheight, char *search, int *x, int *y, int *page)
+void jumpto (list_t *list, int nbcols, int pageheight, char *search, int *x, int *y, int *page, int offset)
{
- //height: int n = (list[i]->nb + windir[i]->nbcols - 1) / windir[i]->nbcols;
- int skip = *x * height + *y;
+ int height = (list->nb + nbcols - 1) / nbcols;
+ int skip = *x * height + *y + offset;
+ if (skip >= list->nb) {
+ skip = 0;
+ } else if (skip < 0) {
+ skip = list->nb - 1;
+ }
char **_list = (char **) calloc (list->nb, sizeof (char *));
CHECKALLOC (_list);
int j;
int find (char **lines, int nblines, int skip, char *search);
-void jumpto (list_t *list, int height, int pageheight, char *search, int *x, int *y, int *page);
+void jumpto (list_t *list, int nbcols, int pageheight, char *search, int *x, int *y, int *page, int offset);
#endif /* __FUNCTION_H__ */