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 70d23075aad9b31af0c8c60b7261f7a5c246f1c2
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 20:44:49 2026 -0600
termd_tymux: publish media blocks to clients
tycat and tyls printed nothing useful in a session, because the daemon
dropped the commands that define their media blocks. The daemon now
runs them and publishes each block in the session table, and a native
client builds its own copy the first time the renderer asks for it. A
client with Terminology escapes turned off shows no media.
NOTIFY tells whether the session ever published a block, so that a
session without any does no per-cell work in its clients. Block sizes
outside 1 to 511 are now refused: this parser runs on untrusted output
in the daemon, and negative or truncated sizes used to pass its check.
The inline proxy draws media cells as blanks.
---
src/bin/termd_tymux.c | 49 ++++++-
src/bin/termiointernals.c | 3 +-
src/bin/termpty.c | 10 +-
src/bin/termpty.h | 9 +-
src/bin/termptyblock.c | 348 +++++++++++++++++++++++++++++++++++++++++++++-
src/bin/termptyblock.h | 13 ++
src/bin/termsrv.h | 4 +-
src/bin/termtymux.c | 233 ++++++++++++++++++++++++++++++-
src/bin/termtymux.h | 3 +
src/bin/tymux.c | 3 +-
src/bin/tytest.c | 4 +
src/bin/tytest_tymux.c | 98 +++++++++++++
src/bin/tytest_tymux.h | 1 +
src/bin/unit_tests.h | 3 +
tests/meson.build | 3 +-
tests/tymux.py | 8 ++
16 files changed, 778 insertions(+), 14 deletions(-)
diff --git a/src/bin/termd_tymux.c b/src/bin/termd_tymux.c
index 057a1291..b9413c68 100644
--- a/src/bin/termd_tymux.c
+++ b/src/bin/termd_tymux.c
@@ -11,6 +11,7 @@
#include <Elementary.h>
#include "config.h"
#include "termpty.h"
+#include "termptyblock.h"
#include "termsrv.h"
#include "backlog.h"
#include "termd_tymux.h"
@@ -112,6 +113,34 @@ _screen_flush(TermDTymux *td)
return termsrv_shm_write_end(shm);
}
+/* A block too large for a record is left out: its cells show nothing. */
+static void
+_block_publish(TermDTymux *td, Termpty *ty, uint32_t id)
+{
+ const Termblock *blk = termpty_block_get(ty, id);
+ char stack[1024], *record = stack;
+ uint32_t length;
+
+ if (!blk)
+ return;
+ ty->block.published = 1;
+ length = termpty_block_serialize(blk, stack, sizeof(stack));
+ if (length > sizeof(stack))
+ {
+ record = malloc(length);
+ if (record)
+ termpty_block_serialize(blk, record, length);
+ }
+ if (length && record)
+ termsrv_table_publish(td->table, TERMSRV_TABLE_BLOCK, id, record, length,
+ atomic_load_explicit(&td->shm->write_seq,
+ memory_order_relaxed) + 2);
+ else
+ termsrv_table_unpublish(td->table, TERMSRV_TABLE_BLOCK, id);
+ if (record != stack)
+ free(record);
+}
+
/* The record of a link is its key and its URL, each ended by a NUL: the key
* is empty when the link has none. It is valid from the next frame. */
static void
@@ -125,13 +154,16 @@ _cb_pty_record(void *data, Termpty *ty, TermSrvTableKind kind, uint32_t id,
size_t key_len, url_len;
uint64_t valid_from;
- if (kind != TERMSRV_TABLE_LINK)
- return;
if (!alive)
{
termsrv_table_unpublish(td->table, kind, id);
return;
}
+ if (kind == TERMSRV_TABLE_BLOCK)
+ {
+ _block_publish(td, ty, id);
+ return;
+ }
link = ty->hl.links + id;
key = link->key ? link->key : "";
key_len = strlen(key);
@@ -155,6 +187,16 @@ _cb_pty_record(void *data, Termpty *ty, TermSrvTableKind kind, uint32_t id,
free(record);
}
+/* Only the media blocks: the rest of the commands drive widgets a session
+ * does not have. */
+static void
+_cb_pty_command(void *data)
+{
+ TermDTymux *td = data;
+
+ termpty_block_command(td->pty, td->pty->cur_cmd);
+}
+
static void _client_del(Client *client);
static void _client_pages_prune(Client *client);
static void _client_free(Client *client);
@@ -300,6 +342,7 @@ _flush_and_notify(TermDTymux *td)
.mouse_ext = ty->mouse_ext,
.bracketed_paste = ty->bracketed_paste,
.focus_reporting = ty->focus_reporting,
+ .has_blocks = ty->block.published,
};
td->dirty = EINA_FALSE;
@@ -1006,6 +1049,8 @@ termd_tymux_new(const char *name, const char *cmd)
td->pty->cb.bell.data = ""
td->pty->cb.exited.func = _cb_pty_exited;
td->pty->cb.exited.data = ""
+ td->pty->cb.command.func = _cb_pty_command;
+ td->pty->cb.command.data = ""
td->pty->record_hook.func = _cb_pty_record;
td->pty->record_hook.data = ""
/* termpty_new() made no store for the scrollback of 0 it was given:
diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index 3ecd1023..3fec77cc 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -2389,7 +2389,8 @@ termio_internal_render(Termio *sd,
int sel_start_x = 0, sel_start_y = 0, sel_end_x = 0, sel_end_y = 0;
Termblock *blk;
Eina_List *l;
- Eina_Bool has_blocks = (sd->pty->block.blocks != NULL);
+ Eina_Bool has_blocks = (sd->pty->block.blocks != NULL) ||
+ (sd->pty->block.published != 0);
EINA_LIST_FOREACH(sd->pty->block.active, l, blk)
{
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index b5aa314a..75559999 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1752,6 +1752,9 @@ termpty_block_free(Termblock *tb)
if (!tb)
return;
+ if (tb->pty && tb->pty->record_hook.func)
+ tb->pty->record_hook.func(tb->pty->record_hook.data, tb->pty,
+ TERMSRV_TABLE_BLOCK, tb->id, EINA_FALSE);
if (tb->chid && tb->pty && tb->pty->block.chid_map &&
(eina_hash_find(tb->pty->block.chid_map, tb->chid) == tb))
eina_hash_del(tb->pty->block.chid_map, tb->chid, tb);
@@ -1822,6 +1825,8 @@ termpty_block_insert(Termpty *ty, int ch, Termblock *blk)
Termblock *
termpty_block_get(const Termpty *ty, int id)
{
+ if (EINA_UNLIKELY(ty->resolver.block != NULL))
+ ty->resolver.block(ty->resolver.data, (Termpty *)ty, id);
if (!ty->block.blocks) return NULL;
return eina_hash_find(ty->block.blocks, &id);
}
@@ -1842,6 +1847,7 @@ termpty_handle_block_codepoint_overwrite_heavy(Termpty *ty, int oldc, int newc)
Termblock *tb;
int ido = 0, idn = 0;
+ if (ty->resolver.block) return;
if (oldc & 0x80000000) ido = (oldc >> 18) & 0x1fff;
if (newc & 0x80000000) idn = (newc >> 18) & 0x1fff;
if (((oldc & 0x80000000) && (newc & 0x80000000)) && (idn == ido)) return;
@@ -1870,8 +1876,10 @@ termpty_handle_block_codepoint_overwrite_heavy(Termpty *ty, int oldc, int newc)
void
termpty_block_refs_release(Termpty *ty, int id, int count)
{
- Termblock *tb = termpty_block_get(ty, id);
+ Termblock *tb;
+ if (ty->resolver.block) return;
+ tb = termpty_block_get(ty, id);
if (!tb) return;
if (EINA_UNLIKELY(count > tb->refs))
{
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index a3aefd3e..52c3886e 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -269,6 +269,9 @@ struct tag_Termpty
Eina_List *active;
Eina_List *expecting;
unsigned char on : 1;
+ /* a session published a block: cells may hold block codepoints even
+ * while no block is resolved */
+ unsigned char published : 1;
} block;
struct {
/* start is always the start of the selection
@@ -370,9 +373,11 @@ struct tag_Termpty
void *data;
} record_hook;
/* Shadow ptys only: refreshes hl.links[id] from the session table before
- * term_link_get() returns it. */
+ * term_link_get() returns it, and the block id before termpty_block_get()
+ * does. The blocks of such a pty are not counted by its cells. */
struct {
void (*link) (void *data, Termpty *ty, uint16_t id);
+ void (*block) (void *data, Termpty *ty, int id);
void *data;
} resolver;
TitleIconElem *title_icon_stack;
@@ -491,6 +496,8 @@ termpty_block_id_get(const Termcell *cell, int *x, int *y)
*y = cell->codepoint & 0x1ff;
return id;
}
+/* The block id, NULL for none. With a resolver, NULL too when the session
+ * has none for the id. */
Termblock *termpty_block_get(const Termpty *ty, int id);
void termpty_block_chid_update(Termpty *ty, Termblock *blk);
diff --git a/src/bin/termptyblock.c b/src/bin/termptyblock.c
index 38da1a1a..8be79418 100644
--- a/src/bin/termptyblock.c
+++ b/src/bin/termptyblock.c
@@ -13,6 +13,16 @@ termpty_block_channel_find(const Termpty *ty, const char *chid)
return eina_hash_find(ty->block.chid_map, chid);
}
+/* The cells of a block, as its codepoints can address them: x and y take 9
+ * bits each. The sizes come from untrusted output. */
+#define BLOCK_SIZE_MAX 511
+
+static inline Eina_Bool
+_block_size_ok(long size)
+{
+ return (size >= 1) && (size <= BLOCK_SIZE_MAX);
+}
+
Eina_Bool
termpty_block_command(Termpty *ty, const char *cmd)
{
@@ -26,7 +36,8 @@ termpty_block_command(Termpty *ty, const char *cmd)
{
const char *p, *p0, *p1, *path = NULL;
char *pp;
- int ww = 0, hh = 0, repch;
+ long ww = 0, hh = 0;
+ int repch;
Eina_List *strs = NULL;
char *link = NULL;
@@ -110,7 +121,7 @@ termpty_block_command(Termpty *ty, const char *cmd)
if (pp) *pp = 0;
}
}
- if ((ww < 512) && (hh < 512))
+ if (_block_size_ok(ww) && _block_size_ok(hh))
{
Termblock *blk = NULL;
@@ -148,6 +159,10 @@ termpty_block_command(Termpty *ty, const char *cmd)
else if (cmd[1] == 'j')
blk->edje = EINA_TRUE;
termpty_block_insert(ty, repch, blk);
+ if (ty->record_hook.func)
+ ty->record_hook.func(ty->record_hook.data, ty,
+ TERMSRV_TABLE_BLOCK, blk->id,
+ EINA_TRUE);
}
}
free(link);
@@ -167,24 +182,195 @@ termpty_block_command(Termpty *ty, const char *cmd)
return EINA_FALSE;
}
+/* A record is a Block_Record_Head, then the NUL ended path, link and chid
+ * its flags say it has, then ncmds NUL ended commands: nothing follows. */
+typedef struct
+{
+ uint16_t w, h;
+ uint32_t flags;
+ uint32_t ncmds;
+} Block_Record_Head;
+
+enum
+{
+ RECORD_STRETCH = 1 << 0,
+ RECORD_CENTER = 1 << 1,
+ RECORD_FILL = 1 << 2,
+ RECORD_THUMB = 1 << 3,
+ RECORD_EDJE = 1 << 4,
+ RECORD_PATH = 1 << 5,
+ RECORD_LINK = 1 << 6,
+ RECORD_CHID = 1 << 7,
+ RECORD_FLAGS_ALL = (1 << 8) - 1
+};
+
+static size_t
+_record_string_put(char *dst, const char *str)
+{
+ size_t len = strlen(str) + 1;
+
+ memcpy(dst, str, len);
+ return len;
+}
+
+uint32_t
+termpty_block_serialize(const Termblock *blk, void *buf, uint32_t capacity)
+{
+ Block_Record_Head head = { .w = blk->w, .h = blk->h };
+ const char *cmd;
+ const Eina_List *l;
+ size_t size = sizeof(head), at;
+ char *out = buf;
+
+ head.flags = (blk->scale_stretch ? RECORD_STRETCH : 0) |
+ (blk->scale_center ? RECORD_CENTER : 0) |
+ (blk->scale_fill ? RECORD_FILL : 0) |
+ (blk->thumb ? RECORD_THUMB : 0) |
+ (blk->edje ? RECORD_EDJE : 0) |
+ (blk->path ? RECORD_PATH : 0) |
+ (blk->link ? RECORD_LINK : 0) |
+ (blk->chid ? RECORD_CHID : 0);
+ head.ncmds = eina_list_count(blk->cmds);
+ if (blk->path) size += strlen(blk->path) + 1;
+ if (blk->link) size += strlen(blk->link) + 1;
+ if (blk->chid) size += strlen(blk->chid) + 1;
+ EINA_LIST_FOREACH(blk->cmds, l, cmd)
+ {
+ size += strlen(cmd) + 1;
+ if (size > TERMSRV_TABLE_RECORD_MAX)
+ return 0;
+ }
+ if (size > TERMSRV_TABLE_RECORD_MAX)
+ return 0;
+ if (size > capacity)
+ return size;
+
+ memcpy(out, &head, sizeof(head));
+ at = sizeof(head);
+ if (blk->path) at += _record_string_put(out + at, blk->path);
+ if (blk->link) at += _record_string_put(out + at, blk->link);
+ if (blk->chid) at += _record_string_put(out + at, blk->chid);
+ EINA_LIST_FOREACH(blk->cmds, l, cmd)
+ at += _record_string_put(out + at, cmd);
+ return size;
+}
+
+/* The NUL ended string at *at, or NULL when none ends before end. */
+static const char *
+_record_string_get(const char **at, const char *end)
+{
+ const char *str = *at;
+ const char *nul = memchr(str, '\0', end - str);
+
+ if (!nul)
+ return NULL;
+ *at = nul + 1;
+ return str;
+}
+
+Eina_Bool
+termpty_block_deserialize(Termblock *blk, const void *buf, uint32_t length)
+{
+ Block_Record_Head head;
+ const char *at, *end = (const char *)buf + length;
+ const char *path = NULL, *link = NULL, *chid = NULL, *cmd;
+ Eina_List *cmds = NULL;
+ char *copy;
+ uint32_t i;
+
+ if (length < sizeof(head))
+ return EINA_FALSE;
+ memcpy(&head, buf, sizeof(head));
+ at = (const char *)buf + sizeof(head);
+ if (!_block_size_ok(head.w) || !_block_size_ok(head.h) ||
+ (head.flags & ~RECORD_FLAGS_ALL) || (head.ncmds > (size_t)(end - at)))
+ return EINA_FALSE;
+ /* the media code reads the path of any block that is not an edje one */
+ if (!(head.flags & (RECORD_PATH | RECORD_EDJE)))
+ return EINA_FALSE;
+ if ((head.flags & RECORD_PATH) && !(path = _record_string_get(&at, end)))
+ return EINA_FALSE;
+ if ((head.flags & RECORD_LINK) && !(link = _record_string_get(&at, end)))
+ return EINA_FALSE;
+ if ((head.flags & RECORD_CHID) && !(chid = _record_string_get(&at, end)))
+ return EINA_FALSE;
+ for (i = 0; i < head.ncmds; i++)
+ {
+ cmd = _record_string_get(&at, end);
+ if (!cmd)
+ goto bad;
+ copy = strdup(cmd);
+ if (!copy)
+ goto bad;
+ cmds = eina_list_append(cmds, copy);
+ }
+ if (at != end)
+ goto bad;
+
+ blk->w = head.w;
+ blk->h = head.h;
+ blk->scale_stretch = !!(head.flags & RECORD_STRETCH);
+ blk->scale_center = !!(head.flags & RECORD_CENTER);
+ blk->scale_fill = !!(head.flags & RECORD_FILL);
+ blk->thumb = !!(head.flags & RECORD_THUMB);
+ blk->edje = !!(head.flags & RECORD_EDJE);
+ blk->path = eina_stringshare_add(path);
+ blk->link = eina_stringshare_add(link);
+ blk->chid = eina_stringshare_add(chid);
+ blk->cmds = cmds;
+ return EINA_TRUE;
+
+bad:
+ EINA_LIST_FREE(cmds, copy) free(copy);
+ return EINA_FALSE;
+}
+
#if defined(BINARY_TYTEST)
#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include "unit_tests.h"
+static struct
+{
+ int alive, dead;
+ Eina_Bool stretch_when_published;
+} _hook;
+
+static void
+_hook_record(void *data EINA_UNUSED, Termpty *ty, TermSrvTableKind kind,
+ uint32_t id, Eina_Bool alive)
+{
+ assert(kind == TERMSRV_TABLE_BLOCK);
+ if (alive)
+ {
+ _hook.alive++;
+ _hook.stretch_when_published = termpty_block_get(ty, id)->scale_stretch;
+ }
+ else
+ _hook.dead++;
+}
+
int
tytest_termpty_block_command(void)
{
+ static const char *bad_sizes[] = {
+ "0;1", "1;0", "-1;1", "1;-3", "512;1", "1;512", "-2147483648;1",
+ "4294967297;1", "1;4294967297", "2147483648;1", "99999999999999999999;1"
+ };
Termpty ty;
Termblock *blk;
Termexp *ex;
+ size_t i;
memset(&ty, 0, sizeof(ty));
+ ty.record_hook.func = _hook_record;
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(_hook.alive == 1 && _hook.stretch_when_published);
assert(termpty_block_command(&ty, "icY1;1;https://l\n/tmp/b.png"));
blk = termpty_block_get(&ty, 1);
@@ -197,9 +383,22 @@ tytest_termpty_block_command(void)
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));
+ /* a size out of 1..511 in cells: handled, but no block is created */
+ for (i = 0; i < EINA_C_ARRAY_LENGTH(bad_sizes); i++)
+ {
+ char cmd[64];
+
+ snprintf(cmd, sizeof(cmd), "isX%s;/tmp/c.png", bad_sizes[i]);
+ assert(termpty_block_command(&ty, cmd));
+ snprintf(cmd, sizeof(cmd), "ijX%s;f.edj\ngroup", bad_sizes[i]);
+ assert(termpty_block_command(&ty, cmd));
+ assert(ty.block.curid == 3);
+ assert(!termpty_block_get(&ty, 3));
+ }
+ assert(_hook.alive == 3 && _hook.dead == 0);
+ assert(termpty_block_command(&ty, "isX511;511;/tmp/d.png"));
+ assert(termpty_block_get(&ty, 3)->w == 511);
+ assert(_hook.alive == 4);
assert(!termpty_block_command(&ty, "iC"));
assert(!termpty_block_command(&ty, "ix"));
@@ -207,6 +406,145 @@ tytest_termpty_block_command(void)
EINA_LIST_FREE(ty.block.expecting, ex) free(ex);
eina_hash_free(ty.block.blocks);
+ assert(_hook.alive == 4 && _hook.dead == 4);
+ return 0;
+}
+
+static void
+_block_fill(Termblock *blk, short w, short h, const char *path,
+ const char *link, const char *chid)
+{
+ blk->w = w;
+ blk->h = h;
+ blk->path = eina_stringshare_add(path);
+ blk->link = eina_stringshare_add(link);
+ blk->chid = eina_stringshare_add(chid);
+}
+
+static void
+_block_clear(Termblock *blk)
+{
+ char *cmd;
+
+ eina_stringshare_del(blk->path);
+ eina_stringshare_del(blk->link);
+ eina_stringshare_del(blk->chid);
+ EINA_LIST_FREE(blk->cmds, cmd) free(cmd);
+ memset(blk, 0, sizeof(*blk));
+}
+
+static Eina_Bool
+_block_empty(const Termblock *blk)
+{
+ return !blk->w && !blk->h && !blk->path && !blk->link && !blk->chid &&
+ !blk->cmds && !blk->scale_stretch && !blk->edje;
+}
+
+int
+tytest_termpty_block_serialize(void)
+{
+ Termblock src = { 0 }, dst = { 0 };
+ Block_Record_Head head;
+ char buf[256], bad[256];
+ uint32_t len, n;
+
+ _block_fill(&src, 3, 2, "/tmp/a.edj", "https://l", "chan");
+ src.scale_fill = EINA_TRUE;
+ src.edje = EINA_TRUE;
+ src.cmds = eina_list_append(src.cmds, strdup("chid\nx"));
+ src.cmds = eina_list_append(src.cmds, strdup("c2"));
+
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(len > 0 && len < sizeof(buf));
+ assert(termpty_block_serialize(&src, NULL, 0) == len);
+ assert(termpty_block_serialize(&src, bad, len - 1) == len);
+
+ assert(termpty_block_deserialize(&dst, buf, len));
+ assert(dst.w == 3 && dst.h == 2 && dst.scale_fill && dst.edje);
+ assert(!dst.scale_stretch && !dst.scale_center && !dst.thumb);
+ assert(!strcmp(dst.path, "/tmp/a.edj") && !strcmp(dst.link, "https://l"));
+ assert(!strcmp(dst.chid, "chan"));
+ assert(eina_list_count(dst.cmds) == 2);
+ assert(!strcmp(eina_list_nth(dst.cmds, 0), "chid\nx"));
+ assert(!strcmp(eina_list_nth(dst.cmds, 1), "c2"));
+ _block_clear(&dst);
+
+ for (n = 0; n < len; n++)
+ {
+ assert(!termpty_block_deserialize(&dst, buf, n));
+ assert(_block_empty(&dst));
+ }
+ memcpy(bad, buf, len);
+ bad[len] = '\0';
+ assert(!termpty_block_deserialize(&dst, bad, len + 1));
+ bad[len - 1] = 'x';
+ assert(!termpty_block_deserialize(&dst, bad, len));
+ assert(_block_empty(&dst));
+
+ memcpy(&head, buf, sizeof(head));
+ head.ncmds = UINT32_MAX;
+ memcpy(bad, buf, len);
+ memcpy(bad, &head, sizeof(head));
+ assert(!termpty_block_deserialize(&dst, bad, len));
+ head.ncmds = 1;
+ memcpy(bad, &head, sizeof(head));
+ assert(!termpty_block_deserialize(&dst, bad, len));
+ assert(_block_empty(&dst));
+
+ /* no link, chid or commands is not an empty one */
+ _block_clear(&src);
+ _block_fill(&src, 1, 1, "/tmp/b.png", NULL, NULL);
+ src.thumb = EINA_TRUE;
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(termpty_block_deserialize(&dst, buf, len));
+ assert(dst.thumb && !dst.link && !dst.chid && !dst.cmds);
+ _block_clear(&dst);
+ _block_clear(&src);
+ _block_fill(&src, 1, 1, "/tmp/b.png", "", "");
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(termpty_block_deserialize(&dst, buf, len));
+ assert(dst.link && !dst.link[0] && dst.chid && !dst.chid[0]);
+ _block_clear(&dst);
+
+ /* a block that is not an edje one has a path */
+ _block_clear(&src);
+ src.w = 1;
+ src.h = 1;
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(!termpty_block_deserialize(&dst, buf, len));
+ assert(_block_empty(&dst));
+ src.edje = EINA_TRUE;
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(termpty_block_deserialize(&dst, buf, len));
+ assert(dst.edje && !dst.path);
+ _block_clear(&dst);
+ _block_clear(&src);
+ _block_fill(&src, 1, 1, "/tmp/b.png", NULL, NULL);
+
+ /* sizes out of 1..511 cells */
+ {
+ static const short bad_sizes[][2] = {
+ { 0, 1 }, { 1, 0 }, { -1, 1 }, { 1, -1 }, { 512, 1 }, { 1, 512 },
+ { 32767, 1 }, { -32768, 1 }
+ };
+ size_t i;
+
+ for (i = 0; i < EINA_C_ARRAY_LENGTH(bad_sizes); i++)
+ {
+ src.w = bad_sizes[i][0];
+ src.h = bad_sizes[i][1];
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(!termpty_block_deserialize(&dst, buf, len));
+ assert(_block_empty(&dst));
+ }
+ src.w = 511;
+ src.h = 511;
+ len = termpty_block_serialize(&src, buf, sizeof(buf));
+ assert(termpty_block_deserialize(&dst, buf, len));
+ assert(dst.w == 511 && dst.h == 511);
+ _block_clear(&dst);
+ }
+ _block_clear(&src);
return 0;
}
diff --git a/src/bin/termptyblock.h b/src/bin/termptyblock.h
index bf300e68..ab4a13f0 100644
--- a/src/bin/termptyblock.h
+++ b/src/bin/termptyblock.h
@@ -10,4 +10,17 @@ Termblock *termpty_block_channel_find(const Termpty *ty, const char *chid);
* nothing for any other command. */
Eina_Bool termpty_block_command(Termpty *ty, const char *cmd);
+/* The record of blk that the session table holds: its size, the flags that
+ * say how it is shown, its path, link and channel id, and its commands.
+ * Returns its length in bytes, and writes it only when that is not more than
+ * capacity. 0 when it is too large for a record. */
+uint32_t termpty_block_serialize(const Termblock *blk, void *buf,
+ uint32_t capacity);
+
+/* Fills blk, a block with no path, link, channel id or commands, from a
+ * record of serialize(). EINA_FALSE, with blk unchanged, for a record that
+ * is not exactly one, as the table is not to be trusted. */
+Eina_Bool termpty_block_deserialize(Termblock *blk, const void *buf,
+ uint32_t length);
+
#endif
diff --git a/src/bin/termsrv.h b/src/bin/termsrv.h
index 8620dd55..45c7f751 100644
--- a/src/bin/termsrv.h
+++ b/src/bin/termsrv.h
@@ -247,7 +247,9 @@ typedef struct
uint8_t mouse_ext;
uint8_t bracketed_paste;
uint8_t focus_reporting;
- uint8_t reserved[2];
+ uint8_t has_blocks; /* a block was published: sticky, as cells may show
+ * one from then on */
+ uint8_t reserved;
uint32_t first_page_id; /* backlog pages held, the last one is the head */
uint32_t page_count; /* 0: an empty store with no head, as after a reset
* until rows are saved: nothing to ask for */
diff --git a/src/bin/termtymux.c b/src/bin/termtymux.c
index 98e9b830..cdefb796 100644
--- a/src/bin/termtymux.c
+++ b/src/bin/termtymux.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include "termtymux.h"
+#include "termptyblock.h"
#include "termptyops.h"
#include "backlog.h"
#include "backlog_view.h"
@@ -97,6 +98,7 @@ termtymux_modes_apply(Termpty *ty, const TermSrvMsgNotify *notify)
ty->mouse_ext = notify->mouse_ext;
ty->bracketed_paste = notify->bracketed_paste ? 1 : 0;
ty->focus_reporting = notify->focus_reporting ? 1 : 0;
+ ty->block.published = notify->has_blocks ? 1 : 0;
}
Eina_Bool
@@ -618,6 +620,85 @@ _link_resolve(void *data, Termpty *ty, uint16_t id)
link->refcount = LINK_REFS_HELD;
}
+/* Whether the user lets a session's blocks load: a block names a path or an
+ * edje file the session chose. */
+static Eina_Bool
+_block_allowed(const Termpty *ty)
+{
+ return ty->config && ty->config->ty_escapes;
+}
+
+/* Frees the block id the way the daemon's cells would, as no cell here
+ * counts it. */
+static void
+_block_drop(Termpty *ty, int id)
+{
+ Termblock *blk;
+
+ if (!ty->block.blocks)
+ return;
+ blk = eina_hash_find(ty->block.blocks, &id);
+ if (!blk)
+ return;
+ ty->block.active = eina_list_remove(ty->block.active, blk);
+ eina_hash_del(ty->block.blocks, &id, blk);
+}
+
+/* Makes the block id the table's for the frame on show: a block is made the
+ * first time it is read, and again when the id gets a new one. None when the
+ * session has no block for the id, or the user turned its escapes off. */
+static void
+_block_resolve(void *data, Termpty *ty, int id)
+{
+ TermTymux *ts = data;
+ Termblock *blk;
+ uint32_t generation, length;
+ int res;
+
+ if ((unsigned int)id >= TERMSRV_TABLE_BLOCKS)
+ return;
+ if (!ts->block_generations)
+ {
+ ts->block_generations = calloc(TERMSRV_TABLE_BLOCKS, sizeof(uint32_t));
+ if (!ts->block_generations)
+ return;
+ }
+ if (!_block_allowed(ty))
+ {
+ _block_drop(ty, id);
+ ts->block_generations[id] = 0;
+ return;
+ }
+ generation = termsrv_table_generation_get(TERMSRV_SHM_TABLE(ts->shm),
+ TERMSRV_TABLE_BLOCK, id,
+ ts->shown_seq);
+ if (generation && (generation == ts->block_generations[id]))
+ return;
+ res = generation ? termsrv_table_read(TERMSRV_SHM_TABLE(ts->shm),
+ TERMSRV_TABLE_BLOCK, id,
+ ts->shown_seq, &generation,
+ &ts->block_record,
+ &ts->block_record_cap, &length) : 0;
+ _block_drop(ty, id);
+ ts->block_generations[id] = (res == 1) ? generation : 0;
+ if (res != 1)
+ return;
+ blk = calloc(1, sizeof(Termblock));
+ if (!blk)
+ return;
+ if (!termpty_block_deserialize(blk, ts->block_record, length) ||
+ (!ty->block.blocks &&
+ !(ty->block.blocks =
+ eina_hash_int32_new((Eina_Free_Cb)termpty_block_free))))
+ {
+ termpty_block_free(blk);
+ return;
+ }
+ blk->pty = ty;
+ blk->id = id;
+ eina_hash_add(ty->block.blocks, &id, blk);
+}
+
/* The daemon holds the pages [first_id, first_id + count), the last one
* being the head. */
static void
@@ -863,6 +944,10 @@ _msg_handle(TermTymux *ts, int type, void *payload, uint32_t size, int fd)
termtymux_frame_apply(ty, &frame, ts->frame_cells))
{
termtymux_modes_apply(ty, notify);
+ /* a frame newer than the notify may show the first block,
+ * which only a newer notify tells of */
+ if (frame.seq > notify->write_seq)
+ ty->block.published = 1;
/* the links are as the first_page_id the notify came with
* says: a newer frame may already show ids reused since */
ts->shown_seq = MIN(frame.seq, notify->write_seq);
@@ -1096,6 +1181,7 @@ termtymux_new(const char *name, int cols, int rows, Config *config,
ts->shadow_pty = ty;
ty->backlog_view = ts->view;
ty->resolver.link = _link_resolve;
+ ty->resolver.block = _block_resolve;
ty->resolver.data = ""
ts->shell_pid = (attached.shell_pid > 0) ? (pid_t)attached.shell_pid : -1;
@@ -1154,6 +1240,8 @@ termtymux_free(TermTymux *ts)
free(ts->frame_cells);
free(ts->link_generations);
free(ts->link_record);
+ free(ts->block_generations);
+ free(ts->block_record);
eina_binbuf_free(ts->chord_out);
eina_stringshare_del(ts->name);
if (ts->shadow_pty) termpty_free(ts->shadow_pty);
@@ -1584,6 +1672,145 @@ tytest_termtymux_link_resolve(void)
return 0;
}
+/* Test: the resolver makes a block once per generation and drops it with
+ * its entry, a record that does not parse leaves none, no cell counts a
+ * block, and a user without escapes sees none. */
+int
+tytest_termtymux_block_resolve(void)
+{
+ TermSrvShmHeader *shm = calloc(1, TERMSRV_SHM_TOTAL_SIZE);
+ TermSrvTableWriter *writer;
+ Termpty *ty = _tt_test_pty_new(4, 4);
+ Config config = { 0 };
+ TermTymux ts = { .shm = shm };
+ Termblock src = { .w = 2, .h = 3, .path = "/tmp/a.png", .edje = 1 };
+ Termblock *blk;
+ char record[64];
+ uint32_t length;
+
+ assert(shm && ty);
+ writer = termsrv_table_writer_new(TERMSRV_SHM_TABLE(shm));
+ assert(writer);
+ ty->config = &config;
+ ty->resolver.block = _block_resolve;
+ ty->resolver.data = ""
+ ts.shown_seq = 4;
+
+ length = termpty_block_serialize(&src, record, sizeof(record));
+ assert(length && length <= sizeof(record));
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 1, record,
+ length, 4));
+ assert(termpty_block_get(ty, 1) == NULL);
+ assert(ty->block.blocks == NULL);
+
+ config.ty_escapes = EINA_TRUE;
+ ts.shown_seq = 2;
+ assert(termpty_block_get(ty, 1) == NULL);
+ ts.shown_seq = 4;
+ blk = termpty_block_get(ty, 1);
+ assert(blk && blk->w == 2 && blk->h == 3 && blk->edje);
+ assert(!strcmp(blk->path, "/tmp/a.png"));
+ assert((blk->pty == ty) && (blk->id == 1) && (blk->refs == 0));
+ assert(blk == termpty_block_get(ty, 1));
+
+ /* cells do not count it */
+ termpty_handle_block_codepoint_overwrite_heavy(ty, 0x80000000 | (1 << 18),
+ 0);
+ termpty_block_refs_release(ty, 1, 1);
+ assert(blk == termpty_block_get(ty, 1));
+
+ /* another block takes the id: the one shown goes with its object */
+ ty->block.active = eina_list_append(ty->block.active, blk);
+ src.w = 5;
+ length = termpty_block_serialize(&src, record, sizeof(record));
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 1, record,
+ length, 4));
+ blk = termpty_block_get(ty, 1);
+ assert(blk && blk->w == 5);
+ assert(ty->block.active == NULL);
+
+ /* a record that is not one, or has an impossible size */
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 2, record,
+ length - 1, 4));
+ assert(termpty_block_get(ty, 2) == NULL);
+ src.w = 0;
+ length = termpty_block_serialize(&src, record, sizeof(record));
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 2, record,
+ length, 4));
+ assert(termpty_block_get(ty, 2) == NULL);
+ assert(ts.block_generations[2]);
+ src.w = 2;
+ src.path = NULL;
+ src.edje = 0;
+ length = termpty_block_serialize(&src, record, sizeof(record));
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 3, record,
+ length, 4));
+ assert(termpty_block_get(ty, 3) == NULL);
+ assert(ts.block_generations[3]);
+ src.path = "/tmp/a.png";
+ src.edje = 1;
+ assert(termpty_block_get(ty, TERMSRV_TABLE_BLOCKS) == NULL);
+ assert(termpty_block_get(ty, -1) == NULL);
+
+ /* no entry for the frame on show */
+ termsrv_table_unpublish(writer, TERMSRV_TABLE_BLOCK, 1);
+ assert(termpty_block_get(ty, 1) == NULL);
+ assert(eina_hash_population(ty->block.blocks) == 0);
+
+ /* escapes turned off take the block away, and back give it again */
+ src.w = 2;
+ length = termpty_block_serialize(&src, record, sizeof(record));
+ assert(termsrv_table_publish(writer, TERMSRV_TABLE_BLOCK, 1, record,
+ length, 4));
+ assert(termpty_block_get(ty, 1));
+ config.ty_escapes = EINA_FALSE;
+ assert(termpty_block_get(ty, 1) == NULL);
+ config.ty_escapes = EINA_TRUE;
+ assert(termpty_block_get(ty, 1));
+
+ ty->resolver.block = NULL;
+ termpty_free(ty);
+ free(ts.block_generations);
+ free(ts.block_record);
+ termsrv_table_writer_free(writer);
+ free(shm);
+ return 0;
+}
+
+/* Test: a frame newer than its notify may hold the first block of the
+ * session: its cells must not be drawn as text meanwhile. */
+int
+tytest_termtymux_block_notify_race(void)
+{
+ TermSrvShmHeader *shm = calloc(1, TERMSRV_SHM_TOTAL_SIZE);
+ Termpty *ty = _tt_test_pty_new(4, 4);
+ TermTymux ts = { .shm = shm, .shadow_pty = ty };
+ TermSrvMsgNotify notify = { 0 };
+
+ assert(shm && ty);
+ shm->cols = 4;
+ shm->rows = 4;
+ termsrv_shm_write_begin(shm);
+ assert(termsrv_shm_write_end(shm) == 2);
+ termsrv_shm_write_begin(shm);
+ assert(termsrv_shm_write_end(shm) == 4);
+
+ notify.write_seq = 2;
+ assert(!_msg_handle(&ts, TSRV_MSG_NOTIFY, ¬ify,
+ offsetof(TermSrvMsgNotify, reserved), -1));
+ assert(ty->block.published);
+
+ notify.write_seq = 4;
+ assert(!_msg_handle(&ts, TSRV_MSG_NOTIFY, ¬ify,
+ offsetof(TermSrvMsgNotify, reserved), -1));
+ assert(!ty->block.published);
+
+ termpty_free(ty);
+ free(ts.frame_cells);
+ free(shm);
+ return 0;
+}
+
/* Test: a frame newer than its notify does not let a link reused since show:
* the notify carries the first_page_id the links are checked against. */
int
@@ -1717,10 +1944,13 @@ tytest_termtymux_modes_apply(void)
TermSrvMsgNotify notify = { .appcursor = 1, .appkeypad = 1,
.mouse_mode = MOUSE_NORMAL_ALL_MOVE,
.mouse_ext = MOUSE_EXT_SGR,
- .bracketed_paste = 1, .focus_reporting = 1 };
+ .bracketed_paste = 1, .focus_reporting = 1,
+ .has_blocks = 1 };
assert(ty);
+ assert(!ty->block.published);
termtymux_modes_apply(ty, ¬ify);
+ assert(ty->block.published);
assert(ty->termstate.appcursor == 1);
assert(ty->termstate.alt_kp == 1);
assert(ty->mouse_mode == MOUSE_NORMAL_ALL_MOVE);
@@ -1732,6 +1962,7 @@ tytest_termtymux_modes_apply(void)
termtymux_modes_apply(ty, ¬ify);
assert(ty->termstate.appcursor == 0);
assert(ty->bracketed_paste == 0);
+ assert(!ty->block.published);
termpty_free(ty);
return 0;
diff --git a/src/bin/termtymux.h b/src/bin/termtymux.h
index e4b61b94..09a1ec88 100644
--- a/src/bin/termtymux.h
+++ b/src/bin/termtymux.h
@@ -64,6 +64,9 @@ struct _TermTymux
uint32_t *link_generations; /* per link id, when it was read */
void *link_record; /* scratch buffer for the table reads */
uint32_t link_record_cap;
+ uint32_t *block_generations; /* per block id, when it was read */
+ void *block_record; /* scratch buffer for the table reads */
+ uint32_t block_record_cap;
};
/* Resize ty's screen buffers to frame->cols x frame->rows if they differ,
diff --git a/src/bin/tymux.c b/src/bin/tymux.c
index 120d67b5..dc2c2593 100644
--- a/src/bin/tymux.c
+++ b/src/bin/tymux.c
@@ -246,7 +246,8 @@ static void
_out_cell(Eina_Strbuf *out, Pen *pen, const TermSrvCell *cell)
{
_out_att(out, pen, &cell->att);
- if (cell->codepoint < ' ' || cell->codepoint == 0x7f)
+ if (cell->codepoint < ' ' || cell->codepoint == 0x7f ||
+ (cell->codepoint & 0x80000000))
_out_printf(out, " ");
else
_out_codepoint(out, cell->codepoint);
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 9c4ca91f..c61b8c3b 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -110,6 +110,7 @@ static struct {
{ "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_serialize", tytest_termpty_block_serialize},
{ "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},
@@ -289,6 +290,8 @@ static struct {
{ "termsrv_shm_fd_valid", tytest_termsrv_shm_fd_valid},
{ "termtymux_link_resolve", tytest_termtymux_link_resolve},
{ "termtymux_link_notify_epoch", tytest_termtymux_link_notify_epoch},
+ { "termtymux_block_resolve", tytest_termtymux_block_resolve},
+ { "termtymux_block_notify_race", tytest_termtymux_block_notify_race},
{ "termtymux_frame_apply_invalid", tytest_termtymux_frame_apply_invalid},
{ "termtymux_modes_apply", tytest_termtymux_modes_apply},
{ "termtymux_input_chunks_send", tytest_termtymux_input_chunks_send},
@@ -342,6 +345,7 @@ static const struct {
{ "tymux_live_focus_restores", tytest_tymux_live_focus_restores},
{ "tymux_live_resume_size", tytest_tymux_live_resume_size},
{ "tymux_live_links", tytest_tymux_live_links},
+ { "tymux_live_blocks", tytest_tymux_live_blocks},
#endif
{ NULL, NULL},
};
diff --git a/src/bin/tytest_tymux.c b/src/bin/tytest_tymux.c
index d7753d5a..6d9bb32a 100644
--- a/src/bin/tytest_tymux.c
+++ b/src/bin/tytest_tymux.c
@@ -2616,3 +2616,101 @@ tytest_tymux_live_links(void)
{
return tytest_tymux_live_run(_live_links_body);
}
+
+#define BLOCK_PATH "/tmp/a.png"
+
+static Eina_Bool
+_screen_block_find(Termpty *ty, int *id_ret, int *y_ret)
+{
+ int x, y, bx, by, id;
+
+ for (y = 0; y < ty->h; y++)
+ for (x = 0; x < ty->w; x++)
+ {
+ id = termpty_block_id_get(termpty_cell_get(ty, y, x), &bx, &by);
+ if (id >= 0)
+ {
+ *id_ret = id;
+ *y_ret = y;
+ return EINA_TRUE;
+ }
+ }
+ return EINA_FALSE;
+}
+
+static Eina_Bool
+_block_screen_done(void *data)
+{
+ int id, y;
+
+ return _screen_block_find(data, &id, &y) &&
+ (termpty_block_get(data, id) != NULL);
+}
+
+typedef struct
+{
+ Termpty *ty;
+ int id;
+} Block_Id;
+
+static Eina_Bool
+_block_gone(void *data)
+{
+ Block_Id *block = data;
+
+ return termpty_block_get(block->ty, block->id) == NULL;
+}
+
+static int
+_live_blocks_body(void)
+{
+ TermTymux *ts, *ts2;
+ Termpty *ty, *ty2;
+ Termblock *blk;
+ Block_Id gone;
+ int id, y;
+
+ assert(tytest_tymux_start(SESSION, 80, 24, &ts, &ty));
+ termtymux_resize(ts, 80, SCREEN_ROWS);
+ assert(tytest_tymux_wait(_screen_rows_done, ty, 5.0));
+ assert(tytest_tymux_wait(_prompt_done, ty, 5.0));
+
+ assert(tytest_tymux_type(ts, ty,
+ "printf '\\033}isX2;2;" BLOCK_PATH "\\000\\033}ib\\000XXXX"
+ "\\033}ie\\000\\n'\n"));
+ assert(tytest_tymux_wait(_block_screen_done, ty, 5.0));
+ assert(_screen_block_find(ty, &id, &y));
+ blk = termpty_block_get(ty, id);
+ assert(blk && blk->w == 2 && blk->h == 2 && blk->scale_stretch);
+ assert(!strcmp(blk->path, BLOCK_PATH));
+ assert(ty->block.published);
+
+ /* a user who turned the escapes off gets nothing of the session */
+ ty->config->ty_escapes = EINA_FALSE;
+ assert(termpty_block_get(ty, id) == NULL);
+ ty->config->ty_escapes = EINA_TRUE;
+ assert(termpty_block_get(ty, id));
+
+ termtymux_free(ts);
+ assert(tytest_tymux_start(SESSION, 80, 24, &ts2, &ty2));
+ termtymux_resize(ts2, 80, SCREEN_ROWS);
+ assert(tytest_tymux_wait(_block_screen_done, ty2, 5.0));
+ assert(_screen_block_find(ty2, &id, &y));
+ blk = termpty_block_get(ty2, id);
+ assert(blk && blk->w == 2 && !strcmp(blk->path, BLOCK_PATH));
+
+ gone.ty = ty2;
+ gone.id = id;
+ assert(tytest_tymux_wait(_prompt_done, ty2, 5.0));
+ assert(tytest_tymux_type(ts2, ty2, "printf '\\033c'\n"));
+ assert(tytest_tymux_wait(_block_gone, &gone, 5.0));
+
+ tytest_tymux_stop(ts2);
+ return 0;
+}
+
+int
+tytest_tymux_live_blocks(void)
+{
+ return tytest_tymux_live_run(_live_blocks_body);
+}
diff --git a/src/bin/tytest_tymux.h b/src/bin/tytest_tymux.h
index 0dd88574..7ea20e1f 100644
--- a/src/bin/tytest_tymux.h
+++ b/src/bin/tytest_tymux.h
@@ -61,5 +61,6 @@ int tytest_tymux_live_pages_read_only(void);
int tytest_tymux_live_focus_restores(void);
int tytest_tymux_live_resume_size(void);
int tytest_tymux_live_links(void);
+int tytest_tymux_live_blocks(void);
#endif
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 58fcb632..ffd49536 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -7,6 +7,7 @@ typedef int (*tytest_func)(void);
/* list of tests */
int tytest_dummy(void);
int tytest_termpty_block_command(void);
+int tytest_termpty_block_serialize(void);
int tytest_termpty_block_channel_find(void);
int tytest_termpty_block_channel_find_newer_claims(void);
int tytest_write_hook(void);
@@ -229,6 +230,8 @@ int tytest_termtymux_frame_read_grow(void);
int tytest_termsrv_shm_fd_valid(void);
int tytest_termtymux_link_resolve(void);
int tytest_termtymux_link_notify_epoch(void);
+int tytest_termtymux_block_resolve(void);
+int tytest_termtymux_block_notify_race(void);
int tytest_termtymux_frame_apply_invalid(void);
int tytest_termtymux_modes_apply(void);
int tytest_termtymux_input_chunks_send(void);
diff --git a/tests/meson.build b/tests/meson.build
index 6ae2cfd9..121bb7ec 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -107,7 +107,8 @@ if tests
'tymux_live_scrollback_zero', 'tymux_live_fd_budget',
'tymux_live_fd_starved',
'tymux_live_page_async', 'tymux_live_paste',
- 'tymux_live_pages_read_only', 'tymux_live_resume_size'],
+ 'tymux_live_pages_read_only', 'tymux_live_resume_size',
+ 'tymux_live_blocks'],
depends: [tymuxd],
timeout: 120)
# Sends tens of MiB of links through a session: apart, for its time.
diff --git a/tests/tymux.py b/tests/tymux.py
index c91e1d45..3ac39def 100644
--- a/tests/tymux.py
+++ b/tests/tymux.py
@@ -291,6 +291,14 @@ def main():
% (code, re.escape(word.encode())), a.out) is not None,
"%s text keeps its attribute" % name)
+ # the cells of a media block hold no text for a terminal that draws only
+ # text
+ a.send("printf '\\033}isX2;1;/tmp/a.png\\000\\033}ib\\000XX"
+ "\\033}ie\\000|B'L'K|\\n'\r")
+ a.expect("|BLK|")
+ check(re.search(rb" {2}(\033\[[0-9;]*m)*\|BLK\|", a.out) is not None,
+ "the cells of a media block are drawn as spaces")
+
a.resize(30, 100)
os.kill(a.pid, signal.SIGWINCH)
a.idle(0.3)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.