Commit 2fcd0535 authored by rswindell's avatar rswindell

When inkey() receives an ANSI escape sequence it doesn't need to consume, put...

When inkey() receives an ANSI escape sequence it doesn't need to consume, put the consumed characters into the keyboard buffer *ahead* of whatever else is in the keyboard buffer already. Uses new ungetkey() insert mode option.
parent e02b1bc5
......@@ -562,13 +562,21 @@ void sbbs_t::pause()
/****************************************************************************/
/* Puts a character into the input buffer */
/****************************************************************************/
void sbbs_t::ungetkey(char ch)
void sbbs_t::ungetkey(char ch, bool insert)
{
#if 0 /* this way breaks ansi_getxy() */
RingBufWrite(&inbuf,(uchar*)&ch,sizeof(uchar));
#else
keybuf[keybuftop++]=ch;
if(keybuftop==KEY_BUFSIZE)
keybuftop=0;
if(insert) {
if(keybufbot == 0)
keybufbot = KEY_BUFSIZE - 1;
else
keybufbot--;
keybuf[keybufbot] = ch;
} else {
keybuf[keybuftop++]=ch;
if(keybuftop==KEY_BUFSIZE)
keybuftop=0;
}
#endif
}
......@@ -306,7 +306,7 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
return(ESC);
ch=i;
if(ch!='[') {
ungetkey(ch);
ungetkey(ch, /* insert: */true);
return(ESC);
}
i=j=0;
......@@ -363,10 +363,10 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
}
break;
}
ungetkey('[');
for(j=0;j<i;j++)
ungetkey(str[j]);
ungetkey(ch);
ungetkey(ch, /* insert: */true);
for(j = i; j > 0; j--)
ungetkey(str[j - 1], /* insert: */true);
ungetkey('[', /* insert: */true);
return(ESC);
}
if(ch=='R') { /* cursor position report */
......@@ -386,9 +386,9 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
str[i++]=ch;
}
ungetkey('[');
for(j=0;j<i;j++)
ungetkey(str[j]);
for(j = i; j > 0; j--)
ungetkey(str[j - 1], /* insert: */true);
ungetkey('[', /* insert: */true);
return(ESC);
}
return(ch);
......
......@@ -784,7 +784,7 @@ public:
/* getkey.cpp */
char getkey(long mode); /* Waits for a key hit local or remote */
long getkeys(const char *str, ulong max, long mode = K_UPPER);
void ungetkey(char ch); /* Places 'ch' into the input buffer */
void ungetkey(char ch, bool insert = false); /* Places 'ch' into the input buffer */
char question[MAX_TEXTDAT_ITEM_LEN+1];
bool yesno(const char *str, long mode = 0);
bool noyes(const char *str, long mode = 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment