diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 12:30:14 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 12:30:14 +0300 |
| commit | 7ed78a31debb0250bae16d8b4098a4689f29bb60 (patch) | |
| tree | eda4e03a9c51140f78ef6e8c9f73ebcd0d8eca8b /tests/osc_test.c | |
| parent | 5f03033b0e211f9ed13e7a1351f9a8f9011ab665 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'tests/osc_test.c')
| -rw-r--r-- | tests/osc_test.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/osc_test.c b/tests/osc_test.c index 41a9247..9d08157 100644 --- a/tests/osc_test.c +++ b/tests/osc_test.c @@ -104,6 +104,35 @@ static void reset_captures(void) notify_count = 0; } +/* The notification default is term_options.name. A DCS +p does not change it. */ +static void test_host_name_notify(void) +{ + struct term_options opt = { + .size = { .x = 80, .y = 24 }, + .scrollback = TEST_SCROLLBACK, + .name = "myterm", + .callbacks = { .notify = capture_notify }, + }; + struct term *t = term_new(&opt); + assert(t); + reset_captures(); + write_seq(t, "\033]9;hello\007"); + assert(notify_count == 1); + assert(!strcmp(notify_title, "myterm")); + assert(!strcmp(notify_body, "hello")); + + write_seq(t, "\033P+p6f74686572\033\\"); + reset_captures(); + write_seq(t, "\033]9;again\007"); + assert(notify_count == 1); + assert(!strcmp(notify_title, "myterm")); + + write_seq(t, "\033]777;notify;Title;Body\007"); + assert(notify_count == 2); + assert(!strcmp(notify_title, "Title")); + term_free(t); +} + static void test_osc52(void) { struct term *t = osc_test_term(); @@ -289,7 +318,7 @@ static void test_osc_misc(void) write_seq(t, "\033]9;hello there\033\\"); assert(notify_count == 1); - assert(!strcmp(notify_title, "wsap_term")); + assert(!strcmp(notify_title, "term")); assert(!strcmp(notify_body, "hello there")); write_seq(t, "\033]9;4;3;50\007"); assert(notify_count == 1); @@ -450,6 +479,7 @@ int main(void) test_osc8(); test_sgr_reset_keeps_link(); test_osc_misc(); + test_host_name_notify(); test_osc_colors(); test_osc_legacy_titles(); test_palette_and_theme(); |
