This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-12-session-parity
in repository terminology.
View the commit online.
commit 32e25a6ad9fd524ca358b55ebbbcde6177028e0f
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 20:24:00 2026 -0600
termpty: parse media block commands outside of termio
The block commands change how the parser writes the following cells,
so tymuxd has to run them, and it has no termio. Their parsing moves
to the termpty layer unchanged, leaving the Evas objects in termio.
ib and ie no longer reach the "command" smart callback, whose only
listener ignores them.
---
src/bin/termio.c | 145 +------------------------------------
src/bin/termptyblock.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/termptyblock.h | 5 ++
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
5 files changed, 201 insertions(+), 143 deletions(-)
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 81191833..2776df87 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4818,141 +4818,8 @@ _smart_pty_command(void *data)
if (ty->cur_cmd[0] == 'i')
{
- if ((ty->cur_cmd[1] == 's') ||
- (ty->cur_cmd[1] == 'c') ||
- (ty->cur_cmd[1] == 'f') ||
- (ty->cur_cmd[1] == 't') ||
- (ty->cur_cmd[1] == 'j'))
- {
- const char *p, *p0, *p1, *path = NULL;
- char *pp;
- int ww = 0, hh = 0, repch;
- Eina_List *strs = NULL;
- char *link = NULL;
-
- // exact size in CHAR CELLS - WW (decimal) width CELLS,
- // HH (decimal) in CELLS.
- //
- // isCWW;HH;PATH
- // OR
- // isCWW;HH;LINK\nPATH
- // OR specific to 'j' (edje)
- // ijCWW;HH;PATH\nGROUP[commands]
- // WHERE [commands] is an optional string set of:
- // \nCMD\nP1[\nP2][\nP3][[\nCMD2\nP21[\nP22]]...
- // CMD is the command, P1, P2, P3 etc. are parameters (P2 and
- // on are optional depending on CMD)
- repch = ty->cur_cmd[2];
- if (!repch)
- return;
-
- for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
- {
- if (*p == ';')
- {
- ww = strtol(p0, NULL, 10);
- p++;
- break;
- }
- }
- for (p0 = p; *p; p++)
- {
- if (*p == ';')
- {
- hh = strtol(p0, NULL, 10);
- p++;
- break;
- }
- }
- if (ty->cur_cmd[1] == 'j')
- {
- // parse from p until end of string - one newline
- // per list item in strs
- p0 = p1 = p;
- for (;;)
- {
- // end of str param
- if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
- {
- // if string is non-empty...
- if ((p1 - p0) >= 1)
- {
- // allocate, fill and add to list
- pp = malloc(p1 - p0 + 1);
- if (pp)
- {
- strncpy(pp, p0, p1 - p0);
- pp[p1 - p0] = 0;
- strs = eina_list_append(strs, pp);
- }
- }
- // end of string buffer
- if (!*p1) break;
- p1++; // skip \n or \r
- p0 = p1;
- }
- else
- p1++;
- }
- }
- else
- {
- path = p;
- p = strchr(path, '\n');
- if (p)
- {
- link = strdup(path);
- path = p + 1;
- if (isspace(path[0])) path++;
- pp = strchr(link, '\n');
- if (pp) *pp = 0;
- pp = strchr(link, '\r');
- if (pp) *pp = 0;
- }
- }
- if ((ww < 512) && (hh < 512))
- {
- Termblock *blk = NULL;
-
- if (strs)
- {
- const char *file, *group;
- Eina_List *l;
-
- file = eina_list_nth(strs, 0);
- group = eina_list_nth(strs, 1);
- l = eina_list_nth_list(strs, 2);
- blk = termpty_block_new(ty, ww, hh, file, group);
- for (;l; l = l->next)
- {
- pp = l->data;
- if (pp)
- blk->cmds = eina_list_append(blk->cmds, pp);
- l->data = ""
- }
- }
- else
- blk = termpty_block_new(ty, ww, hh, path, link);
- if (blk)
- {
- if (ty->cur_cmd[1] == 's')
- blk->scale_stretch = EINA_TRUE;
- else if (ty->cur_cmd[1] == 'c')
- blk->scale_center = EINA_TRUE;
- else if (ty->cur_cmd[1] == 'f')
- blk->scale_fill = EINA_TRUE;
- else if (ty->cur_cmd[1] == 't')
- blk->thumb = EINA_TRUE;
- else if (ty->cur_cmd[1] == 'j')
- blk->edje = EINA_TRUE;
- termpty_block_insert(ty, repch, blk);
- }
- }
- free(link);
- EINA_LIST_FREE(strs, pp) free(pp);
- return;
- }
- else if (ty->cur_cmd[1] == 'C')
+ if (termpty_block_command(ty, ty->cur_cmd)) return;
+ if (ty->cur_cmd[1] == 'C')
{
Termblock *blk = NULL;
const char *p, *p0, *p1;
@@ -4999,14 +4866,6 @@ _smart_pty_command(void *data)
}
EINA_LIST_FREE(strs, pp) free(pp);
}
- else if (ty->cur_cmd[1] == 'b')
- {
- ty->block.on = EINA_TRUE;
- }
- else if (ty->cur_cmd[1] == 'e')
- {
- ty->block.on = EINA_FALSE;
- }
else if (ty->cur_cmd[1] == 'x')
{
const char *chid = &(ty->cur_cmd[2]);
diff --git a/src/bin/termptyblock.c b/src/bin/termptyblock.c
index dddb5ed7..38da1a1a 100644
--- a/src/bin/termptyblock.c
+++ b/src/bin/termptyblock.c
@@ -13,11 +13,203 @@ termpty_block_channel_find(const Termpty *ty, const char *chid)
return eina_hash_find(ty->block.chid_map, chid);
}
+Eina_Bool
+termpty_block_command(Termpty *ty, const char *cmd)
+{
+ if (cmd[0] != 'i') return EINA_FALSE;
+
+ if ((cmd[1] == 's') ||
+ (cmd[1] == 'c') ||
+ (cmd[1] == 'f') ||
+ (cmd[1] == 't') ||
+ (cmd[1] == 'j'))
+ {
+ const char *p, *p0, *p1, *path = NULL;
+ char *pp;
+ int ww = 0, hh = 0, repch;
+ Eina_List *strs = NULL;
+ char *link = NULL;
+
+ // exact size in CHAR CELLS - WW (decimal) width CELLS,
+ // HH (decimal) in CELLS.
+ //
+ // isCWW;HH;PATH
+ // OR
+ // isCWW;HH;LINK\nPATH
+ // OR specific to 'j' (edje)
+ // ijCWW;HH;PATH\nGROUP[commands]
+ // WHERE [commands] is an optional string set of:
+ // \nCMD\nP1[\nP2][\nP3][[\nCMD2\nP21[\nP22]]...
+ // CMD is the command, P1, P2, P3 etc. are parameters (P2 and
+ // on are optional depending on CMD)
+ repch = cmd[2];
+ if (!repch)
+ return EINA_TRUE;
+
+ for (p0 = p = &(cmd[3]); *p; p++)
+ {
+ if (*p == ';')
+ {
+ ww = strtol(p0, NULL, 10);
+ p++;
+ break;
+ }
+ }
+ for (p0 = p; *p; p++)
+ {
+ if (*p == ';')
+ {
+ hh = strtol(p0, NULL, 10);
+ p++;
+ break;
+ }
+ }
+ if (cmd[1] == 'j')
+ {
+ // parse from p until end of string - one newline
+ // per list item in strs
+ p0 = p1 = p;
+ for (;;)
+ {
+ // end of str param
+ if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
+ {
+ // if string is non-empty...
+ if ((p1 - p0) >= 1)
+ {
+ // allocate, fill and add to list
+ pp = malloc(p1 - p0 + 1);
+ if (pp)
+ {
+ strncpy(pp, p0, p1 - p0);
+ pp[p1 - p0] = 0;
+ strs = eina_list_append(strs, pp);
+ }
+ }
+ // end of string buffer
+ if (!*p1) break;
+ p1++; // skip \n or \r
+ p0 = p1;
+ }
+ else
+ p1++;
+ }
+ }
+ else
+ {
+ path = p;
+ p = strchr(path, '\n');
+ if (p)
+ {
+ link = strdup(path);
+ path = p + 1;
+ if (isspace(path[0])) path++;
+ pp = strchr(link, '\n');
+ if (pp) *pp = 0;
+ pp = strchr(link, '\r');
+ if (pp) *pp = 0;
+ }
+ }
+ if ((ww < 512) && (hh < 512))
+ {
+ Termblock *blk = NULL;
+
+ if (strs)
+ {
+ const char *file, *group;
+ Eina_List *l;
+
+ file = eina_list_nth(strs, 0);
+ group = eina_list_nth(strs, 1);
+ l = eina_list_nth_list(strs, 2);
+ blk = termpty_block_new(ty, ww, hh, file, group);
+ // on failure the items stay in strs and are freed below
+ if (blk)
+ for (;l; l = l->next)
+ {
+ pp = l->data;
+ if (pp)
+ blk->cmds = eina_list_append(blk->cmds, pp);
+ l->data = ""
+ }
+ }
+ else
+ blk = termpty_block_new(ty, ww, hh, path, link);
+ if (blk)
+ {
+ if (cmd[1] == 's')
+ blk->scale_stretch = EINA_TRUE;
+ else if (cmd[1] == 'c')
+ blk->scale_center = EINA_TRUE;
+ else if (cmd[1] == 'f')
+ blk->scale_fill = EINA_TRUE;
+ else if (cmd[1] == 't')
+ blk->thumb = EINA_TRUE;
+ else if (cmd[1] == 'j')
+ blk->edje = EINA_TRUE;
+ termpty_block_insert(ty, repch, blk);
+ }
+ }
+ free(link);
+ EINA_LIST_FREE(strs, pp) free(pp);
+ return EINA_TRUE;
+ }
+ if (cmd[1] == 'b')
+ {
+ ty->block.on = EINA_TRUE;
+ return EINA_TRUE;
+ }
+ if (cmd[1] == 'e')
+ {
+ ty->block.on = EINA_FALSE;
+ return EINA_TRUE;
+ }
+ return EINA_FALSE;
+}
+
#if defined(BINARY_TYTEST)
#include <assert.h>
#include <string.h>
#include "unit_tests.h"
+int
+tytest_termpty_block_command(void)
+{
+ Termpty ty;
+ Termblock *blk;
+ Termexp *ex;
+
+ memset(&ty, 0, sizeof(ty));
+
+ assert(termpty_block_command(&ty, "isX2;3;/tmp/a.png"));
+ blk = termpty_block_get(&ty, 0);
+ assert(blk->w == 2 && blk->h == 3 && blk->scale_stretch);
+ assert(!strcmp(blk->path, "/tmp/a.png"));
+
+ assert(termpty_block_command(&ty, "icY1;1;https://l\n/tmp/b.png"));
+ blk = termpty_block_get(&ty, 1);
+ assert(!strcmp(blk->link, "https://l") && !strcmp(blk->path, "/tmp/b.png"));
+
+ assert(termpty_block_command(&ty, "ijZ1;1;f.edj\ngroup\nchid\nc1"));
+ blk = termpty_block_get(&ty, 2);
+ assert(blk->edje && eina_list_count(blk->cmds) == 2);
+
+ assert(termpty_block_command(&ty, "ib") && ty.block.on);
+ assert(termpty_block_command(&ty, "ie") && !ty.block.on);
+
+ /* too wide: handled, but no block is created */
+ assert(termpty_block_command(&ty, "isX512;1;/tmp/c.png"));
+ assert(!termpty_block_get(&ty, 3));
+
+ assert(!termpty_block_command(&ty, "iC"));
+ assert(!termpty_block_command(&ty, "ix"));
+ assert(!termpty_block_command(&ty, "pnfile"));
+
+ EINA_LIST_FREE(ty.block.expecting, ex) free(ex);
+ eina_hash_free(ty.block.blocks);
+ return 0;
+}
+
int
tytest_termpty_block_channel_find(void)
{
diff --git a/src/bin/termptyblock.h b/src/bin/termptyblock.h
index 54006c0c..bf300e68 100644
--- a/src/bin/termptyblock.h
+++ b/src/bin/termptyblock.h
@@ -5,4 +5,9 @@
* the block was freed, or no block has been registered yet. */
Termblock *termpty_block_channel_find(const Termpty *ty, const char *chid);
+/* Handles the media block commands is, ic, if, it, ij, ib and ie, where cmd
+ * is an escape payload without its ESC. Returns EINA_FALSE and changes
+ * nothing for any other command. */
+Eina_Bool termpty_block_command(Termpty *ty, const char *cmd);
+
#endif
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 5bdab70c..9c4ca91f 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -109,6 +109,7 @@ static struct {
{ "resize_screen2_link_refs", tytest_resize_screen2_link_refs},
{ "backlog_block_refs", tytest_backlog_block_refs},
{ "termpty_free_backlog_block", tytest_termpty_free_backlog_block},
+ { "termpty_block_command", tytest_termpty_block_command},
{ "termpty_block_channel_find", tytest_termpty_block_channel_find},
{ "termpty_block_channel_find_newer_claims", tytest_termpty_block_channel_find_newer_claims},
{ "backlog_row_get_args", tytest_backlog_row_get_args},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index a0aa99ac..58fcb632 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -6,6 +6,7 @@ typedef int (*tytest_func)(void);
/* list of tests */
int tytest_dummy(void);
+int tytest_termpty_block_command(void);
int tytest_termpty_block_channel_find(void);
int tytest_termpty_block_channel_find_newer_claims(void);
int tytest_write_hook(void);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.