mirror of
https://github.com/ascii-boxes/boxes.git
synced 2024-12-12 09:51:10 +01:00
Do not use ncurses on Windows
Instead, we just assume that on Windows, we always have color-capable terminals.
This commit is contained in:
parent
ba40638946
commit
94de53c6f0
2
Makefile
2
Makefile
@ -121,7 +121,7 @@ $(LIBUNISTRING_DIR)/lib/.libs/libunistring.a: vendor/libunistring-$(LIBUNISTRING
|
|||||||
cd $(LIBUNISTRING_DIR) ; ./configure --enable-static ; $(MAKE)
|
cd $(LIBUNISTRING_DIR) ; ./configure --enable-static ; $(MAKE)
|
||||||
|
|
||||||
vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz: | vendor
|
vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz: | vendor
|
||||||
curl -L http://invisible-mirror.net/archives/ncurses/ncurses-$(LIBNCURSES_VERSION).tar.gz --output $@
|
curl -L https://invisible-mirror.net/archives/ncurses/ncurses-$(LIBNCURSES_VERSION).tar.gz --output $@
|
||||||
|
|
||||||
$(LIBNCURSES_DIR)/lib/libncurses.a: vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz
|
$(LIBNCURSES_DIR)/lib/libncurses.a: vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz
|
||||||
tar -C vendor -xzf vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz
|
tar -C vendor -xzf vendor/libncurses-$(LIBNCURSES_VERSION).tar.gz
|
||||||
|
@ -72,7 +72,7 @@ boxes.static: $(ALL_OBJ) | check_dir
|
|||||||
if [ "$(STRIP)" = "true" ] ; then strip $(BOXES_EXECUTABLE_NAME) ; fi
|
if [ "$(STRIP)" = "true" ] ; then strip $(BOXES_EXECUTABLE_NAME) ; fi
|
||||||
|
|
||||||
boxes.exe: $(ALL_OBJ) | check_dir
|
boxes.exe: $(ALL_OBJ) | check_dir
|
||||||
$(CC) $(LDFLAGS) $^ -o $@ -lkernel32 -l:libunistring.a -l:libpcre2-32.a -l:libiconv.a -l:libncurses.a
|
$(CC) $(LDFLAGS) $^ -o $@ -lkernel32 -l:libunistring.a -l:libpcre2-32.a -l:libiconv.a
|
||||||
if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi
|
if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi
|
||||||
|
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ flags_static:
|
|||||||
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt
|
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt
|
||||||
|
|
||||||
flags_win32:
|
flags_win32:
|
||||||
$(eval CFLAGS := -Os -s -m32 -I. -I$(SRC_DIR) -I$(LIBNCURSES_WIN_INCLUDE) -Wall -W $(CFLAGS_ADDTL))
|
$(eval CFLAGS := -Os -s -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL))
|
||||||
$(eval LDFLAGS := $(LDFLAGS) -s -m32)
|
$(eval LDFLAGS := $(LDFLAGS) -s -m32 $(LDFLAGS_ADDTL))
|
||||||
$(eval BOXES_EXECUTABLE_NAME := boxes.exe)
|
$(eval BOXES_EXECUTABLE_NAME := boxes.exe)
|
||||||
$(eval ALL_OBJ := $(GEN_SRC:.c=.o) $(ORIG_NORM:.c=.o))
|
$(eval ALL_OBJ := $(GEN_SRC:.c=.o) $(ORIG_NORM:.c=.o))
|
||||||
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt
|
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt
|
||||||
|
27
src/boxes.c
27
src/boxes.c
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifndef __MINGW32__
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
#endif
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -400,19 +402,30 @@ static void handle_remove_box()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* These two functions are actually declared in term.h, but for some reason, that can't be included. */
|
#ifndef __MINGW32__
|
||||||
extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *, int, int *);
|
/* These two functions are actually declared in term.h, but for some reason, that can't be included. */
|
||||||
extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);
|
extern NCURSES_EXPORT(int) setupterm(NCURSES_CONST char *, int, int *);
|
||||||
|
extern NCURSES_EXPORT(int) tigetnum(NCURSES_CONST char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
static int terminal_has_colors()
|
static int terminal_has_colors()
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
char *termtype = getenv("TERM");
|
char *termtype = getenv("TERM");
|
||||||
if (termtype != NULL && setupterm(termtype, STDOUT_FILENO, NULL) == OK && tigetnum("colors") >= 8) {
|
#ifdef __MINGW32__
|
||||||
result = 1;
|
result = 1; /* On Windows, we always assume color capability. */
|
||||||
}
|
UNUSED(termtype);
|
||||||
|
#else
|
||||||
|
if (termtype != NULL && setupterm(termtype, STDOUT_FILENO, NULL) == OK && tigetnum("colors") >= 8) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
int num_colors = result ? tigetnum("colors") : 0;
|
#ifdef __MINGW32__
|
||||||
|
int num_colors = 1;
|
||||||
|
#else
|
||||||
|
int num_colors = result ? tigetnum("colors") : 0;
|
||||||
|
#endif
|
||||||
fprintf(stderr, "Terminal \"%s\" %s colors (number of colors = %d).\n", termtype != NULL ? termtype : "(null)",
|
fprintf(stderr, "Terminal \"%s\" %s colors (number of colors = %d).\n", termtype != NULL ? termtype : "(null)",
|
||||||
result ? "has" : "does NOT have", num_colors);
|
result ? "has" : "does NOT have", num_colors);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user