wip copy/delete/rename
authorLaurent Mazet <mazet@softndesign.org>
Sun, 12 Jan 2025 14:05:05 +0000 (15:05 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Sun, 12 Jan 2025 14:05:05 +0000 (15:05 +0100)
fm.c
function.c
function.h

diff --git a/fm.c b/fm.c
index f44624480a37cde347faa6c7ebd1225283974616..f6bda6f721767f9c3099dc75156cc695237c0d64 100644 (file)
--- a/fm.c
+++ b/fm.c
@@ -305,8 +305,35 @@ int main (int argc, char *argv[])
             switch (getch ()) {
 #endif /* PDCURSES */
             case ALT_C: /* copy */
+                for (i = 0; i < list[panel]->nb; i++) {
+                    current = list[panel]->tab + i;
+                    if (current->selected) {
+                        char *src = strdupcat (dirname[panel], SEPARATOR, current->name);
+                        char *dest = dirname[(panel + 1 ) % MAXPANELS];
+                        if (processcopy (dest, src) != 0) {
+                            char *buf = strdupcat ("Can't copy '", src, "' to '", dest, "'", NULL);
+                            msgwindow (buf, winscreen, 0);
+                            getch ();
+                            free (buf);
+                        }
+                        free (src);
+                    }
+                }
                 break;
             case ALT_D: /* delete */
+                for (i = 0; i < list[panel]->nb; i++) {
+                    current = list[panel]->tab + i;
+                    if (current->selected) {
+                        char *src = strdupcat (dirname[panel], SEPARATOR, current->name);
+                        if (processdelete (src) != 0) {
+                            char *buf = strdupcat ("Can't delete '", src, "'", NULL);
+                            msgwindow (buf, winscreen, 0);
+                            getch ();
+                            free (buf);
+                        }
+                        free (src);
+                    }
+                }
                 break;
             case ALT_F: /* filter */
                 string = getwindow ("Set filter", winscreen, MAXFILTER / 2, MAXFILTER, NULL);
@@ -322,6 +349,20 @@ int main (int argc, char *argv[])
                 }
                 break;
             case ALT_M: /* move */
+                for (i = 0; i < list[panel]->nb; i++) {
+                    current = list[panel]->tab + i;
+                    if (current->selected) {
+                        char *src = strdupcat (dirname[panel], SEPARATOR, current->name);
+                        char *dest = dirname[(panel + 1 ) % MAXPANELS];
+                        if (processmove (dest, src) != 0) {
+                            char *buf = strdupcat ("Can't copy '", src, "' to '", dest, "'", NULL);
+                            msgwindow (buf, winscreen, 0);
+                            getch ();
+                            free (buf);
+                        }
+                        free (src);
+                    }
+                }
                 break;
             case ALT_N: /* new dir */
                 string = getwindow ("New directory", winscreen, MAXFNAME / 2, MAXFNAME, NULL);
@@ -363,7 +404,9 @@ int main (int argc, char *argv[])
                 break;
             case ALT_S: /* select */
                 current = list[panel]->tab + windir[panel]->index;
-                current->selected = (current->selected) ? 0 : 1;
+                if (strcmp (current->name, "..") != 0) {
+                    current->selected = (current->selected) ? 0 : 1;
+                }
                 break;
             case ALT_V: /* view */
                 break;
index 5bf83e9b6768bf8f12a7234bd47fc8584465c96c..7258ca92caf4bef987a6db527d87844c40b9c05b 100644 (file)
@@ -17,8 +17,6 @@
 
 #include "function.h"
 
-#define SEPARATOR "/"
-
 int strmaxlen (char *str, char ch)
 {
     int len = 0;
@@ -363,4 +361,19 @@ int filterlist (list_t *list, char *regex)
     return rc;
 }
 
+int processcopy (char *dest, char *src)
+{
+    return 0;
+}
+
+int processdelete (char *src)
+{
+    return 0;
+}
+
+int processmove (char *dest, char *src)
+{
+    return 0;
+}
+
 /* vim: set ts=4 sw=4 et: */
index 838f0ce8a8ac17ef751efb5e437caba3d8c2071d..ea8440a20712cc641a87047d082d90e27caface3 100644 (file)
@@ -11,6 +11,8 @@
         } \
     } while (0)
 
+#define SEPARATOR "/"
+
 #define max(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
 
 #define min(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
@@ -37,6 +39,12 @@ void freewindow (window_t *win);
 
 int filterlist (list_t *list, char *regex);
 
+int processcopy (char *dest, char *src);
+
+int processdelete (char *src);
+
+int processmove (char *dest, char *src);
+
 #endif /* __FUNCTION_H__ */
 
 /* vim: set ts=4 sw=4 et: */