From 50a7996b4fdb100e812f4350858bde062510e272 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 4 Jul 2021 07:01:50 -0400 Subject: [PATCH] notcurses_detected_terminal: use termdesc_longterm() --- NEWS.md | 5 +++++ doc/OTHERS.md | 1 + include/notcurses/notcurses.h | 6 ++++-- src/fetch/main.c | 2 +- src/lib/notcurses.c | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index f77d66f28..2b65d6dd5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,11 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.3.9 (not yet released) + * `notcurses_detected_terminal()` and `ncdirect_detected_terminal()` now + both return a heap-allocated string, which will contain the terminal + version if Notcurses was able to detect it. This result ought be free()d. + * 2.3.8 (2021-07-04) * Marked all capability functions `__attribute__ ((pure))`. If you were calling `notcurses_check_pixel_support()` before in order to enable pixel diff --git a/doc/OTHERS.md b/doc/OTHERS.md index 1c057831f..03957ffa9 100644 --- a/doc/OTHERS.md +++ b/doc/OTHERS.md @@ -47,3 +47,4 @@ * [Jexer](https://jexer.sourceforge.io/) (Java) * [pygamelib](https://github.com/arnauddupuis/pygamelib) (Python) +* [ctx](https://ctx.graphics/) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 2c58bce6d..7b9154bd2 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1317,8 +1317,10 @@ API unsigned notcurses_supported_styles(const struct notcurses* nc) API unsigned notcurses_palette_size(const struct notcurses* nc) __attribute__ ((nonnull (1))) __attribute__ ((pure)); -API const char* notcurses_detected_terminal(const struct notcurses* nc) - __attribute__ ((nonnull (1))) __attribute__ ((pure)); +// Returns the name (and sometimes version) of the terminal, as Notcurses +// has been best able to determine. +ALLOC API char* notcurses_detected_terminal(const struct notcurses* nc) + __attribute__ ((nonnull (1))); // Can we directly specify RGB values per cell, or only use palettes? API bool notcurses_cantruecolor(const struct notcurses* nc) diff --git a/src/fetch/main.c b/src/fetch/main.c index cc9f3fd55..4d809fe9e 100644 --- a/src/fetch/main.c +++ b/src/fetch/main.c @@ -33,7 +33,7 @@ typedef struct fetched_info { char* kernver; // strdup(uname(2)->version); char* desktop; // getenv("XDG_CURRENT_DESKTOP") const char* shell; // getenv("SHELL") - const char* term; // ncdirect_detected_terminal() + char* term; // ncdirect_detected_terminal(), heap-alloced char* lang; // getenv("LANG") int dimy, dimx; // extracted from xrandr char* cpu_model; // FIXME don't handle hetero setups yet diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 83cd8d875..1dff03f50 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1700,8 +1700,8 @@ unsigned notcurses_palette_size(const notcurses* nc){ return nc->tcache.caps.colors; } -const char* notcurses_detected_terminal(const notcurses* nc){ - return nc->tcache.termname; +char* notcurses_detected_terminal(const notcurses* nc){ + return termdesc_longterm(&nc->tcache); } bool notcurses_cantruecolor(const notcurses* nc){