ncurses 6.2 - patch 20200906
[ncurses.git] / ncurses / tinfo / lib_raw.c
index a207fe0d920c5ee1e9dc17045e4c476f177c736e..91003ae4ba57dfbadb241b46d62d1c91daed4f9b 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2016 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -49,7 +50,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_raw.c,v 1.22 2016/05/28 23:22:52 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.25 2020/09/05 21:29:10 tom Exp $")
 
 #if HAVE_SYS_TERMIO_H
 #include <sys/termio.h>                /* needed for ISC */
@@ -96,6 +97,8 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
        buf.c_iflag &= (unsigned) ~(COOKED_INPUT);
        buf.c_cc[VMIN] = 1;
        buf.c_cc[VTIME] = 0;
+#elif defined(EXP_WIN32_DRIVER)
+       buf.dwFlagIn &= ~CONMODE_NORAW;
 #else
        buf.sg_flags |= RAW;
 #endif
@@ -112,8 +115,10 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
            kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
            KbdSetStatus(&kbdinfo, 0);
 #endif
-           SP_PARM->_raw = TRUE;
-           SP_PARM->_cbreak = 1;
+           if (SP_PARM) {
+               SP_PARM->_raw = TRUE;
+               SP_PARM->_cbreak = 1;
+           }
            termp->Nttyb = buf;
        }
        AFTER("raw");
@@ -149,12 +154,17 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
        buf.c_lflag |= ISIG;
        buf.c_cc[VMIN] = 1;
        buf.c_cc[VTIME] = 0;
+#elif defined(EXP_WIN32_DRIVER)
+       buf.dwFlagIn |= CONMODE_NORAW;
+       buf.dwFlagIn &= ~CONMODE_NOCBREAK;
 #else
        buf.sg_flags |= CBREAK;
 #endif
        result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
        if (result == OK) {
-           SP_PARM->_cbreak = 1;
+           if (SP_PARM) {
+               SP_PARM->_cbreak = 1;
+           }
            termp->Nttyb = buf;
        }
        AFTER("cbreak");
@@ -226,6 +236,8 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
        buf.c_lflag |= ISIG | ICANON |
            (termp->Ottyb.c_lflag & IEXTEN);
        buf.c_iflag |= COOKED_INPUT;
+#elif defined(EXP_WIN32_DRIVER)
+       buf.dwFlagIn |= CONMODE_NORAW;
 #else
        buf.sg_flags &= ~(RAW | CBREAK);
 #endif
@@ -242,8 +254,10 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
            kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
            KbdSetStatus(&kbdinfo, 0);
 #endif
-           SP_PARM->_raw = FALSE;
-           SP_PARM->_cbreak = 0;
+           if (SP_PARM) {
+               SP_PARM->_raw = FALSE;
+               SP_PARM->_cbreak = 0;
+           }
            termp->Nttyb = buf;
        }
        AFTER("noraw");
@@ -276,12 +290,16 @@ NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
 #ifdef TERMIOS
        buf.c_lflag |= ICANON;
        buf.c_iflag |= ICRNL;
+#elif defined(EXP_WIN32_DRIVER)
+       buf.dwFlagIn |= (CONMODE_NOCBREAK | CONMODE_NORAW);
 #else
        buf.sg_flags &= ~CBREAK;
 #endif
        result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
        if (result == OK) {
-           SP_PARM->_cbreak = 0;
+           if (SP_PARM) {
+               SP_PARM->_cbreak = 0;
+           }
            termp->Nttyb = buf;
        }
        AFTER("nocbreak");