From 7ed78a31debb0250bae16d8b4098a4689f29bb60 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 12:30:14 +0300 Subject: Take the terminal name from term_options.name The core hard-coded "wsap_term" for XTVERSION, the XTGETTCAP TN and name default, and the OSC 9 notification title. A headless library should take its identity from the host. term_options.name sets the name. NULL or "" selects "term". term_new() copies it and returns NULL unless it is 1 to 63 printable ASCII bytes, since DCS replies echo it. A DCS +p still changes the TN value, and the XTVERSION and notification defaults keep the host name. Co-Authored-By: Claude Haiku 5.5 --- tests/dcs_test.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'tests/dcs_test.c') diff --git a/tests/dcs_test.c b/tests/dcs_test.c index 0e67f78..d9455be 100644 --- a/tests/dcs_test.c +++ b/tests/dcs_test.c @@ -176,8 +176,8 @@ static void test_xtgettcap(void) { struct term *t = new_term(80, 24); assert_tcap(t, "kind", "\033[1;2B"); - assert_tcap(t, "TN", "wsap_term"); - assert_tcap(t, "name", "wsap_term"); + assert_tcap(t, "TN", "term"); + assert_tcap(t, "name", "term"); assert_tcap(t, "Co", "16777216"); assert_tcap(t, "colors", "16777216"); assert_tcap(t, "RGB", "8/8/8"); @@ -230,7 +230,7 @@ static void test_xtgettcap_multi(void) snprintf(req, sizeof(req), "\033P+q%s;%s\033\\", hk, htn); snprintf(want, sizeof(want), "\033P1+r%s=%s;%s=%s\033\\", - hk, hv, htn, "777361705f7465726d"); + hk, hv, htn, "7465726d"); response_len = 0; write_seq(t, req); expect_response(want); @@ -383,7 +383,51 @@ static void test_xtversion(void) struct term *t = new_term(80, 24); response_len = 0; write_seq(t, "\033[>0q"); - expect_response("\033P>|wsap_term\033\\"); + expect_response("\033P>|term\033\\"); + term_free(t); +} + +/* term_options.name feeds XTVERSION and the TN and name capabilities. */ +static void test_host_name(void) +{ + struct term_options opt = { + .size = { .x = 80, .y = 24 }, + .scrollback = TEST_SCROLLBACK, + .name = "myterm", + .callbacks = { .reply = respond }, + }; + struct term *t = term_new(&opt); + assert(t); + response_len = 0; + write_seq(t, "\033[>0q"); + expect_response("\033P>|myterm\033\\"); + assert_tcap(t, "TN", "myterm"); + assert_tcap(t, "name", "myterm"); + + /* A DCS +p sets the capability value. The XTVERSION name does not change. */ + response_len = 0; + write_seq(t, "\033P+p6f74686572\033\\"); + expect_no_response(); + assert_tcap(t, "TN", "other"); + response_len = 0; + write_seq(t, "\033[>0q"); + expect_response("\033P>|myterm\033\\"); + term_free(t); + + /* NULL and "" both select the default. */ + opt.name = ""; + t = term_new(&opt); + assert(t); + response_len = 0; + write_seq(t, "\033[>0q"); + expect_response("\033P>|term\033\\"); + term_free(t); + opt.name = NULL; + t = term_new(&opt); + assert(t); + response_len = 0; + write_seq(t, "\033[>0q"); + expect_response("\033P>|term\033\\"); term_free(t); } @@ -467,6 +511,7 @@ int main(void) test_synchronized_output(); test_ignored_dcs(); test_xtversion(); + test_host_name(); test_bel_terminator(); test_dcs_long_query(); test_dcs_abort_c0(); -- cgit v1.2.3