]> Sergey Matveev's repositories - nnn.git/commitdiff
Remove from selection when hovered entry is deleted
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 15 Jul 2021 22:24:19 +0000 (03:54 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 15 Jul 2021 23:14:01 +0000 (04:44 +0530)
src/nnn.c

index 1ab79d201f6abeb83ab54dc68380a2576b136e1f..598d78db11d9a5c1df58eadd364ee891f23b8168 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2373,6 +2373,17 @@ static bool xdiraccess(const char *path)
        return TRUE;
 }
 
+static bool plugscript(const char *plugin, uchar_t flags)
+{
+       mkpath(plgpath, plugin, g_buf);
+       if (!access(g_buf, X_OK)) {
+               spawn(g_buf, NULL, NULL, NULL, flags);
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void opstr(char *buf, char *op)
 {
        snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s \"$0\" \"$@\" . < /dev/tty' < %s",
@@ -2396,7 +2407,7 @@ static bool rmmulstr(char *buf)
 }
 
 /* Returns TRUE if file is removed, else FALSE */
-static bool xrm(char *fpath)
+static bool xrm(char * const fpath)
 {
        char r = confirm_force(FALSE);
        if (!r)
@@ -2414,6 +2425,24 @@ static bool xrm(char *fpath)
        return (access(fpath, F_OK) == -1); /* File is removed */
 }
 
+static void xrmfromsel(char *path, char *fpath)
+{
+       bool selected = TRUE;
+
+       if ((pdents[cur].flags & DIR_OR_DIRLNK) && scanselforpath(fpath, FALSE))
+               clearselection();
+       else if (pdents[cur].flags & FILE_SELECTED) {
+               --nselected;
+               rmfromselbuf(mkpath(path, pdents[cur].name, g_buf));
+       } else
+               selected = FALSE;
+
+#ifndef NOX11
+       if (selected && cfg.x11)
+               plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE);
+#endif
+}
+
 static uint_t lines_in_file(int fd, char *buf, size_t buflen)
 {
        ssize_t len;
@@ -5145,17 +5174,6 @@ static bool run_plugin(char **path, const char *file, char *runfile, char **last
        return TRUE;
 }
 
-static bool plugscript(const char *plugin, uchar_t flags)
-{
-       mkpath(plgpath, plugin, g_buf);
-       if (!access(g_buf, X_OK)) {
-               spawn(g_buf, NULL, NULL, NULL, flags);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
 static bool launch_app(char *newpath)
 {
        int r = F_NORMAL;
@@ -7156,6 +7174,8 @@ nochange:
                                        if (!xrm(newpath))
                                                continue;
 
+                                       xrmfromsel(tmp, newpath);
+
                                        copynextname(lastname);
 
                                        if (cfg.filtermode || filterset())