tty_rawmode(): * Set terminal into 1 character at a time mode. */
| 976 | * Set terminal into 1 character at a time mode. |
| 977 | */ |
| 978 | protected int |
| 979 | tty_rawmode(EditLine *el) |
| 980 | { |
| 981 | |
| 982 | if (el->el_tty.t_mode == ED_IO || el->el_tty.t_mode == QU_IO) |
| 983 | return 0; |
| 984 | |
| 985 | if (el->el_flags & EDIT_DISABLED) |
| 986 | return 0; |
| 987 | |
| 988 | if (tty_getty(el, &el->el_tty.t_ts) == -1) { |
| 989 | #ifdef DEBUG_TTY |
| 990 | (void) fprintf(el->el_errfile, "%s: tty_getty: %s\n", __func__, |
| 991 | strerror(errno)); |
| 992 | #endif /* DEBUG_TTY */ |
| 993 | return -1; |
| 994 | } |
| 995 | /* |
| 996 | * We always keep up with the eight bit setting and the speed of the |
| 997 | * tty. But we only believe changes that are made to cooked mode! |
| 998 | */ |
| 999 | el->el_tty.t_eight = tty__geteightbit(&el->el_tty.t_ts); |
| 1000 | el->el_tty.t_speed = tty__getspeed(&el->el_tty.t_ts); |
| 1001 | |
| 1002 | if (tty__getspeed(&el->el_tty.t_ex) != el->el_tty.t_speed || |
| 1003 | tty__getspeed(&el->el_tty.t_ed) != el->el_tty.t_speed) { |
| 1004 | (void) cfsetispeed(&el->el_tty.t_ex, el->el_tty.t_speed); |
| 1005 | (void) cfsetospeed(&el->el_tty.t_ex, el->el_tty.t_speed); |
| 1006 | (void) cfsetispeed(&el->el_tty.t_ed, el->el_tty.t_speed); |
| 1007 | (void) cfsetospeed(&el->el_tty.t_ed, el->el_tty.t_speed); |
| 1008 | } |
| 1009 | if (tty__cooked_mode(&el->el_tty.t_ts)) { |
| 1010 | int i; |
| 1011 | |
| 1012 | for (i = MD_INP; i <= MD_LIN; i++) |
| 1013 | tty_update_flags(el, i); |
| 1014 | |
| 1015 | if (tty__gettabs(&el->el_tty.t_ex) == 0) |
| 1016 | el->el_tty.t_tabs = 0; |
| 1017 | else |
| 1018 | el->el_tty.t_tabs = EL_CAN_TAB ? 1 : 0; |
| 1019 | |
| 1020 | tty__getchar(&el->el_tty.t_ts, el->el_tty.t_c[TS_IO]); |
| 1021 | /* |
| 1022 | * Check if the user made any changes. |
| 1023 | * If he did, then propagate the changes to the |
| 1024 | * edit and execute data structures. |
| 1025 | */ |
| 1026 | for (i = 0; i < C_NCC; i++) |
| 1027 | if (el->el_tty.t_c[TS_IO][i] != |
| 1028 | el->el_tty.t_c[EX_IO][i]) |
| 1029 | break; |
| 1030 | |
| 1031 | if (i != C_NCC) { |
| 1032 | /* |
| 1033 | * Propagate changes only to the unprotected |
| 1034 | * chars that have been modified just now. |
| 1035 | */ |
no test coverage detected