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 0810779d70339bff85fe16e0cabc41c6a6db4928
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Fri Jan 23 17:33:20 2026 +0000

    typebuf - pass cmd mode to backend
---
 src/backends/default/open.c |  25 +++++++--
 src/efm/efm.c               |   9 ++--
 src/efm/efm_structs.h       |  19 +++++--
 src/efm/efm_typebuf.c       | 129 ++++++++++++++++++++++++++++++++------------
 src/efm/efm_util.c          |   1 -
 5 files changed, 136 insertions(+), 47 deletions(-)

diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index d17853c..859b70d 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -1630,11 +1630,30 @@ do_handle_cmd(Cmd *c)
           EINA_LIST_FREE(files, s) eina_stringshare_del(s);
         }
     }
-//  cmd_dump_sterr(c);
+  else if (!strcmp(c->command, "typebuf"))
+    {
+      KEY_WALK_BEGIN
+      {
+        if (!strcmp(key, "op"))
+          {
+            fprintf(stderr, "XXX: ZZZ: typebuf op [%s]\n", data);
+          }
+        else if (!strcmp(key, "line"))
+          {
+            fprintf(stderr, "XXX: ZZZ: typebuf line [%s]\n", data);
+          }
+        else if (!strcmp(key, "cursor-pos"))
+          {
+            int cpos = atoi(data);
+            fprintf(stderr, "XXX: ZZZ: typebuf cpos=%i\n", cpos);
+          }
+      }
+      KEY_WALK_END
+    }
+  //  cmd_dump_sterr(c);
 }
 
