From: Antoine Fontaine Date: Mon, 3 May 2021 19:52:15 +0000 (+0200) Subject: quake3/help: move away from termcap X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=fa5abd8c4ea119b7d60056122cbbd7b02dde4260 quake3/help: move away from termcap termcap is old and crusty. terminfo seems more recent (lol), but maybe we can get away without adding any dependency :) On my system, no -ltermcap exists. (Well, except a compat one provided by zsh for some reason.) --- diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt index 4b30535a..638d867c 100644 --- a/tools/quake3/CMakeLists.txt +++ b/tools/quake3/CMakeLists.txt @@ -193,4 +193,4 @@ if (UNIX) target_link_libraries(q3data m) endif () -target_link_libraries(q3map2 termcap) +target_link_libraries(q3map2) diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index fc77050a..f4fd717b 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -31,9 +31,8 @@ /* dependencies */ #include "q3map2.h" - - -unsigned terminalColumns = 80; +#include +static unsigned terminalColumns = 80; struct HelpOption { @@ -41,6 +40,7 @@ struct HelpOption const char* description; }; +// FIXME: low column width cause an endless loop void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count) { indentation *= 2; @@ -457,18 +457,16 @@ void HelpGames() printf("\n\n"); } -#include - void HelpMain(const char* arg) { printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n"); printf(" q3map2 -help [stage]\n"); printf(" q3map2 -help all\n\n"); - static char termbuf[2048]; - char *termtype = getenv("TERM"); - if (tgetent(termbuf, termtype) >= 0) { - terminalColumns = tgetnum("co"); + struct winsize ws; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); + if (ws.ws_col > 60) { + terminalColumns = ws.ws_col; } HelpCommon();