/****************************************************************************
- * Copyright (c) 1998-2007,2009 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 *
*/
#include <curses.priv.h>
-#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.15 2009/02/15 00:49:02 tom Exp $")
-
-#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
-#define _POSIX_SOURCE
-#endif
+MODULE_ID("$Id: lib_raw.c,v 1.26 2020/11/21 22:07:48 tom Exp $")
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
#define _nc_setmode(mode) /* nothing */
#endif
+#if USE_KLIBC_KBD
+#define INCL_KBD
+#include <os2.h>
+#endif
+
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
#ifdef TRACE
NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("raw()")));
-
- if (SP_PARM != 0 && cur_term != 0) {
+ T((T_CALLED("raw(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
BEFORE("raw");
_nc_setmode(O_BINARY);
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= ~(ICANON | ISIG | IEXTEN);
- buf.c_iflag &= ~(COOKED_INPUT);
+ buf.c_lflag &= (unsigned) ~(ICANON | ISIG | IEXTEN);
+ buf.c_iflag &= (unsigned) ~(COOKED_INPUT);
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
+#elif defined(EXP_WIN32_DRIVER)
+ buf.dwFlagIn &= (unsigned long) ~CONMODE_NORAW;
#else
buf.sg_flags |= RAW;
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP_PARM->_raw = TRUE;
- SP_PARM->_cbreak = 1;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+#if USE_KLIBC_KBD
+ KBDINFO kbdinfo;
+
+ kbdinfo.cb = sizeof(kbdinfo);
+ KbdGetStatus(&kbdinfo, 0);
+
+ kbdinfo.cb = sizeof(kbdinfo);
+ kbdinfo.fsMask &= ~KEYBOARD_ASCII_MODE;
+ kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
+ KbdSetStatus(&kbdinfo, 0);
+#endif
+ if (SP_PARM) {
+ SP_PARM->_raw = TRUE;
+ SP_PARM->_cbreak = 1;
+ }
+ termp->Nttyb = buf;
}
AFTER("raw");
}
NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("cbreak()")));
-
- if (SP_PARM != 0 && cur_term != 0) {
+ T((T_CALLED("cbreak(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
BEFORE("cbreak");
_nc_setmode(O_BINARY);
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= ~ICANON;
- buf.c_iflag &= ~ICRNL;
+ buf.c_lflag &= (unsigned) ~ICANON;
+ buf.c_iflag &= (unsigned) ~ICRNL;
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 &= (unsigned long) ~CONMODE_NOCBREAK;
#else
buf.sg_flags |= CBREAK;
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP_PARM->_cbreak = 1;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ if (SP_PARM) {
+ SP_PARM->_cbreak = 1;
+ }
+ termp->Nttyb = buf;
}
AFTER("cbreak");
}
NCURSES_EXPORT(void)
NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0)
{
- int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("qiflush()")));
-
- if (cur_term != 0) {
+ T((T_CALLED("qiflush(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
+ int result;
BEFORE("qiflush");
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= ~(NOFLSH);
- result = _nc_set_tty_mode(&buf);
+ buf.c_lflag &= (unsigned) ~(NOFLSH);
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
#else
+ result = ERR;
/* FIXME */
#endif
if (result == OK)
- cur_term->Nttyb = buf;
+ termp->Nttyb = buf;
AFTER("qiflush");
}
returnVoid;
NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("noraw()")));
-
- if (SP_PARM != 0 && cur_term != 0) {
+ T((T_CALLED("noraw(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
BEFORE("noraw");
_nc_setmode(O_TEXT);
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
buf.c_lflag |= ISIG | ICANON |
- (cur_term->Ottyb.c_lflag & IEXTEN);
+ (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
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP_PARM->_raw = FALSE;
- SP_PARM->_cbreak = 0;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+#if USE_KLIBC_KBD
+ KBDINFO kbdinfo;
+
+ kbdinfo.cb = sizeof(kbdinfo);
+ KbdGetStatus(&kbdinfo, 0);
+
+ kbdinfo.cb = sizeof(kbdinfo);
+ kbdinfo.fsMask &= ~KEYBOARD_BINARY_MODE;
+ kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
+ KbdSetStatus(&kbdinfo, 0);
+#endif
+ if (SP_PARM) {
+ SP_PARM->_raw = FALSE;
+ SP_PARM->_cbreak = 0;
+ }
+ termp->Nttyb = buf;
}
AFTER("noraw");
}
NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("nocbreak()")));
-
- if (SP_PARM != 0 && cur_term != 0) {
+ T((T_CALLED("nocbreak(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
BEFORE("nocbreak");
_nc_setmode(O_TEXT);
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#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
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP_PARM->_cbreak = 0;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ if (SP_PARM) {
+ SP_PARM->_cbreak = 0;
+ }
+ termp->Nttyb = buf;
}
AFTER("nocbreak");
}
}
#endif
-/*
- * Note:
- * this implementation may be wrong. See the comment under intrflush().
- */
NCURSES_EXPORT(void)
NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0)
{
- int result = ERR;
-
- T((T_CALLED("noqiflush()")));
+ TERMINAL *termp;
- if (cur_term != 0) {
+ T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
+ int result;
BEFORE("noqiflush");
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
buf.c_lflag |= NOFLSH;
- result = _nc_set_tty_mode(&buf);
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
#else
/* FIXME */
+ result = ERR;
#endif
- if (result == OK) {
- cur_term->Nttyb = buf;
- }
+ if (result == OK)
+ termp->Nttyb = buf;
AFTER("noqiflush");
}
returnVoid;
NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("intrflush(%d)"), flag));
+ T((T_CALLED("intrflush(%p,%d)"), (void *) SP_PARM, flag));
+ if (SP_PARM == 0)
+ returnCode(ERR);
- if (cur_term != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
BEFORE("intrflush");
- buf = cur_term->Nttyb;
+ buf = termp->Nttyb;
#ifdef TERMIOS
if (flag)
- buf.c_lflag &= ~(NOFLSH);
+ buf.c_lflag &= (unsigned) ~(NOFLSH);
else
buf.c_lflag |= (NOFLSH);
- result = _nc_set_tty_mode(&buf);
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
#else
/* FIXME */
#endif
if (result == OK) {
- cur_term->Nttyb = buf;
+ termp->Nttyb = buf;
}
AFTER("intrflush");
}