aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:44 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:44 +0100
commitec53566f5ccb4fb88f2f42c3099ab630c0f2375d (patch)
tree70dd3fa285a20f0c21497d25c1fcfb91137206bd
parent2d036d562f9ebdd4f1f6bfc34d7fac86d5d414dc (diff)
TSalis checks color availability.
-rw-r--r--tsalis/include/printer.h39
-rw-r--r--tsalis/src/printer.c14
-rw-r--r--tsalis/src/tsalis.c5
3 files changed, 38 insertions, 20 deletions
diff --git a/tsalis/include/printer.h b/tsalis/include/printer.h
index 5356594..f5d8c3c 100644
--- a/tsalis/include/printer.h
+++ b/tsalis/include/printer.h
@@ -12,24 +12,25 @@ extern sword g_processGeneScroll;
extern sword g_worldPos;
extern sword g_worldZoom;
-void tsp_init (void);
-void tsp_quit (void);
-void tsp_onResize (void);
-void tsp_prevPage (void);
-void tsp_nextPage (void);
-void tsp_scrollUp (void);
-void tsp_scrollDown (void);
-void tsp_scrollLeft (void);
-void tsp_scrollRight (void);
-void tsp_scrollToTop (void);
-void tsp_scrollToLeft (void);
-void tsp_zoomIn (void);
-void tsp_zoomOut (void);
-void tsp_prevOrganism (void);
-void tsp_nextOrganism (void);
-void tsp_gotoSelectedProc (void);
-void tsp_selectProcess (sword proc);
-void tsp_moveTo (sword loc);
-void tsp_printData (void);
+sbool tsp_check (void);
+void tsp_init (void);
+void tsp_quit (void);
+void tsp_onResize (void);
+void tsp_prevPage (void);
+void tsp_nextPage (void);
+void tsp_scrollUp (void);
+void tsp_scrollDown (void);
+void tsp_scrollLeft (void);
+void tsp_scrollRight (void);
+void tsp_scrollToTop (void);
+void tsp_scrollToLeft (void);
+void tsp_zoomIn (void);
+void tsp_zoomOut (void);
+void tsp_prevOrganism (void);
+void tsp_nextOrganism (void);
+void tsp_gotoSelectedProc (void);
+void tsp_selectProcess (sword proc);
+void tsp_moveTo (sword loc);
+void tsp_printData (void);
#endif
diff --git a/tsalis/src/printer.c b/tsalis/src/printer.c
index 9d82fc8..88da4a8 100644
--- a/tsalis/src/printer.c
+++ b/tsalis/src/printer.c
@@ -90,10 +90,22 @@ adjustWorld(void)
}
}
+sbool
+tsp_check(void)
+{
+ initscr();
+
+ if (!has_colors()) {
+ endwin();
+ return SFALSE;
+ }
+
+ return STRUE;
+}
+
void
tsp_init(void)
{
- initscr();
cbreak();
noecho();
curs_set(0);
diff --git a/tsalis/src/tsalis.c b/tsalis/src/tsalis.c
index f578e8f..7722ca9 100644
--- a/tsalis/src/tsalis.c
+++ b/tsalis/src/tsalis.c
@@ -52,6 +52,11 @@ onLoad(const char *fileName)
static void
init(int argc, char **argv)
{
+ if (!tsp_check()) {
+ fputs("ERROR: Terminal not supported\n", stderr);
+ exit(1);
+ }
+
if (argc == 1) {
onDefault();
} else if (argc == 2) {