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 489cc4ef42c6a138e73f61c8858332b67866053e
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 20 01:24:16 2026 -0600

    tymuxd: size the scrollback from the terminology config
    
    tymuxd kept a fixed 10000 lines whatever the user set in Terminology.
    Read the scrollback with config_load(), the loader Terminology uses,
    once as the daemon starts: a running session keeps its size. Without a
    config file the default of config_new() applies, and a scrollback below
    1 gives the session one page instead of keeping the daemon from
    starting.
    
    The live tests, tymux.py and tybenchd now run the daemon with a private
    XDG_CONFIG_HOME, so none of them depends on the user's config. The live
    tests and tybenchd pin the 10000 lines the daemon used to have.
---
 man/tymux.1            |   3 +-
 src/bin/meson.build    |   6 ++-
 src/bin/termd_tymux.c  |  18 ++++++++-
 src/bin/termd_tymux.h  |   8 +++-
 src/bin/tybenchd.c     |  51 ++++++++++++++++++++++++
 src/bin/tymuxd_stubs.c |  12 +++---
 src/bin/tytest.c       |   3 ++
 src/bin/tytest_tymux.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/bin/tytest_tymux.h |   2 +
 tests/meson.build      |   3 +-
 tests/tymux.py         |   4 +-
 11 files changed, 199 insertions(+), 17 deletions(-)

diff --git a/man/tymux.1 b/man/tymux.1
index 38c1f81a..0a99d77d 100644
--- a/man/tymux.1
+++ b/man/tymux.1
@@ -200,7 +200,8 @@ miniview work on it like on any other terminal. Hyperlinks in that backlog
 are not: the daemon does not send the link targets, only inert text. A
 terminal that attaches keeps as many of the lines the daemon holds as its
 own scrollback setting allows, the oldest ones being dropped first; the
-daemon itself holds up to 10000. The
+daemon itself holds as many as the scrollback setting of Terminology's
+configuration when the session started. The
 inline proxy still has no scrollback of its own.
 .PP
 When proxied (not natively handed off), the attached terminal is also
diff --git a/src/bin/meson.build b/src/bin/meson.build
index 18e12a86..bae139c9 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -242,6 +242,7 @@ if host_os == 'linux'
                     'termptystatus.c', 'termptystatus.h',
                     'backlog.c', 'backlog.h',
                     'colors.c', 'colors.h',
+                    'config.c', 'config.h',
                     'sb.c', 'sb.h',
                     'utf8.c', 'utf8.h',
                     'utils.c', 'utils.h',
@@ -340,9 +341,10 @@ if benchmarks
              dependencies: terminology_dependencies)
   if host_os == 'linux'
     tybenchd = executable('tybenchd',
-                          ['tybenchd.c', 'termsrv.c', 'termsrv.h'],
+                          ['tybenchd.c', 'termsrv.c', 'termsrv.h',
+                           'config.c', 'config.h', 'colors.c', 'colors.h'],
                           install: false,
                           include_directories: config_dir,
-                          dependencies: [eina_dep, ecore_dep])
+                          dependencies: terminology_dependencies)
   endif
 endif
diff --git a/src/bin/termd_tymux.c b/src/bin/termd_tymux.c
index 72b57f18..f0741dbe 100644
--- a/src/bin/termd_tymux.c
+++ b/src/bin/termd_tymux.c
@@ -707,6 +707,20 @@ _cb_backlog_timer(void *data)
    return ECORE_CALLBACK_RENEW;
 }
 
