aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2007-12-30 11:08:14 +0000
committerRong-En Fan <rafan@FreeBSD.org>2007-12-30 11:08:14 +0000
commit5ca44d1c915a0e0c87f8f347e61f7bfa65d609af (patch)
tree319eb1471eaf8c0c9cfc606e7cb8987ca9167507 /contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
parent01b82453a3d0c6d76d4afc340c07cfc2be4a6b7a (diff)
downloadsrc-5ca44d1c915a0e0c87f8f347e61f7bfa65d609af.tar.gz
src-5ca44d1c915a0e0c87f8f347e61f7bfa65d609af.zip
Import ncurses 5.6-20071222 snapshot onto the vender branch
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=174993
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo/lib_ttyflags.c')
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ttyflags.c80
1 files changed, 51 insertions, 29 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
index 77c35fa58426..4cbbf504a0c7 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 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 *
@@ -38,31 +38,35 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_ttyflags.c,v 1.13 2006/12/10 01:31:54 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.15 2007/05/26 18:54:25 tom Exp $")
NCURSES_EXPORT(int)
_nc_get_tty_mode(TTY * buf)
{
int result = OK;
- if (cur_term == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- for (;;) {
- if (GET_TTY(cur_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- result = ERR;
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (GET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ result = ERR;
+ }
+ break;
}
- break;
}
- }
- if (result == ERR)
- memset(buf, 0, sizeof(*buf));
+ if (result == ERR)
+ memset(buf, 0, sizeof(*buf));
- TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
+ TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
+ cur_term->Filedes, _nc_trace_ttymode(buf)));
+ }
return (result);
}
@@ -71,22 +75,26 @@ _nc_set_tty_mode(TTY * buf)
{
int result = OK;
- if (cur_term == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- for (;;) {
- if (SET_TTY(cur_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- if ((errno == ENOTTY) && (SP != 0))
- SP->_notty = TRUE;
- result = ERR;
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (SET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOTTY) && (SP != 0))
+ SP->_notty = TRUE;
+ result = ERR;
+ }
+ break;
}
- break;
}
+ TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
+ cur_term->Filedes, _nc_trace_ttymode(buf)));
}
- TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
return (result);
}
@@ -164,19 +172,33 @@ reset_shell_mode(void)
returnCode(ERR);
}
+static TTY *
+saved_tty(void)
+{
+ TTY *result = 0;
+
+ if (SP != 0) {
+ result = &(SP->_saved_tty);
+ } else {
+ if (_nc_prescreen.saved_tty == 0) {
+ _nc_prescreen.saved_tty = typeCalloc(TTY, 1);
+ }
+ result = _nc_prescreen.saved_tty;
+ }
+ return result;
+}
+
/*
** savetty() and resetty()
**
*/
-static TTY buf;
-
NCURSES_EXPORT(int)
savetty(void)
{
T((T_CALLED("savetty()")));
- returnCode(_nc_get_tty_mode(&buf));
+ returnCode(_nc_get_tty_mode(saved_tty()));
}
NCURSES_EXPORT(int)
@@ -184,5 +206,5 @@ resetty(void)
{
T((T_CALLED("resetty()")));
- returnCode(_nc_set_tty_mode(&buf));
+ returnCode(_nc_set_tty_mode(saved_tty()));
}