This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit c11f2df2c009ca4a9ba041999579031bfabebbc3
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Tue Feb 17 20:01:31 2026 +0000

    typebuf - implement rm and rm -f
---
 src/backends/default/open.c | 121 ++++++++++++++++++++++++++++++++------------
 1 file changed, 89 insertions(+), 32 deletions(-)

diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index 38b7097..96036f1 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -1378,6 +1378,44 @@ _meta_update(const char *path)
   _file_mod(path);
 }
 
+static char *
+_path_arg_rel_to_abs(const char *arg)
+{
+  Eina_Strbuf *buf = eina_strbuf_new();
+  const char  *mondir = ecore_file_monitor_path_get(mon);
+  const char  *s;
+  char        *ret = NULL;
+
+  if (!buf) return NULL;
+  if (!mondir) goto done;
+  if (!strncmp(arg, "../", 3))
+    { // ../relatve/path.xx
+      char *tmps = ecore_file_dir_get(mondir);
+
+      if (tmps)
+        {
+          eina_strbuf_append_printf(buf, "%s/%s", tmps, arg + 3);
+          free(tmps);
+        }
+    }
+  else if (arg[0] == '/')
+    { // /full/path/arg.xx
+      eina_strbuf_append(buf, arg);
+    }
+  else
+    { // flename/path/blah.xx
+      const char *append = arg;
+
+      if (!strncmp(arg, "./", 2)) append += 2;
+      eina_strbuf_append_printf(buf, "%s/%s", mondir, append);
+    }
+  s = eina_strbuf_string_get(buf);
+  if (s) ret = strdup(s);
+done:
+  eina_strbuf_free(buf);
+  return ret;
+}
+
 static void
 _typebuf_cd(const char *dest)
 {
@@ -1409,38 +1447,12 @@ done:
 static char *
 _complete_arg_path(char *arg)
 {
-  Eina_Strbuf *buf    = eina_strbuf_new();
   char        *comp   = NULL;
-  const char  *mondir = ecore_file_monitor_path_get(mon);
+  char        *full   = _path_arg_rel_to_abs(arg);
 
-  if (!buf) return NULL;
-  if (!mondir) goto done;
-  if (!strncmp(arg, "../", 3))
-    { // ../relatve/path.xx
-      char *tmps = ecore_file_dir_get(mondir);
-
-      if (tmps)
-        {
-          eina_strbuf_append_printf(buf, "%s/%s", tmps, arg + 3);
-          comp = util_complete(eina_strbuf_string_get(buf), COMPLETE_ANY);
-          free(tmps);
-        }
-    }
-  else if (arg[0] == '/')
-    { // /full/path/arg.xx
-      eina_strbuf_append(buf, arg);
-      comp = util_complete(eina_strbuf_string_get(buf), COMPLETE_ANY);
-    }
-  else
-    { // flename/path/blah.xx
-      const char *append = arg;
-
-      if (!strncmp(arg, "./", 2)) append += 2;
-      eina_strbuf_append_printf(buf, "%s/%s", mondir, append);
-      comp = util_complete(eina_strbuf_string_get(buf), COMPLETE_ANY);
-    }
-done:
-  if (buf) eina_strbuf_free(buf);
+  if (!full) return NULL;
+  comp = util_complete(full, COMPLETE_ANY);
+  free(full);
   return comp;
 }
 
@@ -1462,7 +1474,7 @@ _complete_last_arg_path_cmd(char **args, Eina_Strbuf *cmd, const char *cmd_arg)
 
           if (comp)
             {
-              eina_strbuf_append(buf, comp);
+              eina_strbuf_append_printf(buf, "%s ", comp);
               free(comp);
               ret = EINA_TRUE;
             }
@@ -1799,7 +1811,52 @@ do_handle_cmd(Cmd *c)
           else if (!strcmp(args[0], "rm"))
             {
               _cmd_typebuf_icon_send("std:edit-delete");
-//              _op_run("trash", files, NULL);
+              if ((op) && (!strcmp(op, "run")))
+                {
+                  if (args[1])
+                    {
+                      Eina_List *files = NULL;
+                      int        i, j;
+                      Eina_Bool  opt_f = EINA_FALSE;
+                      char      *full = NULL;
+
+                      for (i = 1; args[i]; i++)
+                        {
+                          const char *arg = args[i];
+
+                          if (arg[0] == '-')
+                            { // its an option
+                              for (j = 1; arg[j]; j++)
+                                {
+                                  if (arg[j] == 'f') opt_f = EINA_TRUE;
+                                  // ignore other: we're fuzzy not 100% compat
+                                }
+                            }
+                          else if (arg[0])
+                            { // its a file - convert to path if needed
+                              full = _path_arg_rel_to_abs(arg);
+
+                              if (full) files = eina_list_append(files, full);
+                            }
+                        }
+                      if (files)
+                        {
+                          if (opt_f) _op_run("rm", files, NULL);
+                          else _op_run("trash", files, NULL);
+                          EINA_LIST_FREE(files, full) free(full);
+                        }
+                    }
+                }
+              else if ((op) && (!strcmp(op, "complete")))
+                {
+                  if (args[1])
+                    { // we have 1 or more args - assume 1 and its a file/path
+                      Eina_Strbuf *strbuf = cmd_strbuf_new("typebuf-set");
+                      if (_complete_last_arg_path_cmd(args, strbuf, "string"))
+                        cmd_strbuf_print_consume(strbuf);
+                      else eina_strbuf_free(strbuf);
+                    }
+                }
             }
           else if (!strcmp(args[0], "unlink"))
             {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to