]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_set_term.c
ncurses 6.2 - patch 20210213
[ncurses.git] / ncurses / base / lib_set_term.c
index b900a68e320805e49bda1db8d1c92e61a990368c..8573fbe7d5225f7bf6bdaeeedafaaaeb48348f27 100644 (file)
 #include <curses.priv.h>
 #include <tic.h>
 
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+#endif
+#endif
+
 #undef CUR
 #define CUR SP_TERMTYPE
 
-MODULE_ID("$Id: lib_set_term.c,v 1.171 2020/05/23 19:13:12 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.175 2020/10/10 19:09:03 juergen Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -197,6 +204,14 @@ delscreen(SCREEN *sp)
        if (_nc_find_prescr() == sp) {
            _nc_forget_prescr();
        }
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+       if (sp->_dlopen_gpm != 0) {
+           dlclose(sp->_dlopen_gpm);
+           sp->_dlopen_gpm = 0;
+       }
+#endif
+#endif /* USE_GPM_SUPPORT */
        free(sp);
 
        /*
@@ -391,6 +406,11 @@ NCURSES_SP_NAME(_nc_setupscreen) (
     T(("setting output mode to binary"));
     fflush(output);
     setmode(output, O_BINARY);
+#endif
+#if defined(EXP_WIN32_DRIVER)
+    T(("setting output mode to binary"));
+    fflush(output);
+    _setmode(fileno(output), _O_BINARY);
 #endif
     NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_ARGx output, TRUE);
     sp->_lines = (NCURSES_SIZE_T) slines;
@@ -400,6 +420,10 @@ NCURSES_SP_NAME(_nc_setupscreen) (
     fflush(output);
     sp->_ofd = output ? fileno(output) : -1;
     sp->_ofp = output;
+#if defined(EXP_WIN32_DRIVER)
+    if (output)
+       _setmode(fileno(output), _O_BINARY);
+#endif
     sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns));
     if ((sp->out_buffer = malloc(sp->out_limit)) == 0)
        sp->out_limit = 0;