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.)
target_link_libraries(q3data m)
endif ()
target_link_libraries(q3data m)
endif ()
-target_link_libraries(q3map2 termcap)
+target_link_libraries(q3map2)
/* dependencies */
#include "q3map2.h"
/* dependencies */
#include "q3map2.h"
-
-
-unsigned terminalColumns = 80;
+#include <sys/ioctl.h>
+static unsigned terminalColumns = 80;
const char* description;
};
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;
void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
{
indentation *= 2;
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");
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;