tb Handle keyboard inside of the shell interactive mode
This commit is contained in:
@ -16,23 +16,11 @@ void tb_runinitscript(void) {
|
||||
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb", "-logcmds", "yes" };
|
||||
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)&tbargs, ARRLEN(tbargs));
|
||||
|
||||
ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_MAKE, NULL, 0);
|
||||
ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_ADD_BCAST, NULL, 1);
|
||||
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_ADD_BCAST, NULL, 1);
|
||||
|
||||
processctl(tb, PCTL_RUN, 0, 0, 0);
|
||||
|
||||
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
int32_t kbchr;
|
||||
int32_t read = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_READ, (uint8_t *)&kbchr, sizeof(kbchr));
|
||||
if (read > 0) {
|
||||
uint8_t c = kbchr & 0xff;
|
||||
if (string_chr_isascii(c)) {
|
||||
if (c != 0) {
|
||||
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_WRITE, &c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
Reference in New Issue
Block a user