commit fa0f9ddc93153f2953102ce2787b4040be24c8dc
parent 3ef50f06f86a962b465d50b7ffb6909436b69685
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Fri, 16 Jul 2021 03:54:19 +0530
Remove from selection when hovered entry is deleted
Diffstat:
| M | src/nnn.c | | | 44 | ++++++++++++++++++++++++++++++++------------ |
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git 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())