From a9d2214414857df9dafc7cf149317425bfbf8219 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 2 Aug 2021 23:08:34 -0400 Subject: [PATCH] don't try to use termios from windows --- src/lib/direct.c | 4 ++++ src/lib/input.c | 12 ++++++++++++ src/lib/notcurses.c | 8 ++++---- src/lib/termdesc.c | 2 ++ src/lib/termdesc.h | 2 ++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib/direct.c b/src/lib/direct.c index 81a27e2d7..4a21622f2 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -405,6 +405,7 @@ detect_cursor_inversion_wrapper(ncdirect* n, const char* u7, int* y, int* x){ // the terminal, and then reading a response. many things can distupt this // non-atomic procedure, leading to unexpected results. a garbage function. int ncdirect_cursor_yx(ncdirect* n, int* y, int* x){ +#ifndef __MINGW64__ // FIXME struct termios termio, oldtermios; // this is only meaningful for real terminals if(n->ctermfd < 0){ @@ -455,6 +456,9 @@ int ncdirect_cursor_yx(ncdirect* n, int* y, int* x){ n->ctermfd, strerror(errno)); // don't return error for this } return ret; +#else + return -1; // FIXME +#endif } int ncdirect_cursor_push(ncdirect* n){ diff --git a/src/lib/input.c b/src/lib/input.c index fa2aeaa04..6685bfbb0 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -18,6 +18,7 @@ void sigwinch_handler(int signo){ } int cbreak_mode(int ttyfd, const struct termios* tpreserved){ +#ifndef __MINGW64__ if(ttyfd < 0){ return 0; } @@ -36,11 +37,15 @@ int cbreak_mode(int ttyfd, const struct termios* tpreserved){ return -1; } return 0; +#else + return -1; // FIXME +#endif } // Disable signals originating from the terminal's line discipline, i.e. // SIGINT (^C), SIGQUIT (^\), and SIGTSTP (^Z). They are enabled by default. int notcurses_linesigs_disable(notcurses* n){ +#ifndef __MINGW64__ if(n->ttyfd < 0){ return 0; } @@ -55,11 +60,15 @@ int notcurses_linesigs_disable(notcurses* n){ return -1; } return 0; +#else + return -1; // FIXME +#endif } // Restore signals originating from the terminal's line discipline, i.e. // SIGINT (^C), SIGQUIT (^\), and SIGTSTP (^Z), if disabled. int notcurses_linesigs_enable(notcurses* n){ +#ifndef __MINGW64__ if(n->ttyfd < 0){ return 0; } @@ -74,6 +83,9 @@ int notcurses_linesigs_enable(notcurses* n){ return -1; } return 0; +#else + return -1; // FIXME +#endif } static inline int diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 4fa67c712..013a99dc0 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -880,13 +880,13 @@ int ncplane_destroy_family(ncplane *ncp){ // only invoked without suppress banners flag. prints various warnings based on // the environment / terminal definition. returns the number of lines printed. static int -init_banner_warnings(const notcurses* nc, FILE* out){ - term_fg_palindex(nc, out, nc->tcache.caps.colors <= 88 ? 1 : 0xcb); +init_banner_warnings(const notcurses* nc, fbuf* f){ + term_fg_palindex(nc, f, nc->tcache.caps.colors <= 88 ? 1 : 0xcb); if(!notcurses_canutf8(nc)){ - fprintf(out, " Warning! Encoding is not UTF-8; output may be degraded.\n"); + fbuf_puts(f, " Warning! Encoding is not UTF-8; output may be degraded.\n"); } if(!get_escape(&nc->tcache, ESCAPE_HPA)){ - fprintf(out, " Warning! No absolute horizontal placement.\n"); + fbuf_puts(f, " Warning! No absolute horizontal placement.\n"); } return 0; } diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index fd75840c9..339b098f2 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -695,6 +695,7 @@ int interrogate_terminfo(tinfo* ti, int fd, unsigned utf8, unsigned noaltscreen, } // enter cbreak mode regardless of user preference until we've performed // terminal interrogation. at that point, we might restore original mode. +#ifndef __MINGW64__ if(cbreak_mode(fd, &ti->tpreserved)){ return -1; } @@ -705,6 +706,7 @@ int interrogate_terminfo(tinfo* ti, int fd, unsigned utf8, unsigned noaltscreen, fprintf(stderr, "Error issuing terminal queries on %d\n", fd); return -1; } +#endif } ti->sprixel_scale_height = 1; get_default_geometry(ti); diff --git a/src/lib/termdesc.h b/src/lib/termdesc.h index 4e2c861a6..4c3592b14 100644 --- a/src/lib/termdesc.h +++ b/src/lib/termdesc.h @@ -180,7 +180,9 @@ typedef struct tinfo { int sprixel_scale_height; // sprixel must be a multiple of this many rows const char* termname; // terminal name from environment variables/init char* termversion; // terminal version (freeform) from query responses +#ifndef __MINGW64__ struct termios tpreserved;// terminal state upon entry +#endif ncinputlayer input; // input layer int default_rows; // LINES environment var / lines terminfo / 24