2
******************************************************************************
3
This file is part of `bf', Yet another Brainfuck interpreter.
7
Description of this file:
8
tty handling routines using termios.h
10
Copyright (C) GPL, 2004 Stephan Beyer - s-beyer@gmx.net
12
Permission is hereby granted, free of charge, to any person obtaining a
13
copy of this software and associated documentation files (the "Software"),
14
to deal in the Software without restriction, including without limitation
15
the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
and/or sell copies of the Software, and to permit persons to whom the
17
Software is furnished to do so, subject to the following conditions:
19
The above copyright notice and this permission notice shall be included in
20
all copies or substantial portions of the Software.
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
******************************************************************************
32
#include <stdio.h> /* getchar */
39
static struct termios *tty = NULL; /* save tty settings */
41
/* restore tty settings */
45
tcsetattr(STDIN_FILENO, TCSANOW, tty);
48
/* set handlers and init tty according to input mode */
51
static struct termios term;
52
if (!tcgetattr(STDIN_FILENO, &term))
59
static struct termios term;
60
term = *tty; /* copy saved tty */
61
term.c_lflag &= ~ICANON; /* disable eof */
62
term.c_lflag &= ~ICRNL; /* disable CR -> NL */
63
if (opt.inputmode == 1 || opt.inputmode == 3)
64
term.c_lflag &= ~ECHO; /* disable output of input */
65
term.c_cc[VMIN] = 1; /* one character */
66
tcsetattr(STDIN_FILENO, TCSANOW, &term);
69
char ttyGetInput(void)