+uint32_t
+termd_tymux_scrollback_get(void)
+{
+   Config *config;
+   int scrollback;
+
+   config_init();
+   config = config_load();
+   scrollback = config ? config->scrollback : 0;
+   config_del(config);
+   config_shutdown();
+   return scrollback < 1 ? 1 : scrollback;
+}
+
 TermDTymux *
 termd_tymux_new(const char *name, const char *cmd)
 {
@@ -761,8 +775,8 @@ termd_tymux_new(const char *name, const char *cmd)
     * the session's is in memfds, for the clients to map */
    termpty_backlog_store_backing_set(td->pty, BACKLOG_STORE_MEMFD);
    td->pty->backlog_head_only = 1;
-   td->config->scrollback = TERMD_TYMUX_SCROLLBACK;
-   termpty_backlog_size_set(td->pty, TERMD_TYMUX_SCROLLBACK);
+   td->config->scrollback = termd_tymux_scrollback_get();
+   termpty_backlog_size_set(td->pty, td->config->scrollback);
    if (!td->pty->backlog_store)
      goto err;
    td->backlog_timer = ecore_timer_add(BACKLOG_MAINTAIN_SECONDS,
diff --git a/src/bin/termd_tymux.h b/src/bin/termd_tymux.h
index c3eaafed..1c4c50b2 100644
--- a/src/bin/termd_tymux.h
+++ b/src/bin/termd_tymux.h
@@ -1,10 +1,14 @@
 #ifndef TERMINOLOGY_TERMD_TYMUX_H_
 #define TERMINOLOGY_TERMD_TYMUX_H_ 1
 
+#include <stdint.h>
+
 typedef struct tag_TermDTymux TermDTymux;
 
-/* Lines of scrollback the session keeps, in the pages clients map. */
-#define TERMD_TYMUX_SCROLLBACK 10000
+/* Lines of scrollback the session keeps, in the pages clients map: the
+ * scrollback of the Terminology config of the user, or its default when
+ * there is none, and at least 1: a page. */
+uint32_t termd_tymux_scrollback_get(void);
 
 /* Start the shell (cmd, or the user's shell if NULL) on a new pty whose
  * screen is published in shared memory. The main loop is quit when the
diff --git a/src/bin/tybenchd.c b/src/bin/tybenchd.c
index 4a77989d..08937564 100644
--- a/src/bin/tybenchd.c
+++ b/src/bin/tybenchd.c
@@ -19,10 +19,13 @@
 #include <unistd.h>
 #include <Eina.h>
 #include <Ecore.h>
+#include <Ecore_File.h>
+#include "config.h"
 #include "termsrv.h"
 
 #define DEFAULT_ITERATIONS 5
 #define DEFAULT_LINES      100000
+#define DAEMON_SCROLLBACK  10000
 
 typedef struct
 {
@@ -30,6 +33,45 @@ typedef struct
    long   notifies;
 } Run;
 
+int _log_domain = -1;
+
+/* config_save() has nobody to tell here. */
+void
+main_config_sync(const Config *config EINA_UNUSED)
+{
+}
+
+static char _config_home[] = "/tmp/tybenchd-XXXXXX";
+static bool _config_home_made = false;
+
+/* The daemon reads its scrollback from the Terminology config: give it a
+ * private one, so the numbers do not depend on the user's settings. */
+static int
+_config_home_pin(void)
+{
+   Config *config;
+   int level = eina_log_domain_registered_level_get(_log_domain);
+
+   if (!mkdtemp(_config_home))
+     return -1;
+   _config_home_made = true;
+   setenv("XDG_CONFIG_HOME", _config_home, 1);
+   config_init();
+   /* the color scheme lookup of config_new() finds no theme data in a build
+    * tree, and does not matter here */
+   eina_log_domain_level_set("tybenchd", EINA_LOG_LEVEL_CRITICAL);
+   config = config_new();
+   eina_log_domain_level_set("tybenchd", level);
+   if (config)
+     {
+        config->scrollback = DAEMON_SCROLLBACK;
+        config_save(config);
+        config_del(config);
+     }
+   config_shutdown();
+   return 0;
+}
+
 static double
 _now(void)
 {
@@ -194,6 +236,12 @@ _main(int argc, char **argv)
    /* a plain shell: the startup files of the user's shell are not what is
     * measured */
    setenv("SHELL", "/bin/sh", 1);
+   if (_config_home_pin() < 0)
+     {
+        perror("tybenchd");
+        free(runs);
+        return 1;
+     }
    if (termsrv_ensure_tymux_dir() < 0)
      {
         perror("tybenchd");
@@ -242,7 +290,10 @@ main(int argc, char **argv)
    /* no use for power/timezone/D-Bus system monitoring in a benchmark */
    ecore_app_no_system_modules();
    ecore_init();
+   _log_domain = eina_log_domain_register("tybenchd", NULL);
    ret = _main(argc, argv);
+   if (_config_home_made)
+     ecore_file_recursive_rm(_config_home);
    ecore_shutdown();
    eina_shutdown();
    return ret;
diff --git a/src/bin/tymuxd_stubs.c b/src/bin/tymuxd_stubs.c
index 31e0d2f7..74391c21 100644
--- a/src/bin/tymuxd_stubs.c
+++ b/src/bin/tymuxd_stubs.c
@@ -27,6 +27,12 @@ tymuxd_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,
    if (a) *a = ca;
 }
 
+/* The config is only read here: there is no window to tell about a save. */
+void
+main_config_sync(const Config *config EINA_UNUSED)
+{
+}
+
 void
 termio_scroll(Evas_Object *obj EINA_UNUSED, int direction EINA_UNUSED,
               int start_y EINA_UNUSED, int end_y EINA_UNUSED)
@@ -141,12 +147,6 @@ termio_selection_buffer_get_cb(Evas_Object *obj EINA_UNUSED,
 {
 }
 
-const char *
-config_term_type_name(int term_type EINA_UNUSED)
-{
-   return "xterm-256color";
-}
-
 Cursor_Shape
 termio_cursor_shape_get(const Evas_Object *obj EINA_UNUSED)
 {
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 90f1b3ef..4e43f6e8 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -252,6 +252,9 @@ static const struct {
        { "tymux_live_compress", tytest_tymux_live_compress},
        { "tymux_live_resize_no_dup", tytest_tymux_live_resize_no_dup},
        { "tymux_live_clear", tytest_tymux_live_clear},
+       { "tymux_live_scrollback_config",
+         tytest_tymux_live_scrollback_config},
+       { "tymux_live_scrollback_zero", tytest_tymux_live_scrollback_zero},
 #endif
        { NULL, NULL},
 };
diff --git a/src/bin/tytest_tymux.c b/src/bin/tytest_tymux.c
index 447279b9..70b9d415 100644
--- a/src/bin/tytest_tymux.c
+++ b/src/bin/tytest_tymux.c
@@ -16,11 +16,13 @@
 #include "config.h"
 #include "tytest_tymux.h"
 #include "backlog.h"
+#include "backlog_store.h"
 #include "backlog_window.h"
 #include "utf8.h"
 
 #define LIVE_TIMEOUT_SECONDS 100
 #define DAEMON_EXIT_TIMEOUT_SECONDS 5.0
+#define DAEMON_SCROLLBACK 10000
 
 #define RUNTIME_DIR_TEMPLATE "/tmp/tytest-tymux-XXXXXX"
 static char _runtime_dir[] = RUNTIME_DIR_TEMPLATE;
@@ -71,12 +73,28 @@ _environment_setup(void)
    unsetenv("STY");
    unsetenv("TYMUX_NO_NATIVE");
    setenv("XDG_RUNTIME_DIR", _runtime_dir, 1);
+   setenv("XDG_CONFIG_HOME", _runtime_dir, 1);
    setenv("SHELL", "/bin/sh", 1);
    setenv("PS1", "$ ", 1);
    setenv("TERM", "xterm-256color", 1);
    _rc_file_write();
 }
 
+/* What tymuxd reads, as it starts, for the scrollback of its session. */
+static void
+_daemon_scrollback_set(int scrollback)
+{
+   Config *config;
+
+   config_init();
+   config = config_new();
+   assert(config);
+   config->scrollback = scrollback;
+   config_save(config);
+   config_del(config);
+   config_shutdown();
+}
+
 /* The tymuxd processes that have our XDG_RUNTIME_DIR in their environment,
  * whatever session they were started for. */
 static void
@@ -178,6 +196,7 @@ tytest_tymux_live_run(int (*body)(void))
 
         alarm(LIVE_TIMEOUT_SECONDS);
         ecore_init();
+        _daemon_scrollback_set(DAEMON_SCROLLBACK);
         ret = body();
         if (_config) config_del(_config);
         ecore_shutdown();
@@ -205,7 +224,7 @@ tytest_tymux_start(const char *name, int cols, int rows,
      {
         _config = config_new();
         assert(_config);
-        _config->scrollback = 10000;
+        _config->scrollback = DAEMON_SCROLLBACK;
      }
    *ts = termtymux_new(name, cols, rows, _config, TSRV_ATTACH_HIJACK, ty);
    return *ts != NULL;
@@ -1385,3 +1404,88 @@ tytest_tymux_live_clear(void)
 {
    return tytest_tymux_live_run(_live_clear_body);
 }
+
+#define CONFIG_SCROLLBACK 300
+
+/* The numbers up to the last one are in the backlog, and the shell is back
+ * at its prompt: nothing more is coming. */
+static Eina_Bool
+_config_seq_finished(void *data)
+{
+   return _backlog_find(data, "1990") != 0 && _prompt_done(data);
+}
+
+/* The daemon sizes its scrollback from the Terminology config of the
+ * user, read once as it starts: the store rounds it up to whole pages. */
+static int
+_live_scrollback_config_body(void)
+{
+   BacklogStoreGeometry geo;
+   TermTymux *ts;
+   Termpty *ty;
+   char *oldest, *newest;
+   int count;
+
+   _daemon_scrollback_set(CONFIG_SCROLLBACK);
+   backlog_store_geometry_get(CONFIG_SCROLLBACK, sysconf(_SC_PAGESIZE), &geo);
+
+   assert(tytest_tymux_start(SESSION, 80, 24, &ts, &ty));
+   termpty_backlog_viewport_set(ts->shadow_pty, 0);
+   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, "seq 1 2000\n"));
+   assert(tytest_tymux_wait(_config_seq_finished, ty, 20.0));
+
+   termpty_backlog_viewport_set(ts->shadow_pty, termpty_backlog_length(ty));
+   count = _backlog_entries(ty);
+   assert(count >= (int)geo.max_entries);
+   assert(count < (int)(geo.max_entries + geo.entries_per_page));
+   newest = tytest_tymux_backlog_line(ty, 1);
+   oldest = tytest_tymux_backlog_line(ty, count);
+   assert(newest && oldest);
+   assert(atoi(oldest) == atoi(newest) - count + 1);
+   free(newest);
+   free(oldest);
+
+   tytest_tymux_stop(ts);
+   return 0;
+}
+
+int
+tytest_tymux_live_scrollback_config(void)
+{
+   return tytest_tymux_live_run(_live_scrollback_config_body);
+}
+
+static Eina_Bool
+_zero_seq_finished(void *data)
+{
+   return _backlog_find(data, "190") != 0 && _prompt_done(data);
+}
+
+/* A scrollback of 0 in the config still gives the session a page. */
+static int
+_live_scrollback_zero_body(void)
+{
+   TermTymux *ts;
+   Termpty *ty;
+
+   _daemon_scrollback_set(0);
+   assert(tytest_tymux_start(SESSION, 80, 24, &ts, &ty));
+   termpty_backlog_viewport_set(ts->shadow_pty, 0);
+   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, "seq 1 200\n"));
+   assert(tytest_tymux_wait(_zero_seq_finished, ty, 20.0));
+
+   tytest_tymux_stop(ts);
+   return 0;
+}
+
+int
+tytest_tymux_live_scrollback_zero(void)
+{
+   return tytest_tymux_live_run(_live_scrollback_zero_body);
+}
diff --git a/src/bin/tytest_tymux.h b/src/bin/tytest_tymux.h
index c9152c25..0e6fccd4 100644
--- a/src/bin/tytest_tymux.h
+++ b/src/bin/tytest_tymux.h
@@ -51,5 +51,7 @@ int tytest_tymux_live_window(void);
 int tytest_tymux_live_compress(void);
 int tytest_tymux_live_resize_no_dup(void);
 int tytest_tymux_live_clear(void);
+int tytest_tymux_live_scrollback_config(void);
+int tytest_tymux_live_scrollback_zero(void);
 
 #endif
diff --git a/tests/meson.build b/tests/meson.build
index 3b18d3e5..d22bd416 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -103,7 +103,8 @@ if tests
          args: ['tymux_live_backlog', 'tymux_live_pages',
                 'tymux_live_pages_busy', 'tymux_live_window',
                 'tymux_live_compress', 'tymux_live_resize_no_dup',
-                'tymux_live_clear'],
+                'tymux_live_clear', 'tymux_live_scrollback_config',
+                'tymux_live_scrollback_zero'],
          depends: [tymuxd],
          timeout: 120)
   endif
diff --git a/tests/tymux.py b/tests/tymux.py
index 25796fd1..bb8b44c6 100644
--- a/tests/tymux.py
+++ b/tests/tymux.py
@@ -33,8 +33,8 @@ with open(SHELL_RC, "w") as f:
 ENV = {k: v for k, v in os.environ.items()
        if k not in ("DISPLAY", "WAYLAND_DISPLAY", "TYMUX_NAME",
                     "TERMINOLOGY", "TMUX", "STY", "TYMUX_NO_NATIVE")}
-ENV.update(XDG_RUNTIME_DIR=XDG, SHELL="/bin/sh", PS1="$ ", ENV=SHELL_RC,
-           TERM="xterm-256color")
+ENV.update(XDG_RUNTIME_DIR=XDG, XDG_CONFIG_HOME=XDG, SHELL="/bin/sh",
+           PS1="$ ", ENV=SHELL_RC, TERM="xterm-256color")
 failures = []
 stopped = []
 

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

Reply via email to