/* display panel */
if ((mode) && (search[i])) {
int n = (list[i]->nb + windir[i]->nbcols - 1) / windir[i]->nbcols;
- int skip = index_x[i] * n + index_y[i];
- char **_list = (char **) calloc (list[i]->nb, sizeof (char *));
- CHECKALLOC (_list);
- int j;
- for (j = 0; j < list[i]->nb; j++) {
- _list[j] = (list[i]->tab + j)->name;
- }
- skip = find (_list, list[i]->nb, skip, search[i]);
- if (skip != -1) {
- index_x[i] = skip / n;
- index_y[i] = skip % n;
- if (n > windir[i]->ysize) {
- page[i] = index_y[i];
- if (page[i] + windir[i]->ysize > n) {
- page[i] = n - windir[i]->ysize;
- index_y[i] -= page[i];
- } else {
- index_y[i] = 0;
- }
- }
- }
- free (_list);
+ jumpto (list[i], n, windir[i]->ysize, search[i], index_x + i, index_y + i, page + i);
}
displaywindow (windir[i], list[i], page[i], &index_x[i], &index_y[i], &index_f[i], search[i]);
return -1;
}
+void jumpto (list_t *list, int height, int pageheight, char *search, int *x, int *y, int *page)
+{
+ //height: int n = (list[i]->nb + windir[i]->nbcols - 1) / windir[i]->nbcols;
+ int skip = *x * height + *y;
+ char **_list = (char **) calloc (list->nb, sizeof (char *));
+ CHECKALLOC (_list);
+ int j;
+ for (j = 0; j < list->nb; j++) {
+ _list[j] = (list->tab + j)->name;
+ }
+ skip = find (_list, list->nb, skip, search);
+ if (skip != -1) {
+ *x = skip / height;
+ *y = skip % height;
+ if (height > pageheight) {
+ *page = *y;
+ if (*page + pageheight > height) {
+ *page = height - pageheight;
+ *y -= *page;
+ } else {
+ *y = 0;
+ }
+ }
+ }
+
+ free (_list);
+}
+
/* vim: set ts=4 sw=4 et: */
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);
+
#endif /* __FUNCTION_H__ */
/* vim: set ts=4 sw=4 et: */