| 142 | var term_cursor_x = 0; |
| 143 | |
| 144 | function termInit() { |
| 145 | var tab; |
| 146 | term_fd = std.in.fileno(); |
| 147 | |
| 148 | /* get the terminal size */ |
| 149 | term_width = 80; |
| 150 | if (os.isatty(term_fd)) { |
| 151 | if (os.ttyGetWinSize) { |
| 152 | tab = os.ttyGetWinSize(term_fd); |
| 153 | if (tab) |
| 154 | term_width = tab[0]; |
| 155 | } |
| 156 | if (os.ttySetRaw) { |
| 157 | /* set the TTY to raw mode */ |
| 158 | os.ttySetRaw(term_fd); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /* install a Ctrl-C signal handler */ |
| 163 | os.signal(os.SIGINT, sigint_handler); |
| 164 | |
| 165 | /* install a handler to read stdin */ |
| 166 | term_read_buf = new Uint8Array(64); |
| 167 | os.setReadHandler(term_fd, term_read_handler); |
| 168 | } |
| 169 | |
| 170 | function sigint_handler() { |
| 171 | /* send Ctrl-C to readline */ |