19 |
int |
int |
20 |
tty_store(void) |
tty_store(void) |
21 |
{ |
{ |
22 |
|
|
23 |
if (isatty(fileno(stdin))) { |
if (isatty(fileno(stdin))) { |
24 |
flags |= FLAG_TTY; |
flags |= FLAG_TTY; |
25 |
|
|
36 |
* Disable echo. |
* Disable echo. |
37 |
*/ |
*/ |
38 |
int |
int |
39 |
tty_disable_echo(void) |
tty_noecho(void) |
40 |
{ |
{ |
41 |
|
|
42 |
if (!(flags & FLAG_TTY)) |
if (!(flags & FLAG_TTY)) |
43 |
return 0; |
return 0; |
44 |
|
|
45 |
ntio = otio; |
ntio = otio; |
46 |
ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); |
ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); |
47 |
|
|
48 |
flags |= FLAG_TTY_MODIFIED; |
flags |= FLAG_TTYMOD; |
49 |
|
|
50 |
if (tcsetattr(fileno(stdin), TCSAFLUSH, &ntio)) { |
if (tcsetattr(fileno(stdin), TCSAFLUSH, &ntio)) { |
51 |
error("setting term attributes; %s\n", strerror(errno)); |
error("setting term attributes; %s\n", strerror(errno)); |
61 |
int |
int |
62 |
tty_restore(void) |
tty_restore(void) |
63 |
{ |
{ |
64 |
if (!(flags & FLAG_TTY) || !(flags & FLAG_TTY_MODIFIED)) |
|
65 |
|
if (!(flags & FLAG_TTY) || !(flags & FLAG_TTYMOD)) |
66 |
return 0; |
return 0; |
67 |
|
|
68 |
if (tcsetattr(fileno(stdin), TCSAFLUSH, &otio)) { |
if (tcsetattr(fileno(stdin), TCSAFLUSH, &otio)) { |
69 |
error("setting term attributes; %s\n", strerror(errno)); |
error("setting term attributes; %s\n", strerror(errno)); |
70 |
return ERROR_TERMIO; |
return ERROR_TERMIO; |
71 |
} |
} |
72 |
flags &= ~(FLAG_TTY_MODIFIED); |
flags &= ~(FLAG_TTYMOD); |
73 |
|
|
74 |
return 0; |
return 0; |
75 |
} |
} |