-int
-do_init(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
+int do_init(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
 {
   const char *s;
 
diff --git a/src/efm/efm.c b/src/efm/efm.c
index 21a7269..1f64704 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -49,7 +49,7 @@ _cb_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
   Evas_Event_Key_Down *ev      = event_info;
   Eina_Bool            handled = EINA_FALSE;
 
-  if (!sd->typebuf)
+  if (!sd->typebuf_on)
     {
       handled = _efm_key_handle(sd, ev);
       // flag on hold if we use the  event - otherwise pass it on
@@ -76,7 +76,7 @@ _cb_refocus(void *data)
   if (sd->focused)
     {
       printf("XXX:  focus widget\n");
-      if (sd->typebuf) elm_object_focus_set(sd->o_typebuf, EINA_TRUE);
+      if (sd->typebuf_on) elm_object_focus_set(sd->o_typebuf, EINA_TRUE);
       else evas_object_focus_set(sd->o_clip, EINA_TRUE);
       if (sd->key_control) _icon_focus_show(sd);
     }
@@ -753,8 +753,9 @@ _smart_del(Evas_Object *obj)
     ecore_timer_del(st->timer);
     free(st);
   }
-  EINA_LIST_FREE(sd->typebuf_history, s) { eina_stringshare_del(s); }
-  eina_stringshare_replace(&sd->typebuf_restore, NULL);
+  EINA_LIST_FREE(sd->typebuf.history, s) eina_stringshare_del(s);
+  eina_stringshare_replace(&sd->typebuf.restore, NULL);
+  eina_stringshare_replace(&sd->typebuf.prevcmd.line, NULL);
   if (sd->dnd_drop_data)
     {
       free(sd->dnd_drop_data);
diff --git a/src/efm/efm_structs.h b/src/efm/efm_structs.h
index 50855c1..fc4b197 100644
--- a/src/efm/efm_structs.h
+++ b/src/efm/efm_structs.h
@@ -82,10 +82,19 @@ struct _Smart_Data
   Icon      *rename_icon;
   Icon      *dnd_over_icon;
 
-  Eina_Stringshare *typebuf_restore;
-  Eina_List        *typebuf_history;
-  int               typebuf_history_pos;
-  int               typebuf_cursor_ignore;
+  struct
+  {
+    Eina_Stringshare *restore;
+    Eina_List        *history;
+    int               history_pos;
+    int               cursor_ignore;
+    struct
+    {
+      const char *line;
+      int         cursor_pos;
+    } prevcmd;
+  } typebuf;
+  
 
   Evas_Coord      icon_min_w, icon_min_h;
   Evas_Coord      list_min_w, list_min_h;
@@ -139,7 +148,7 @@ struct _Smart_Data
   Eina_Bool detail_down          : 1;
   Eina_Bool listing_done         : 1;
   Eina_Bool listing_done_reblock : 1;
-  Eina_Bool typebuf              : 1;
+  Eina_Bool typebuf_on           : 1;
 
   struct
   {
diff --git a/src/efm/efm_typebuf.c b/src/efm/efm_typebuf.c
index f3ca29e..c3a985d 100644
--- a/src/efm/efm_typebuf.c
+++ b/src/efm/efm_typebuf.c
@@ -1,6 +1,5 @@
 #include "efm_typebuf.h"
 #include "efm_util.h"
-#include "elm_entry_common.h"
 
 static int
 _typebuf_command_detect(const char *str)
@@ -65,6 +64,44 @@ _typebuf_command_str_build_args(Eina_Strbuf *buf, const char *str,
   free(s2);
 }
 
+static void
+_typebuf_cmd_reset(Smart_Data *sd)
+{
+  sd->typebuf.prevcmd.cursor_pos = -1;
+  eina_stringshare_replace(&sd->typebuf.prevcmd.line, NULL);
+}
+
+static void
+_typebuf_cmd_send(Smart_Data *sd, const char *op)
+{
+  Eina_Strbuf *buf  = cmd_strbuf_new("typebuf");
+  char        *s    = _typebuf_command_get(sd);
+  int          cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
+
+  if ((!s) ||
+      ((sd->typebuf.prevcmd.line) &&
+       (!strcmp(s, sd->typebuf.prevcmd.line)) &&
+       (sd->typebuf.prevcmd.cursor_pos == cpos)))
+    {
+      if (buf) eina_strbuf_free(buf);
+      return;
+    }
+  // tell the backend and have it respond
+  if (buf)
+    {
+      char tmp[64];
+
+      cmd_strbuf_append(buf, "op", op);
+      cmd_strbuf_append(buf, "line", s);
+      snprintf(tmp, sizeof(tmp), "%i", cpos);
+      cmd_strbuf_append(buf, "cursor-pos", tmp);
+      cmd_strbuf_exe_consume(buf, sd->exe_open);
+    }
+  sd->typebuf.prevcmd.cursor_pos = cpos;
+  eina_stringshare_replace(&sd->typebuf.prevcmd.line, s);
+  free(s);
+}
+
 static Eina_Bool
 _has_glob(const char *glob)
 {
@@ -96,11 +133,12 @@ _typebuf_update(Smart_Data *sd, const char *str)
 
   if (pos > 0)
     { // we have a cmd
+      _typebuf_cmd_send(sd, "update");
       _efm_sel_none(sd);
-      // now what????
     }
   else
     { // just have a file match glob
+      _typebuf_cmd_reset(sd);
       // XXX: what if we have 1000's of files?
       if (!str) _efm_sel_none(sd);
       else
@@ -131,7 +169,7 @@ _typebuf_format(Smart_Data *sd)
 {
   char *s    = _typebuf_command_get(sd);
   int   cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
-  int pos;
+  int   pos;
 
   printf("XXX: typebuf changed [%s]\n", s);
   pos = _typebuf_command_detect(s);
@@ -149,8 +187,12 @@ _typebuf_format(Smart_Data *sd)
         }
     }
   // strip out markup used to hilight stuff
-  else if (pos <= 0) _typebuf_command_clear(sd, s);
-  // pur cursor back where it was
+  else if (pos <= 0)
+    {
+      _typebuf_command_clear(sd, s);
+      _typebuf_cmd_reset(sd);
+    }
+  // put cursor back where it was
   elm_entry_cursor_pos_set(sd->o_typebuf, cpos);
   _typebuf_update(sd, s);
   free(s);
@@ -164,9 +206,8 @@ _typebuf_complete(Smart_Data *sd)
 
   printf("XXX: complete typebuf\n");
   if (pos > 0)
-    { // cmd mode - ifferent completion
-      int cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
-      printf("XXX: cmd, cpos=%i\n", cpos);
+    { // cmd mode - different completion
+      _typebuf_cmd_send(sd, "complete");
     }
   else
     {
@@ -183,6 +224,7 @@ _typebuf_complete(Smart_Data *sd)
           _icon_select(ic);
           _efm_icon_bring_in(ic);
         }
+      _typebuf_cmd_reset(sd);
     }
   free(s);
 }
@@ -191,26 +233,26 @@ static void
 _typebuf_history(Smart_Data *sd, int dir)
 { // replace typebuf with history typebuf item in direction given
   const char *s;
-  int         len = eina_list_count(sd->typebuf_history);
+  int         len = eina_list_count(sd->typebuf.history);
   Eina_Bool   restore = EINA_FALSE;
 
-  if (sd->typebuf_history_pos == -1)
+  if (sd->typebuf.history_pos == -1)
     {
       char *s = _typebuf_command_get(sd);
-      eina_stringshare_replace(&sd->typebuf_restore, s);
+      eina_stringshare_replace(&sd->typebuf.restore, s);
       printf("XXX: restore = [%s]", s);
       free(s);
     }
-  sd->typebuf_history_pos += dir;
-  if (sd->typebuf_history_pos < 0)
+  sd->typebuf.history_pos += dir;
+  if (sd->typebuf.history_pos < 0)
     {
       restore = EINA_TRUE;
-      sd->typebuf_history_pos = -1;
+      sd->typebuf.history_pos = -1;
       printf("XXX: restore!\n");
     }
-  else if (sd->typebuf_history_pos >= len) sd->typebuf_history_pos = len - 1;
-  if (restore) s = sd->typebuf_restore;
-  else s = eina_list_nth(sd->typebuf_history, sd->typebuf_history_pos);
+  else if (sd->typebuf.history_pos >= len) sd->typebuf.history_pos = len - 1;
+  if (restore) s = sd->typebuf.restore;
+  else s = eina_list_nth(sd->typebuf.history, sd->typebuf.history_pos);
   _typebuf_command_clear(sd, s);
   elm_entry_cursor_end_set(sd->o_typebuf);
   _typebuf_format(sd);
@@ -224,6 +266,7 @@ _cb_typebuf_aborted(void *data, Evas_Object *obj EINA_UNUSED,
 
   printf("XXX: typebuf aborted\n");
   typebuf_del(sd);
+  _typebuf_cmd_reset(sd);
 }
 
 static void
@@ -232,25 +275,35 @@ _cb_typebuf_activated(void *data, Evas_Object *obj EINA_UNUSED,
 {
   Smart_Data *sd  = data;
   char       *s   = _typebuf_command_get(sd);
+  int         pos = _typebuf_command_detect(s);
 
   printf("XXX: typebuf activated\n");
+
   // XXX: "run" the cmd (eg run selected files or run detected cmd)
-  sd->typebuf_history
-    = eina_list_prepend(sd->typebuf_history, eina_stringshare_add(s));
-  while ((int)eina_list_count(sd->typebuf_history) >
+  sd->typebuf.history
+    = eina_list_prepend(sd->typebuf.history, eina_stringshare_add(s));
+  while ((int)eina_list_count(sd->typebuf.history) >
          sd->config.typebuf_history_max)
     {
-      Eina_List *last = eina_list_last(sd->typebuf_history);
+      Eina_List *last = eina_list_last(sd->typebuf.history);
       if (last)
         {
           eina_stringshare_del(last->data);
-          sd->typebuf_history
-            = eina_list_remove_list(sd->typebuf_history, last);
+          sd->typebuf.history
+            = eina_list_remove_list(sd->typebuf.history, last);
         }
     }
+  if (pos > 0)
+    {
+      _typebuf_cmd_send(sd, "run");
+    }
+  else
+    {
+      _efm_icons_run(sd, EINA_FALSE);
+    }
   typebuf_del(sd);
+  _typebuf_cmd_reset(sd);
   free(s);
-  _efm_icons_run(sd, EINA_FALSE);
 }
 
 static void
@@ -265,12 +318,20 @@ _cb_typebuf_cursor(void *data, Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
   Smart_Data *sd   = data;
-  int         cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
-  int         x, y, w, h;
+  char        *s    = _typebuf_command_get(sd);
+  int          pos  = _typebuf_command_detect(s);
+  int          cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
+  int          x, y, w, h;
 
-  if (sd->typebuf_cursor_ignore) return;
+  if (sd->typebuf.cursor_ignore) goto done;
   elm_entry_cursor_geometry_get(sd->o_typebuf, &x, &y, &w, &h);
   printf("XXX: typebuf cursor %i @ %i,%i %ix%i\n", cpos, x, y, w, h);
+  if (pos > 0)
+    {
+      _typebuf_cmd_send(sd, "cursor");
+    }
+done:
+  free(s);
 }
 
 static Eina_Bool
@@ -303,11 +364,11 @@ _cb_typebuf_key(void *data, Evas_Object *obj EINA_UNUSED,
       return EINA_TRUE;
     }
   // allow left/right arrow through if the cursor is not at the start/end
-  sd->typebuf_cursor_ignore++;
+  sd->typebuf.cursor_ignore++;
   elm_entry_cursor_end_set(sd->o_typebuf);
   cpos2 = elm_entry_cursor_pos_get(sd->o_typebuf);
   elm_entry_cursor_pos_set(sd->o_typebuf, cpos);
-  sd->typebuf_cursor_ignore--;
+  sd->typebuf.cursor_ignore--;
   // here if at start or end - swallow left/right that goes out of entry
   if ((cpos == 0) && (!strcmp(ev->key, "Left"))) return EINA_TRUE;
   if ((cpos == cpos2) && (!strcmp(ev->key, "Right"))) return EINA_TRUE;
@@ -327,9 +388,9 @@ _cb_typebuf_size_hint_change(void *data, Evas *evas EINA_UNUSED,
 void
 typebuf_del(Smart_Data *sd)
 {
-  if (!sd->typebuf) return;
+  if (!sd->typebuf_on) return;
   printf("XXX: hide typebuf\n");
-  sd->typebuf = EINA_FALSE;
+  sd->typebuf_on = EINA_FALSE;
   edje_object_signal_emit(sd->o_typebuf_over, "e,state,typebuf,stop", "e");
   evas_object_focus_set(sd->o_clip, EINA_TRUE);
 }
@@ -339,11 +400,11 @@ typebuf_add(Smart_Data *sd, Evas_Event_Key_Down *ev)
 {
   Evas_Object *o;
 
-  if (sd->typebuf) return;
-  sd->typebuf = EINA_TRUE;
+  if (sd->typebuf_on) return;
+  sd->typebuf_on = EINA_TRUE;
   // new entry obj to start fresh
   if (sd->o_typebuf) evas_object_del(sd->o_typebuf);
-  sd->typebuf_history_pos = -1;
+  sd->typebuf.history_pos = -1;
   sd->o_typebuf = o = elm_entry_add(sd->o_scroller);
   elm_object_style_set(o, "blank");
   // when entry changes min size - handle it...
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 646e2e6..30597be 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -2908,7 +2908,6 @@ _efm_sel_glob(Smart_Data *sd, const char *glob, Eina_Bool scroll)
 
   EINA_LIST_FOREACH(sd->icons, l, ic)
   {
-    printf("match[%s] in [%s]\n", glob, ic->info.file);
     if (_glob_match(ic->info.file, glob) || _glob_match(ic->info.label, glob))
       {
         if (!first) first = ic;

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

Reply via email to