1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Merge branch 'read-stdin' of https://github.com/JoeMerten/picocom into JoeMerten-read-stdin

This commit is contained in:
Nick Patavalis
2018-01-16 04:16:26 +02:00

View File

@ -277,6 +277,7 @@ struct tty_q {
.buff = NULL
};
#define STI_RD_SZ 128
#define TTY_RD_SZ 128
int tty_write_sz;
@ -1441,11 +1442,12 @@ loop(void)
}
if ( FD_ISSET(STI, &rdset) ) {
/* read from terminal */
char buff_rd[STI_RD_SZ];
int i;
do {
n = read(STI, &c, 1);
n = read(STI, buff_rd, sizeof(buff_rd));
} while (n < 0 && errno == EINTR);
if (n == 0) {
stdin_closed = 1;
@ -1459,30 +1461,33 @@ loop(void)
goto skip_proc_STI;
}
switch (state) {
case ST_COMMAND:
if ( c == opts.escape ) {
/* pass the escape character down */
if ( tty_q_push((char *)&c, 1) != 1 )
fd_printf(STO, "\x07");
} else {
/* process command key */
if ( do_command(c) )
/* picocom exit */
return LE_CMD;
for ( i = 0; i < n; i++ ) {
c = buff_rd[i];
switch (state) {
case ST_COMMAND:
if ( c == opts.escape ) {
/* pass the escape character down */
if ( tty_q_push((char *)&c, 1) != 1 )
fd_printf(STO, "\x07");
} else {
/* process command key */
if ( do_command(c) )
/* picocom exit */
return LE_CMD;
}
state = ST_TRANSPARENT;
break;
case ST_TRANSPARENT:
if ( ! opts.noescape && c == opts.escape )
state = ST_COMMAND;
else
if ( tty_q_push((char *)&c, 1) != 1 )
fd_printf(STO, "\x07");
break;
default:
assert(0);
break;
}
state = ST_TRANSPARENT;
break;
case ST_TRANSPARENT:
if ( ! opts.noescape && c == opts.escape )
state = ST_COMMAND;
else
if ( tty_q_push((char *)&c, 1) != 1 )
fd_printf(STO, "\x07");
break;
default:
assert(0);
break;
}
}
skip_proc_STI: