aboutsummaryrefslogtreecommitdiff
path: root/ncurses/tinfo/lib_raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/tinfo/lib_raw.c')
-rw-r--r--ncurses/tinfo/lib_raw.c202
1 files changed, 130 insertions, 72 deletions
diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c
index 58e71889af12..b524a1bb55be 100644
--- a/ncurses/tinfo/lib_raw.c
+++ b/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2009,2010 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 *
@@ -29,7 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1998 on *
+ * and: Thomas E. Dickey 1998-on *
+ * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -47,9 +48,8 @@
*/
#include <curses.priv.h>
-#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.19 2010/04/24 23:49:12 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -61,7 +61,7 @@ MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
#ifdef __EMX__
#include <io.h>
-#define _nc_setmode(mode) setmode(SP->_ifd, mode)
+#define _nc_setmode(mode) setmode(SP_PARM->_ifd, mode)
#else
#define _nc_setmode(mode) /* nothing */
#endif
@@ -77,188 +77,235 @@ MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
#endif /* TRACE */
NCURSES_EXPORT(int)
-raw(void)
+NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("raw()")));
-
- if (SP != 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;
#else
buf.sg_flags |= RAW;
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP->_raw = TRUE;
- SP->_cbreak = 1;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ SP_PARM->_raw = TRUE;
+ SP_PARM->_cbreak = 1;
+ termp->Nttyb = buf;
}
AFTER("raw");
}
returnCode(result);
}
+#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-cbreak(void)
+raw(void)
{
- int result = ERR;
+ return NCURSES_SP_NAME(raw) (CURRENT_SCREEN);
+}
+#endif
- T((T_CALLED("cbreak()")));
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
+{
+ int result = ERR;
+ TERMINAL *termp;
- if (SP != 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;
#else
buf.sg_flags |= CBREAK;
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP->_cbreak = 1;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ SP_PARM->_cbreak = 1;
+ termp->Nttyb = buf;
}
AFTER("cbreak");
}
returnCode(result);
}
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+cbreak(void)
+{
+ return NCURSES_SP_NAME(cbreak) (CURRENT_SCREEN);
+}
+#endif
+
/*
* Note:
* this implementation may be wrong. See the comment under intrflush().
*/
NCURSES_EXPORT(void)
-qiflush(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;
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
/* FIXME */
#endif
if (result == OK)
- cur_term->Nttyb = buf;
+ termp->Nttyb = buf;
AFTER("qiflush");
}
returnVoid;
}
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+qiflush(void)
+{
+ NCURSES_SP_NAME(qiflush) (CURRENT_SCREEN);
+}
+#endif
+
NCURSES_EXPORT(int)
-noraw(void)
+NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("noraw()")));
-
- if (SP != 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;
#else
buf.sg_flags &= ~(RAW | CBREAK);
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP->_raw = FALSE;
- SP->_cbreak = 0;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ SP_PARM->_raw = FALSE;
+ SP_PARM->_cbreak = 0;
+ termp->Nttyb = buf;
}
AFTER("noraw");
}
returnCode(result);
}
+#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-nocbreak(void)
+noraw(void)
{
- int result = ERR;
+ return NCURSES_SP_NAME(noraw) (CURRENT_SCREEN);
+}
+#endif
- T((T_CALLED("nocbreak()")));
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
+{
+ int result = ERR;
+ TERMINAL *termp;
- if (SP != 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;
#else
buf.sg_flags &= ~CBREAK;
#endif
- if ((result = _nc_set_tty_mode(&buf)) == OK) {
- SP->_cbreak = 0;
- cur_term->Nttyb = buf;
+ result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ if (result == OK) {
+ SP_PARM->_cbreak = 0;
+ termp->Nttyb = buf;
}
AFTER("nocbreak");
}
returnCode(result);
}
-/*
- * Note:
- * this implementation may be wrong. See the comment under intrflush().
- */
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+nocbreak(void)
+{
+ return NCURSES_SP_NAME(nocbreak) (CURRENT_SCREEN);
+}
+#endif
+
NCURSES_EXPORT(void)
-noqiflush(void)
+NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0)
{
int result = ERR;
+ TERMINAL *termp;
- T((T_CALLED("noqiflush()")));
-
- if (cur_term != 0) {
+ T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM));
+ if ((termp = TerminalOf(SP_PARM)) != 0) {
TTY buf;
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 */
#endif
- if (result == OK) {
- cur_term->Nttyb = buf;
- }
+ if (result == OK)
+ termp->Nttyb = buf;
AFTER("noqiflush");
}
returnVoid;
}
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+noqiflush(void)
+{
+ NCURSES_SP_NAME(noqiflush) (CURRENT_SCREEN);
+}
+#endif
+
/*
* This call does the same thing as the qiflush()/noqiflush() pair. We know
* for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the other hand,
@@ -267,30 +314,41 @@ noqiflush(void)
* curs_inopts(3x) is too exact to be coincidence.
*/
NCURSES_EXPORT(int)
-intrflush(WINDOW *win GCC_UNUSED, bool flag)
+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");
}
returnCode(result);
}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+intrflush(WINDOW *win GCC_UNUSED, bool flag)
+{
+ return NCURSES_SP_NAME(intrflush) (CURRENT_SCREEN, win, flag);
+}
+#endif