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 0adbb8f8a7850cf2672caa6f887c18a73be98258
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Thu Mar 26 10:36:45 2026 +0000

    fill in more builtin typebuf cmds
---
 src/backends/default/ln.c        |   7 +-
 src/backends/default/meson.build |   2 +
 src/backends/default/open.c      | 192 ++++++++++++++++++++++++++++-----------
 3 files changed, 143 insertions(+), 58 deletions(-)

diff --git a/src/backends/default/ln.c b/src/backends/default/ln.c
index 8599876..894a590 100644
--- a/src/backends/default/ln.c
+++ b/src/backends/default/ln.c
@@ -109,13 +109,8 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
   // build up a list of all files to cp and scan them to find how much
   EINA_LIST_FOREACH(files, l, fs)
   {
-    struct stat stsrc, stdst;
-
     if (strlen(fs->src) < 1) goto err2;
-    if (lstat(fs->src, &stsrc) != 0) break;
-    if (lstat(fs->dst, &stdst) != 0) break;
-    if (stsrc.st_dev == stdst.st_dev) status_count(1, fs->src);
-    else if (!fs_scan(fs->src)) goto err2;
+    status_count(1, fs->src);
   }
 
   EINA_LIST_FOREACH(files, l, fs)
diff --git a/src/backends/default/meson.build b/src/backends/default/meson.build
index 11c9d0d..fdc4a58 100644
--- a/src/backends/default/meson.build
+++ b/src/backends/default/meson.build
@@ -15,6 +15,8 @@ executable('open', [
     'open.c',
     'meta.c',
     'icon_override.c',
+    'fs.c',
+    'status.c',
   ],
   include_directories: inc,
   dependencies: deps,
diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index e6067a6..b37c2dc 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -24,6 +24,8 @@
 #include "thumb_check.h"
 #include "esc.h"
 #include "util.h"
+#include "fs.h"
+#include "status.h"
 
 typedef struct
 {
@@ -1844,11 +1846,11 @@ do_handle_cmd(Cmd *c)
       if (args)
         {
           if (!strcmp(args[0], "ls"))
-            {
+            { // built-in cmd: ls [file1]
               _cmd_typebuf_icon_send("std:view-refresh");
               if ((op) && (!strcmp(op, "run")))
-                {
-                  if (args[1]) _typebuf_cd(args[1]);
+                { // only support 1 arg (first) if there - "cd arg"
+                  if ((args[1]) && (args[1][0])) _typebuf_cd(args[1]);
                   else
                     {
                       Eina_Strbuf *strbuf = cmd_strbuf_new("view-refresh");
@@ -1856,8 +1858,8 @@ do_handle_cmd(Cmd *c)
                     }
                 }
               else if ((op) && (!strcmp(op, "complete")))
-                {
-                  if (args[1])
+                { // only support 1 arg (first) if there - "cd arg"
+                  if ((args[1]) && (args[1][0]))
                     { // 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"))
@@ -1867,11 +1869,11 @@ do_handle_cmd(Cmd *c)
                 }
             }
           else if (!strcmp(args[0], "rm"))
-            {
+            { // built-in cmd: rm [-f] file1 [file2] [file3] ...
               _cmd_typebuf_icon_send("std:edit-delete");
               if ((op) && (!strcmp(op, "run")))
                 {
-                  if (args[1])
+                  if ((args[1]) && (args[1][0]))
                     {
                       Eina_List *files = NULL;
                       int        i, j;
@@ -1891,14 +1893,13 @@ do_handle_cmd(Cmd *c)
                                 }
                             }
                           else if (arg[0])
-                            { // its a file - convert to path if needed
+                            { // it's a file - convert to path if needed
                               full = _path_arg_rel_to_abs(arg);
-
                               if (full) files = eina_list_append(files, full);
                             }
                         }
                       if (files)
-                        {
+                        { // only run if we have files
                           if (opt_f) _op_run("rm", files, NULL);
                           else _op_run("trash", files, NULL);
                           EINA_LIST_FREE(files, full) free(full);
@@ -1907,8 +1908,8 @@ do_handle_cmd(Cmd *c)
                 }
               else if ((op) && (!strcmp(op, "complete")))
                 {
-                  if (args[1])
-                    { // we have 1 or more args - assume 1 and its a file/path
+                  if ((args[1]) && (args[1][0]))
+                    { // we have 1 or more args - complete last
                       Eina_Strbuf *strbuf = cmd_strbuf_new("typebuf-set");
                       if (_complete_last_arg_path_cmd(args, strbuf, "string"))
                         cmd_strbuf_print_consume(strbuf);
@@ -1917,42 +1918,37 @@ do_handle_cmd(Cmd *c)
                 }
             }
           else if (!strcmp(args[0], "unlink"))
-            {
+            { // built-in cmd: unlink file1 [file2] [file3] ...
               _cmd_typebuf_icon_send("std:edit-delete");
-//              _op_run("rm", files, NULL);
-            }
-          else if (!strcmp(args[0], "mv"))
-            {
-              _cmd_typebuf_icon_send("std:edit-rename");
-//              _op_run("mv", files, NULL);
-            }
-          else if (!strcmp(args[0], "cp"))
-            {
-              _cmd_typebuf_icon_send("std:edit-copy");
-//              _op_run("cp", files, NULL);
-            }
-          else if (!strcmp(args[0], "ln"))
-            {
-              _cmd_typebuf_icon_send("std:insert-link");
-//              _op_run("ln", files, NULL);
-            }
-          else if (!strcmp(args[0], "cd"))
-            {
-              _cmd_typebuf_icon_send("std:folder");
-              fprintf(stderr, "GGG: cd op=[%s]\n", op);
               if ((op) && (!strcmp(op, "run")))
                 {
-                  if (args[1]) _typebuf_cd(args[1]);
-                  else
+                  if ((args[1]) && (args[1][0]))
                     {
-                      Eina_Strbuf *strbuf = cmd_strbuf_new("view-refresh");
-                      cmd_strbuf_print_consume(strbuf);
+                      Eina_List *files = NULL;
+                      int        i;
+                      char      *full  = NULL;
+
+                      for (i = 1; args[i]; i++)
+                        {
+                          const char *arg = args[i];
+
+                          if (arg[0])
+                            { // it's a file - convert to path if needed
+                              full = _path_arg_rel_to_abs(arg);
+                              if (full) files = eina_list_append(files, full);
+                            }
+                        }
+                      if (files)
+                        { // only run if we have files
+                          _op_run("rm", files, NULL);
+                          EINA_LIST_FREE(files, full) free(full);
+                        }
                     }
                 }
               else if ((op) && (!strcmp(op, "complete")))
-                { // we have 1 or more args - assume 1 and its a file/path
-                  if (args[1])
-                    {
+                {
+                  if ((args[1]) && (args[1][0]))
+                    { // we have 1 or more args - complete last
                       Eina_Strbuf *strbuf = cmd_strbuf_new("typebuf-set");
                       if (_complete_last_arg_path_cmd(args, strbuf, "string"))
                         cmd_strbuf_print_consume(strbuf);
@@ -1960,30 +1956,122 @@ do_handle_cmd(Cmd *c)
                     }
                 }
             }
-          else
-            {
+          else if (!strcmp(args[0], "mv"))
+            { // built-in cmd: mv file1 [file2] [file3] [destdir] ...
+              // built-in cmd: mv file newfilename
+              // at least 2 args. last arg is dest dir OR new filename
+              _cmd_typebuf_icon_send("std:edit-rename");
+//              _op_run("mv", files, NULL);
+            }
+          else if (!strcmp(args[0], "cp"))
+            { // built-in cmd: cp file1 [file2] [file3] [destdir] ...
+              // built-in cmd: cp file copyfilename
+              // at least 2 args. last arg is dest dir OR new copy filename
+              _cmd_typebuf_icon_send("std:edit-copy");
+//              _op_run("cp", files, NULL);
+            }
+          else if (!strcmp(args[0], "ln"))
+            { // built-in cmd: ln [-s] dest linkfilename
+              _cmd_typebuf_icon_send("std:insert-link");
+              if ((op) && (!strcmp(op, "run")))
+                { // must have 2 args minimum
+                  if ((args[1]) && (args[1][0]) && (args[2]) && (args[2][0]))
+                    {
+                      Eina_List *files = NULL;
+                      int        i;
+                      char      *full  = NULL;
+
+                      for (i = 1; args[i]; i++)
+                        {
+                          const char *arg = args[i];
+
+                          if (arg[0] == '-')
+                            { // its an option - ignore it - we ALWAYS do -s
+                            }
+                          else if (arg[0])
+                            { // it's a file - convert to path if needed
+                              if (!files) full = strdup(arg);
+                              else full = _path_arg_rel_to_abs(arg);
+                              if (full) files = eina_list_append(files, full);
+                            }
+                        }
+                      if (files)
+                        { // only run if we have files
+                          char *link_src = eina_list_nth(files, 0);
+                          const char *link_file = eina_list_nth(files, 1);
+                          if (link_src && link_file)
+                            {
+                              status_begin();
+                              status_op("ln");
+                              fs_ln(link_src, link_file, EINA_FALSE);
+                              status_end();
+                            }
+                          EINA_LIST_FREE(files, full) free(full);
+                        }
+                    }
+                }
+              else if ((op) && (!strcmp(op, "complete")))
+                { // complete last arg
+                  if ((args[1]) && (args[1][0]))
+                    { // we have 1 or more args
+                      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], "cd"))
+            { // built-in cmd: cd dirname
+              _cmd_typebuf_icon_send("std:folder");
+              if ((op) && (!strcmp(op, "run")))
+                { // only support 1 arg (first) if there - "cd arg"
+                  if ((args[1]) && (args[1][0])) _typebuf_cd(args[1]);
+                  else
+                    { // no arg - go to $HOME
+                      const char *home = getenv("HOME");
+                      if (home) _typebuf_cd(home);
+                    }
+                }
+              else if ((op) && (!strcmp(op, "complete")))
+                { // complete last arg
+                  if ((args[1]) && (args[1][0]))
+                    { // we have 1 or more args
+                      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 (args[0])
+            { // generic typebuf matches a desktop file for an app/command you
+              // have installed and indexed - thus can be extended with more
+              // installed desktop files that are found/indexed
+              // first try - match by the exec command in the desktop
               Efreet_Desktop *d = efreet_util_desktop_exec_find(args[0]);
 
-              if (!d)
-                {
+              if (!d) // that didn't work
+                { // can't find by exec - let's find by desktop filename/oid
                   char buf[1024];
 
                   snprintf(buf, sizeof(buf), "%s.desktop", args[0]);
                   d = efreet_util_desktop_file_id_find(buf);
                 }
+              // if that didn't work find by name field in desktop
               if (!d) d = efreet_util_desktop_name_find(args[0]);
               if (d)
-                {
+                { // found some desktop matching the cmd
                   Eina_Strbuf *buf2 = eina_strbuf_new();
 
                   if (buf2)
-                    {
+                    { // provide the icon from the desktop file for typebuf
                       eina_strbuf_append_printf(buf2, "std:%s", d->icon);
                       _cmd_typebuf_icon_send(eina_strbuf_string_get(buf2));
                       eina_strbuf_free(buf2);
                     }
                   if ((op) && (!strcmp(op, "run")))
-                    {
+                    { // ask front end to "run" files provided as args
                       Eina_Strbuf *strbuf = cmd_strbuf_new("file-run");
 
                       if (strbuf)
@@ -1992,14 +2080,14 @@ do_handle_cmd(Cmd *c)
                           const char *mondir = ecore_file_monitor_path_get(mon);
 
                           if (mondir)
-                            { // cwd is this dir for cmds
+                            { // cwd is this dir for cmds as if we were in a terminal in cwd
                               cmd_strbuf_append(strbuf, "cwd", mondir);
                               cmd_strbuf_append(strbuf, "open-with",
                                                 d->orig_path);
                               // add args as files
                               for (i = 1; args[i]; i++)
                                 {
-                                  if (args[i][0])
+                                  if ((args[i]) && (args[i][0]))
                                     cmd_strbuf_append(strbuf, "path",args[i]);
                                 }
                               // send file-run cmd back to front end
@@ -2008,8 +2096,8 @@ do_handle_cmd(Cmd *c)
                         }
                     }
                   else if ((op) && (!strcmp(op, "complete")))
-                    {
-                      if (args[1])
+                    { // complete last arg as file
+                      if ((args[1]) && (args[1][0]))
                         {
                           Eina_Strbuf *strbuf = cmd_strbuf_new("typebuf-set");
                           if (_complete_last_arg_path_cmd(args, strbuf,

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

Reply via email to