diplay working
authorLaurent Mazet <mazet@softndesign.org>
Mon, 30 Dec 2024 22:27:48 +0000 (23:27 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Mon, 30 Dec 2024 22:27:48 +0000 (23:27 +0100)
display.c

index 194e1bd4b277eca23bc31255e525d8f7338f9754..bf9244b2294d4afe68cdd7103720ccd0fbf74299 100644 (file)
--- a/display.c
+++ b/display.c
@@ -120,12 +120,41 @@ int helpwindow (char *msg, int xoffset, int yoffset)
 void displaywindow (window_t *win, list_t *list, int index)
 {
     int i;
-    int nbcols = win->xsize / list->width;
+    int nbcols = win->xsize / (list->width + 1);
+    int width = win->xsize / nbcols;
     int n = (list->nb + nbcols - 1) / nbcols;
     for (i = 0; i < list->nb; i++) {
         int j = (i % n) - index;
         if ((j >= 0) && (j < win->ysize)) {
-            mvaddstr (win->yoffset + j, win->xoffset + (i % n) * list->width, (list->tab + i)->name);
+            elem_t *elem = list->tab + i;
+            switch (elem->type) {
+            case type_unkn_e:
+               set_color (black);
+               break;
+            case type_block_e:
+               set_color (yellow);
+               break;
+            case type_char_e:
+               set_color (magenta);
+               break;
+            case type_dir_e:
+               set_color (blue);
+               break;
+            case type_pipe_e:
+               set_color (red);
+               break;
+            case type_symb_e:
+               set_color (cyan);
+               break;
+            case type_reg_e:
+               set_color (white);
+               break;
+            case type_socket_e:
+               set_color (red);
+               break;
+            }
+            mvaddstr (win->yoffset + j, win->xoffset + (i / n) * (width + 1), elem->name);
+            set_color (white);
         }
     }
 }