almost working search in panel
authorLaurent Mazet <mazet@softndesign.org>
Tue, 18 Mar 2025 06:45:27 +0000 (07:45 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Tue, 18 Mar 2025 06:45:27 +0000 (07:45 +0100)
fm.c
function.c
function.h

diff --git a/fm.c b/fm.c
index 295afd9aed580aa2ff049fa2ecf5b0c2a7f5d6bd..f4af40e1d8c3a6f1aae16150395f9ea3e1750f27 100644 (file)
--- a/fm.c
+++ b/fm.c
@@ -200,7 +200,7 @@ int main (int argc, char *argv[])
     /* 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;
@@ -238,8 +238,7 @@ int main (int argc, char *argv[])
 
             /* 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]);
 
@@ -282,8 +281,10 @@ int main (int argc, char *argv[])
                     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;
index a527d1ca8bed5fa07f9bb28c9317ec960c1efdb9..82f7380314c9056e57b226b59203fa2b192406c6 100644 (file)
@@ -804,10 +804,15 @@ int find (char **lines, int nblines, int skip, char *search)
     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;
index 4aad0480b6cfe69414aa8db9bb207496d8fd9065..eb674a782e41245736471ba36a66c7549931553d 100644 (file)
@@ -71,7 +71,7 @@ char **splithexalines (char *buffer, int length, int width);
 
 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__ */