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

git pushed a commit to branch tytab
in repository terminology.

View the commit online.

commit ad796d3d6f1a32826bf1e4e75a02f0308cef0714
Author: [email protected] <[email protected]>
AuthorDate: Mon Mar 30 09:21:29 2026 -0600

    refactor: extract helpers to reduce duplication in _cb_command
    
    Extract _term_new_solo() and _container_tab_attach_point() from the
    tt escape handler. Removes ~60 lines of duplicated term creation and
    tab attach point logic.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/win.c | 146 +++++++++++++++++++++++++---------------------------------
 1 file changed, 63 insertions(+), 83 deletions(-)

diff --git a/src/bin/win.c b/src/bin/win.c
index 7afa5b42..75f9fb11 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -6749,6 +6749,47 @@ _term_id_generate(void)
    return id;
 }
 
+static Term_Container *
+_term_new_solo(Win *wn, const char *cmd, const char *wdir)
+{
+   Term *tm;
+   Term_Container *tc;
+
+   tm = term_new(wn, wn->config, cmd, wn->config->login_shell,
+                 wdir, 80, 24, EINA_FALSE, NULL);
+   if (!tm) return NULL;
+   tc = _solo_new(tm, wn);
+   evas_object_data_set(tm->termio, "sizedone", tm->termio);
+   return tc;
+}
+
+static Term_Container *
+_container_tab_attach_point(Term_Container *target)
+{
+   if (target->type == TERM_CONTAINER_TYPE_SOLO)
+     {
+        if (target->parent->type != TERM_CONTAINER_TYPE_TABS)
+          _tabs_new(target, target->parent);
+        return target->parent;
+     }
+   else if (target->type == TERM_CONTAINER_TYPE_TABS)
+     {
+        return target;
+     }
+   else
+     {
+        Term *tm_first = target->term_first(target);
+        if (tm_first)
+          {
+             Term_Container *tc_first = tm_first->container;
+             if (tc_first->parent->type != TERM_CONTAINER_TYPE_TABS)
+               _tabs_new(tc_first, tc_first->parent);
+             return tc_first->parent;
+          }
+     }
+   return NULL;
+}
+
 static void
 _cb_command(void *data,
             Evas_Object *_obj EINA_UNUSED,
@@ -6918,47 +6959,19 @@ _cb_command(void *data,
                      target = _container_find_by_name((Term_Container *)wn, name);
                      if (target)
                        {
-                          Term *tm_new;
-                          Term_Container *tc_new, *tc_attach = NULL;
-
-                          if (target->type == TERM_CONTAINER_TYPE_SOLO)
-                            {
-                               if (target->parent->type != TERM_CONTAINER_TYPE_TABS)
-                                 _tabs_new(target, target->parent);
-                               tc_attach = target->parent;
-                            }
-                          else if (target->type == TERM_CONTAINER_TYPE_TABS)
-                            {
-                               tc_attach = target;
-                            }
-                          else
-                            {
-                               Term *tm_first = target->term_first(target);
-                               if (tm_first)
-                                 {
-                                    Term_Container *tc_first = tm_first->container;
-                                    if (tc_first->parent->type !=
-                                        TERM_CONTAINER_TYPE_TABS)
-                                      _tabs_new(tc_first, tc_first->parent);
-                                    tc_attach = tc_first->parent;
-                                 }
-                            }
-
+                          Term_Container *tc_attach;
+                          tc_attach = _container_tab_attach_point(target);
                           if (tc_attach)
                             {
-                               tm_new = term_new(wn, wn->config,
-                                                 cmd_str, wn->config->login_shell,
-                                                 wdir, 80, 24, EINA_FALSE, NULL);
-                               tc_new = _solo_new(tm_new, wn);
-                               evas_object_data_set(tm_new->termio, "sizedone",
-                                                    tm_new->termio);
-                               _tabs_attach(tc_attach, tc_new);
+                               Term_Container *tc_new;
+                               tc_new = _term_new_solo(wn, cmd_str, wdir);
+                               if (tc_new)
+                                 _tabs_attach(tc_attach, tc_new);
                             }
                        }
                      else
                        {
                           Split_Direction dir;
-                          Term *tm_new;
                           Term_Container *tc_new;
 
                           switch (direction)
@@ -6973,14 +6986,13 @@ _cb_command(void *data,
                           if (tc->type != TERM_CONTAINER_TYPE_SOLO)
                             goto done;
 
-                          tm_new = term_new(wn, wn->config,
-                                            cmd_str, wn->config->login_shell,
-                                            wdir, 80, 24, EINA_FALSE, NULL);
-                          tc_new = _solo_new(tm_new, wn);
-                          evas_object_data_set(tm_new->termio, "sizedone",
-                                               tm_new->termio);
-                          tc->parent->split_direction(tc->parent, tc, tc_new, dir);
-                          eina_stringshare_replace(&tc_new->name, name);
+                          tc_new = _term_new_solo(wn, cmd_str, wdir);
+                          if (tc_new)
+                            {
+                               tc->parent->split_direction(tc->parent, tc,
+                                                           tc_new, dir);
+                               eina_stringshare_replace(&tc_new->name, name);
+                            }
                        }
                   }
                 else if (name && !direction)
@@ -6989,59 +7001,27 @@ _cb_command(void *data,
                      target = _container_find_by_name((Term_Container *)wn, name);
                      if (target)
                        {
-                          Term *tm_new;
-                          Term_Container *tc_new, *tc_attach = NULL;
-
-                          if (target->type == TERM_CONTAINER_TYPE_SOLO)
-                            {
-                               if (target->parent->type != TERM_CONTAINER_TYPE_TABS)
-                                 _tabs_new(target, target->parent);
-                               tc_attach = target->parent;
-                            }
-                          else if (target->type == TERM_CONTAINER_TYPE_TABS)
-                            {
-                               tc_attach = target;
-                            }
-                          else
-                            {
-                               Term *tm_first = target->term_first(target);
-                               if (tm_first)
-                                 {
-                                    Term_Container *tc_first = tm_first->container;
-                                    if (tc_first->parent->type !=
-                                        TERM_CONTAINER_TYPE_TABS)
-                                      _tabs_new(tc_first, tc_first->parent);
-                                    tc_attach = tc_first->parent;
-                                 }
-                            }
-
+                          Term_Container *tc_attach;
+                          tc_attach = _container_tab_attach_point(target);
                           if (tc_attach)
                             {
-                               tm_new = term_new(wn, wn->config,
-                                                 cmd_str, wn->config->login_shell,
-                                                 wdir, 80, 24, EINA_FALSE, NULL);
-                               tc_new = _solo_new(tm_new, wn);
-                               evas_object_data_set(tm_new->termio, "sizedone",
-                                                    tm_new->termio);
-                               _tabs_attach(tc_attach, tc_new);
+                               Term_Container *tc_new;
+                               tc_new = _term_new_solo(wn, cmd_str, wdir);
+                               if (tc_new)
+                                 _tabs_attach(tc_attach, tc_new);
                             }
                        }
                   }
                 else
                   {
-                     Term *tm_new;
                      Term_Container *tc_new;
 
                      if (tc->parent->type != TERM_CONTAINER_TYPE_TABS)
                        _tabs_new(tc, tc->parent);
 
-                     tm_new = term_new(wn, wn->config,
-                                       cmd_str, wn->config->login_shell, wdir,
-                                       80, 24, EINA_FALSE, NULL);
-                     tc_new = _solo_new(tm_new, wn);
-                     evas_object_data_set(tm_new->termio, "sizedone",
-                                          tm_new->termio);
-                     _tabs_attach(tc->parent, tc_new);
+                     tc_new = _term_new_solo(wn, cmd_str, wdir);
+                     if (tc_new)
+                       _tabs_attach(tc->parent, tc_new);
                   }
 done:
                 eina_stringshare_del(name);

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

Reply via email to