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

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit 760c8dc84a00a6c4ce1d32f905425ba3445cdd54
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 18 21:50:03 2026 -0600

    termpty: tell the backlog hook when a row extends an entry
    
    A consumer mirroring the backlog needs to know whether
    termpty_text_save_top() merged the row into the entry at the top or
    started a new one. Guessing from the autowrap bit of the previous row
    can diverge, for instance after the backlog is cleared: the next save
    starts a new entry, yet the previous row still looks wrapped. Report
    the decision itself.
---
 src/bin/termd_tymux.c |  2 +-
 src/bin/termpty.c     | 41 ++++++++++++++++++++++++++---------------
 src/bin/termpty.h     |  8 +++++---
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/bin/termd_tymux.c b/src/bin/termd_tymux.c
index c6b9f0f5..de2532d9 100644
--- a/src/bin/termd_tymux.c
+++ b/src/bin/termd_tymux.c
@@ -337,7 +337,7 @@ _td_has_backlog_client(TermDTymux *td)
  * TERMSRV_MAX_COLS by _client_resize(), so it always fits in one message
  * on its own. */
 static void
-_cb_pty_backlog(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w)
+_cb_pty_backlog(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w, Eina_Bool extends EINA_UNUSED)
 {
    TermDTymux *td = data;
    uint32_t off, cols = (uint32_t)w;
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index b257a6e3..73332a53 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1127,7 +1127,7 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
                                           - DIV_ROUND_UP(old_len, ty->w);
 
              if (ty->backlog_hook.func)
-               ty->backlog_hook.func(ty->backlog_hook.data, ty, cells, w);
+               ty->backlog_hook.func(ty->backlog_hook.data, ty, cells, w, EINA_TRUE);
              return;
           }
      }
@@ -1143,7 +1143,7 @@ add_new_ts:
      ty->backpos = 0;
 
    if (ty->backlog_hook.func)
-     ty->backlog_hook.func(ty->backlog_hook.data, ty, cells, w);
+     ty->backlog_hook.func(ty->backlog_hook.data, ty, cells, w, EINA_FALSE);
 
    ty->backlog_beacon.screen_y += termpty_backlog_entry_rows(ty, w);
    ty->backlog_beacon.backlog_y++;
@@ -1366,7 +1366,7 @@ termpty_cell_get(Termpty *ty, int y_requested, int x_requested)
 
 void
 termpty_backlog_hook_set(Termpty *ty,
-                         void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w),
+                         void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w, Eina_Bool extends),
                          void *data)
 {
    ty->backlog_hook.func = func;
@@ -4911,12 +4911,19 @@ _ty_write_hook_capture(void *data, Termpty *ty EINA_UNUSED, const char *input, i
    return EINA_TRUE;
 }
 
-static void
-_ty_backlog_hook_capture(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w)
+typedef struct
 {
-   int *count = data;
+   int count;
+   Eina_Bool last_extends;
+} Ty_Backlog_Capture;
 
-   (*count)++;
+static void
+_ty_backlog_hook_capture(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w, Eina_Bool extends)
+{
+   Ty_Backlog_Capture *capture = data;
+
+   capture->count++;
+   capture->last_extends = extends;
    assert(cells);
    assert(w >= 0);
 }
@@ -4930,7 +4937,7 @@ tytest_backlog_hook(void)
 {
    Termpty ty;
    Termcell cells[10];
-   int count = 0;
+   Ty_Backlog_Capture capture = { 0, EINA_TRUE };
    int j;
 
    _ty_test_init(&ty, 10, 5);
@@ -4946,9 +4953,10 @@ tytest_backlog_hook(void)
     * starting a new entry. */
    cells[9].att.autowrapped = 1;
 
-   termpty_backlog_hook_set(&ty, _ty_backlog_hook_capture, &count);
+   termpty_backlog_hook_set(&ty, _ty_backlog_hook_capture, &capture);
    termpty_text_save_top(&ty, cells, 10);
-   assert(count == 1);
+   assert(capture.count == 1);
+   assert(capture.last_extends == EINA_FALSE);
    assert(termpty_backlog_length(&ty) == 1);
 
    /* extends the entry saved above instead of starting a new one --
@@ -4958,22 +4966,25 @@ tytest_backlog_hook(void)
     * merges further. */
    cells[9].att.autowrapped = 0;
    termpty_text_save_top(&ty, cells, 10);
-   assert(count == 2);
+   assert(capture.count == 2);
+   assert(capture.last_extends == EINA_TRUE);
    assert(termpty_backlog_length(&ty) == 2);
 
    termpty_text_save_top(&ty, cells, 10);
-   assert(count == 3);
+   assert(capture.count == 3);
+   assert(capture.last_extends == EINA_FALSE);
    assert(termpty_backlog_length(&ty) == 3);
 
    /* a blank row has no cells to report and is reported all the same */
    memset(cells, 0, sizeof(cells));
    termpty_text_save_top(&ty, cells, 10);
-   assert(count == 4);
+   assert(capture.count == 4);
+   assert(capture.last_extends == EINA_FALSE);
    assert(termpty_backlog_length(&ty) == 4);
 
    termpty_backlog_hook_set(&ty, NULL, NULL);
    termpty_text_save_top(&ty, cells, 10);
-   assert(count == 4);
+   assert(capture.count == 4);
    assert(termpty_backlog_length(&ty) == 5);
 
    _ty_test_shutdown(&ty);
@@ -5075,7 +5086,7 @@ tytest_backlog_external(void)
  * the exact same merged entry instead of only the first physical row of the
  * wrapped line. A blank row after it is replayed as a blank entry. */
 static void
-_ty_backlog_hook_replay(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w)
+_ty_backlog_hook_replay(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssize_t w, Eina_Bool extends EINA_UNUSED)
 {
    Termpty *dst = data;
 
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 13dd10b1..4f4e785a 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -250,7 +250,7 @@ struct tag_Termpty
       void *data;
    } write_hook;
    struct {
-      void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w);
+      void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w, Eina_Bool extends);
       void *data;
    } backlog_hook;
    struct {
@@ -447,9 +447,11 @@ void       termpty_write_hook_set(Termpty *ty,
  * termpty_text_save_top() (after autowrap marking), not the possibly wider
  * merged Termsave it ends up part of: replaying every call through
  * termpty_text_save_top() again reproduces the same backlog, and each call
- * is at most the screen width wide. A NULL FUNC clears the hook. */
+ * is at most the screen width wide. EXTENDS tells which of the two it was:
+ * EINA_TRUE when the row was merged into the entry already at the top,
+ * EINA_FALSE when it started a new entry. A NULL FUNC clears the hook. */
 void       termpty_backlog_hook_set(Termpty *ty,
-                                    void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w),
+                                    void (*func) (void *data, Termpty *ty, const Termcell *cells, ssize_t w, Eina_Bool extends),
                                     void *data);
 
 void       termpty_resize(Termpty *ty, int new_w, int new_h);

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

Reply via email to