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