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

git pushed a commit to branch tymux
in repository terminology.

View the commit online.

commit 5c12a9ad877fa938e9dc6aa1c5fff6ef78de912f
Author: [email protected] <[email protected]>
AuthorDate: Mon May 4 21:45:54 2026 -0600

    feat(tymux): add _termio_tymux_demote helper for in-place shell respawn
    
    Adds the shared primitive for the upcoming native Ctrl+b d detach and
    tymux auto-respawn features. The helper tears down the active tymux
    session, frees its shadow Termpty, and spawns a fresh local shell in
    the same widget, rooted at the supplied cwd if valid or Terminology's
    default otherwise. Mirrors the Termpty callback wiring from termio_add.
    Deliberately unused at this commit — the call site lands in the next
    commit, and the -Wunused-function warning is expected.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
---
 src/bin/termio.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index e1cf9cad..c84799df 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -3,6 +3,7 @@
 #include <Elementary.h>
 #include <Elementary_Cursor.h>
 #include <Ecore_Input.h>
+#include <sys/stat.h>
 
 #include "termio.h"
 #include "termtymux.h"
@@ -3872,8 +3873,10 @@ _smart_tymux_resume(void *data)
      sd->tymux->cb_change.func(sd->tymux->cb_change.data);
 }
 
-/* Forward declaration — defined below after _termio_tymux_newtab_job. */
+/* Forward declarations — defined below after _termio_tymux_newtab_job. */
 static void _termio_tymux_switch_job(void *data);
+static void _termio_tymux_demote(Evas_Object *obj, Termio *sd, const char *cwd);
+static void _smart_pty_command(void *data);
 
 /* Deferred new-tab creation: opens a new tab, then schedules a tymux switch
  * in that tab.  Split into a separate job so that main_new() has time to
@@ -4022,6 +4025,61 @@ _termio_tymux_switch_job(void *data)
    _smart_apply(obj);
 }
 
+static void
+_termio_tymux_demote(Evas_Object *obj, Termio *sd, const char *cwd)
+{
+   const char *spawn_cwd = NULL;
+   struct stat st;
+
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+   if (!sd->tymux)
+     return;
+
+   /* Validate cwd: must exist and be a directory. Treat empty/NULL as
+    * "no cwd available" — fall back to Terminology's default. */
+   if (cwd && cwd[0] != '\0' &&
+       stat(cwd, &st) == 0 && S_ISDIR(st.st_mode))
+     spawn_cwd = cwd;
+
+   /* Tear down tymux: this also frees the shadow Termpty. */
+   termtymux_free(sd->tymux);
+   sd->tymux = NULL;
+   sd->pty   = NULL;
+   eina_stringshare_replace(&sd->tymux_name, NULL);
+
+   if (sd->term)
+     term_tymux_indicator_set(sd->term, EINA_FALSE);
+
+   /* Spawn a fresh local Termpty in the same widget. The arguments mirror
+    * the non-tymux branch in termio_add(). */
+   sd->pty = termpty_new(NULL, EINA_FALSE, spawn_cwd,
+                         sd->grid.w, sd->grid.h,
+                         sd->config, NULL,
+                         sd->win ? elm_win_window_id_get(sd->win) : 0);
+   if (!sd->pty)
+     {
+        ERR("tymux demote: termpty_new failed");
+        return;
+     }
+   sd->pty->obj                  = obj;
+   sd->pty->cb.change.func       = _smart_pty_change;
+   sd->pty->cb.change.data       = ""
+   sd->pty->cb.set_title.func    = _smart_pty_title;
+   sd->pty->cb.set_title.data    = ""
+   sd->pty->cb.set_icon.func     = _smart_pty_icon;
+   sd->pty->cb.set_icon.data     = ""
+   sd->pty->cb.cancel_sel.func   = _smart_pty_cancel_sel;
+   sd->pty->cb.cancel_sel.data   = ""
+   sd->pty->cb.exited.func       = _smart_pty_exited;
+   sd->pty->cb.exited.data       = ""
+   sd->pty->cb.bell.func         = _smart_pty_bell;
+   sd->pty->cb.bell.data         = ""
+   sd->pty->cb.command.func      = _smart_pty_command;
+   sd->pty->cb.command.data      = ""
+
+   _smart_apply(obj);
+}
+
 static void
 _termio_tymux_switch(Evas_Object *obj, Termio *sd, const char *tymux_name,
                      TermSrvAttachMode mode)

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

Reply via email to