...
 
Commits (1)
  • Rob Swindell's avatar
    Improve the ANSI sequence parsing/stripping/pass-through in spy() · 5c711045
    Rob Swindell authored
    Strip all *but* the expected keyboard input sequences (arrow keys, pgup/dn,
    home, end, insert). Pass-through a bare ESC key (albeit with delay). ESC
    immediately followed by a key other than '[' should be very quickly passed
    through.
    Increase the max ANSI sequence length from 31 to 256 chars.
    5c711045
......@@ -1059,8 +1059,8 @@ extern RingBuf* node_inbuf[];
bool sbbs_t::spy(uint i /* node_num */)
{
char ch;
char ansi_seq[32];
int ansi_len;
char ansi_seq[256];
size_t ansi_len;
int in;
if(!i || i>MAX_NODES) {
......@@ -1092,31 +1092,47 @@ bool sbbs_t::spy(uint i /* node_num */)
continue;
}
ch=in;
if(ch==ESC) {
if(!ansi_len) {
ansi_seq[ansi_len++]=ch;
continue;
if(ch == ESC) {
if(ansi_len)
ansi_len = 0;
else {
if((in = incom(500)) != NOINP) {
if(in == '[') {
ansi_seq[ansi_len++] = ESC;
ansi_seq[ansi_len++] = '[';
continue;
} else {
if(node_inbuf[i-1] != NULL) {
RingBufWrite(node_inbuf[i-1], (uchar*)&ch, sizeof(ch));
ch = in;
}
}
}
}
ansi_len=0;
}
if(ansi_len && ansi_len<(int)sizeof(ansi_seq)-2) {
if(ansi_len==1) {
if(ch=='[') {
ansi_seq[ansi_len++]=ch;
continue;
if(ansi_len) {
if(ansi_len < sizeof(ansi_seq))
ansi_seq[ansi_len++] = ch;
if(ch >= '@' && ch <= '~') {
switch(ch) {
case 'A': // Up
case 'B': // Down
case 'C': // Right
case 'D': // Left
case 'F': // Preceding line
case 'H': // Home
case 'K': // End
case 'V': // PageUp
case 'U': // PageDn
case '@': // Insert
case '~': // Various VT-220
// Pass-through these sequences to spied-upon node (eat all others)
if(node_inbuf[i-1] != NULL)
RingBufWrite(node_inbuf[i-1], (uchar*)ansi_seq, ansi_len);
break;
}
ansi_len=0;
}
if(ch=='R') { /* throw-away cursor position report */
ansi_len=0;
continue;
}
ansi_seq[ansi_len++]=ch;
if(isalpha(ch)) {
if(node_inbuf[i-1]!=NULL)
RingBufWrite(node_inbuf[i-1],(uchar*)ansi_seq,ansi_len);
ansi_len=0;
}
continue;
}
if(ch<' ') {
......