|
15 | 15 | #include <stdlib.h> |
16 | 16 | #include <string> |
17 | 17 | #include <sys/time.h> |
| 18 | +#include <termios.h> |
18 | 19 | #include <unistd.h> |
19 | 20 | #include <vector> |
20 | 21 |
|
@@ -137,13 +138,48 @@ static napi_value run(napi_env env, napi_callback_info info) { |
137 | 138 | struct winsize ws = {}; |
138 | 139 | ws.ws_col = width; |
139 | 140 | ws.ws_row = height; |
140 | | - int pid = forkpty(&fd, nullptr, nullptr, &ws); |
| 141 | + |
| 142 | + // termios |
| 143 | + struct termios t {}; |
| 144 | + struct termios *term = &t; |
| 145 | + |
| 146 | + term->c_iflag = ICRNL | IXON | IUTF8; |
| 147 | + term->c_oflag = NL0 | CR0 | TAB0 | BS0 | VT0 | FF0 | OPOST | ONLCR; |
| 148 | + term->c_cflag = B38400 | CS8 | CREAD; |
| 149 | + // ICANON | ECHO removed |
| 150 | + term->c_lflag = ISIG | ECHOE | ECHOK | IEXTEN | ECHOCTL | ECHOKE; |
| 151 | + |
| 152 | + term->c_cc[VINTR] = 0x3; |
| 153 | + term->c_cc[VQUIT] = 0x1c; |
| 154 | + term->c_cc[VERASE] = 0x7f; |
| 155 | + term->c_cc[VKILL] = 0x15; |
| 156 | + term->c_cc[VEOF] = 0x4; |
| 157 | + term->c_cc[VMIN] = 0x1; |
| 158 | + term->c_cc[VSTART] = 0x11; |
| 159 | + term->c_cc[VSTOP] = 0x13; |
| 160 | + term->c_cc[VSUSP] = 0x1a; |
| 161 | + term->c_cc[VREPRINT] = 0x12; |
| 162 | + term->c_cc[VDISCARD] = 0xf; |
| 163 | + term->c_cc[VWERASE] = 0x17; |
| 164 | + term->c_cc[VLNEXT] = 0x16; |
| 165 | + |
| 166 | + term->c_cc[19] = 0x7f; |
| 167 | + term->c_cc[24] = 0x20; |
| 168 | + term->c_cc[25] = 0x88; |
| 169 | + term->c_cc[26] = 0xb6; |
| 170 | + term->c_cc[27] = 0x7f; |
| 171 | + term->c_cc[31] = 0x78; |
| 172 | + |
| 173 | + int pid = forkpty(&fd, nullptr, term, &ws); |
141 | 174 |
|
142 | 175 | if (!pid) { |
143 | 176 | const char *home = "/storage/Users/currentUser"; |
144 | 177 | setenv("HOME", home, 1); |
145 | 178 | setenv("PWD", home, 1); |
146 | | - setenv("PATH", "/data/app/bin:/data/service/hnp/bin:/bin:/usr/local/bin:/usr/bin:/system/bin:/vendor/bin", 1); |
| 179 | + setenv("PATH", |
| 180 | + "/data/app/bin:/data/service/hnp/bin:/bin:" |
| 181 | + "/usr/local/bin:/usr/bin:/system/bin:/vendor/bin", |
| 182 | + 1); |
147 | 183 |
|
148 | 184 | chdir(home); |
149 | 185 | execl("/bin/sh", "/bin/sh", nullptr); |
|
0 commit comments