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 1c7d7a3a6d4566a992ab67b0153dfa20e1f61642
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 b3dffd56..42459417 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1200,6 +1200,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 d802a0e3..dd573296 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 {
const char *icon;
/* dynamic title set by xterm, keep it in case user don't want a
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.