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

git pushed a commit to reference refs/pull/36/head
in repository terminology.

View the commit online.

commit 0fe48d11ddd728dca79c50565a4f23422142a720
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 15 21:44:34 2026 -0600

    feat: add write hook to Termpty for session mode I/O redirection
    
    Session mode uses a shadow Termpty with no PTY file descriptor. Without
    a hook mechanism, keyboard input would accumulate in the internal write
    buffer and never reach the shell. This commit adds a write_cb struct with
    a function pointer and data pointer to termpty.h, and checks it at the
    start of termpty_write() before buffering. If the hook is set, it calls
    the hook and returns early, allowing session mode to redirect all input
    to the tymuxd socket instead.
    
    The hook is unguarded (pure C, no #ifdef) and harmless on all platforms.
    NULL by default, so all existing code paths are unaffected.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/termpty.c | 5 +++++
 src/bin/termpty.h | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 5d7c26b3..a5a0cfcb 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1279,6 +1279,11 @@ termpty_write(Termpty *ty, const char *input, int len)
 #if defined(BINARY_TYFUZZ)
    return;
 #endif
+   if (ty->write_cb.func)
+     {
+        ty->write_cb.func(input, len, ty->write_cb.data);
+        return;
+     }
    int res = ty_sb_add(&ty->write_buffer, input, len);
 
    if (res < 0)
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index ba0376f6..15ee3cd1 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -155,6 +155,13 @@ struct tag_Termpty
          void *data;
       } change, set_title, set_icon, cancel_sel, exited, bell, command;
    } cb;
+   /* Write hook: if set, termpty_write() calls this instead of buffering.
+    * Used by session mode to forward input to the socket.
+    * func must not free buf. */
+   struct {
+      void (*func)(const char *buf, int len, void *data);
+      void *data;
+   } write_cb;
    struct {
       Ecore_Timer *watchdog;
       Termcell   **shadow_rows;     /* size shadow_h, each entry NULL or malloc'd row copy */

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

Reply via email to