textio/txInput.c: Refactor header includes
Rather than being dependent on OS-level defines, refactor to use feature-level defines.
This commit is contained in:
parent
388572c1ff
commit
d825f6cafe
105
textio/txInput.c
105
textio/txInput.c
|
|
@ -1223,36 +1223,29 @@ TxGetLine(
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
|
||||||
|
|
||||||
void
|
void
|
||||||
txGetTermState(
|
txGetTermState(
|
||||||
struct termio *buf)
|
#if defined(HAVE_TERMIOS_H)
|
||||||
{
|
struct termios *buf
|
||||||
ioctl( fileno( stdin ), TCGETA, buf);
|
#elif defined(HAVE_TERMIO_H)
|
||||||
}
|
struct termio *buf
|
||||||
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
|
|
||||||
void
|
|
||||||
txGetTermState(
|
|
||||||
struct termios *buf)
|
|
||||||
{
|
|
||||||
(void) tcgetattr(fileno(stdin), buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
txTermState *buf
|
||||||
void
|
#endif
|
||||||
txGetTermState(
|
)
|
||||||
txTermState *buf)
|
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_TERMIOS_H) /* POSIX */
|
||||||
|
(void) tcgetattr(fileno(stdin), buf);
|
||||||
|
#elif defined(HAVE_TERMIO_H) /* SYSV */
|
||||||
|
ioctl( fileno( stdin ), TCGETA, buf);
|
||||||
|
#else /* fallback to sgtty-style */
|
||||||
ASSERT(TxStdinIsatty, "txGetTermState");
|
ASSERT(TxStdinIsatty, "txGetTermState");
|
||||||
/* save the current terminal characteristics */
|
/* save the current terminal characteristics */
|
||||||
(void) ioctl(fileno(stdin), TIOCGETP, (char *) &(buf->tx_i_sgtty) );
|
(void) ioctl(fileno(stdin), TIOCGETP, (char *) &(buf->tx_i_sgtty) );
|
||||||
(void) ioctl(fileno(stdin), TIOCGETC, (char *) &(buf->tx_i_tchars) );
|
(void) ioctl(fileno(stdin), TIOCGETC, (char *) &(buf->tx_i_tchars) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* SYSV */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1271,24 +1264,24 @@ txGetTermState(
|
||||||
|
|
||||||
void
|
void
|
||||||
txSetTermState(
|
txSetTermState(
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
#if defined(HAVE_TERMIOS_H)
|
||||||
struct termio *buf
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
struct termios *buf
|
struct termios *buf
|
||||||
|
#elif defined(HAVE_TERMIO_H)
|
||||||
|
struct termio *buf
|
||||||
#else
|
#else
|
||||||
txTermState *buf
|
txTermState *buf
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
#if defined(HAVE_TERMIOS_H) /* POSIX */
|
||||||
ioctl( fileno(stdin), TCSETAF, buf );
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
(void) tcsetattr( fileno(stdin), TCSANOW, buf );
|
(void) tcsetattr( fileno(stdin), TCSANOW, buf );
|
||||||
#else
|
#elif defined(HAVE_TERMIO_H) /* SYSV */
|
||||||
|
ioctl( fileno(stdin), TCSETAF, buf );
|
||||||
|
#else /* fallback to sgtty-style */
|
||||||
/* set the current terminal characteristics */
|
/* set the current terminal characteristics */
|
||||||
(void) ioctl(fileno(stdin), TIOCSETN, (char *) &(buf->tx_i_sgtty) );
|
(void) ioctl(fileno(stdin), TIOCSETN, (char *) &(buf->tx_i_sgtty) );
|
||||||
(void) ioctl(fileno(stdin), TIOCSETC, (char *) &(buf->tx_i_tchars) );
|
(void) ioctl(fileno(stdin), TIOCSETC, (char *) &(buf->tx_i_tchars) );
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1311,37 +1304,36 @@ txSetTermState(
|
||||||
|
|
||||||
void
|
void
|
||||||
txInitTermRec(
|
txInitTermRec(
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
#if defined(HAVE_TERMIOS_H)
|
||||||
struct termio *buf
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
struct termios *buf
|
struct termios *buf
|
||||||
|
#elif defined(HAVE_TERMIO_H)
|
||||||
|
struct termio *buf
|
||||||
#else
|
#else
|
||||||
txTermState *buf
|
txTermState *buf
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if defined(SYSV) || defined(CYGWIN) || defined(__OpenBSD__) || defined(EMSCRIPTEN)
|
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
|
||||||
buf->c_lflag = ISIG; /* raw: no echo and no processing, allow signals */
|
buf->c_lflag = ISIG; /* raw: no echo and no processing, allow signals */
|
||||||
buf->c_cc[ VMIN ] = 1;
|
buf->c_cc[ VMIN ] = 1;
|
||||||
buf->c_cc[ VTIME ] = 0;
|
buf->c_cc[ VTIME ] = 0;
|
||||||
#else
|
#else /* sgtty-style interface */
|
||||||
/* set things up for us, turn off echo, turn on cbreak, no EOF */
|
/* set things up for us, turn off echo, turn on cbreak, no EOF */
|
||||||
buf->tx_i_sgtty.sg_flags |= CBREAK;
|
buf->tx_i_sgtty.sg_flags |= CBREAK;
|
||||||
buf->tx_i_sgtty.sg_flags &= ~ECHO;
|
buf->tx_i_sgtty.sg_flags &= ~ECHO;
|
||||||
buf->tx_i_tchars.t_eofc = -1;
|
buf->tx_i_tchars.t_eofc = -1;
|
||||||
|
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAVE_TERMIOS_H)
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
|
||||||
struct termio closeTermState;
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
struct termios closeTermState;
|
struct termios closeTermState;
|
||||||
|
#elif defined(HAVE_TERMIO_H)
|
||||||
|
struct termio closeTermState;
|
||||||
#else
|
#else
|
||||||
static txTermState closeTermState;
|
static txTermState closeTermState;
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
|
|
||||||
static bool haveCloseState = FALSE;
|
static bool haveCloseState = FALSE;
|
||||||
|
|
||||||
|
|
@ -1364,21 +1356,18 @@ static bool haveCloseState = FALSE;
|
||||||
void
|
void
|
||||||
txSaveTerm(void)
|
txSaveTerm(void)
|
||||||
{
|
{
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
|
||||||
ioctl( fileno( stdin ), TCGETA, &closeTermState);
|
# if defined(HAVE_TERMIOS_H)
|
||||||
txEraseChar = closeTermState.c_cc[VERASE];
|
|
||||||
txKillChar = closeTermState.c_cc[VKILL];
|
|
||||||
TxEOFChar = closeTermState.c_cc[VEOF];
|
|
||||||
TxInterruptChar = closeTermState.c_cc[VINTR];
|
|
||||||
haveCloseState = TRUE;
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
(void) tcgetattr( fileno( stdin ), &closeTermState);
|
(void) tcgetattr( fileno( stdin ), &closeTermState);
|
||||||
|
# else /* HAVE_TERMIO_H */
|
||||||
|
ioctl( fileno( stdin ), TCGETA, &closeTermState);
|
||||||
|
# endif /* HAVE_TERMIOS_H || HAVE_TERMIO_H */
|
||||||
txEraseChar = closeTermState.c_cc[VERASE];
|
txEraseChar = closeTermState.c_cc[VERASE];
|
||||||
txKillChar = closeTermState.c_cc[VKILL];
|
txKillChar = closeTermState.c_cc[VKILL];
|
||||||
TxEOFChar = closeTermState.c_cc[VEOF];
|
TxEOFChar = closeTermState.c_cc[VEOF];
|
||||||
TxInterruptChar = closeTermState.c_cc[VINTR];
|
TxInterruptChar = closeTermState.c_cc[VINTR];
|
||||||
haveCloseState = TRUE;
|
haveCloseState = TRUE;
|
||||||
#else
|
#else /* sgtty-style interface */
|
||||||
struct ltchars lt;
|
struct ltchars lt;
|
||||||
txGetTermState(&closeTermState);
|
txGetTermState(&closeTermState);
|
||||||
(void) ioctl(fileno(stdin), TIOCGLTC, (char *) <);
|
(void) ioctl(fileno(stdin), TIOCGLTC, (char *) <);
|
||||||
|
|
@ -1391,7 +1380,7 @@ txSaveTerm(void)
|
||||||
TxEOFChar = closeTermState.tx_i_tchars.t_eofc;
|
TxEOFChar = closeTermState.tx_i_tchars.t_eofc;
|
||||||
TxInterruptChar = closeTermState.tx_i_tchars.t_intrc;
|
TxInterruptChar = closeTermState.tx_i_tchars.t_intrc;
|
||||||
haveCloseState = TRUE;
|
haveCloseState = TRUE;
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1412,13 +1401,13 @@ txSaveTerm(void)
|
||||||
void
|
void
|
||||||
TxSetTerminal(void)
|
TxSetTerminal(void)
|
||||||
{
|
{
|
||||||
#if defined(SYSV) || defined(CYGWIN)
|
#if defined(HAVE_TERMIOS_H)
|
||||||
struct termio buf;
|
|
||||||
#elif defined (__OpenBSD__) || defined(EMSCRIPTEN)
|
|
||||||
struct termios buf;
|
struct termios buf;
|
||||||
|
#elif defined(HAVE_TERMIO_H)
|
||||||
|
struct termio buf;
|
||||||
#else
|
#else
|
||||||
txTermState buf;
|
txTermState buf;
|
||||||
#endif /* SYSV */
|
#endif
|
||||||
|
|
||||||
#ifdef MAGIC_WRAPPER
|
#ifdef MAGIC_WRAPPER
|
||||||
/* If using Tk console, don't mess with the terminal settings; */
|
/* If using Tk console, don't mess with the terminal settings; */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue